Skip to content
  • Keith Packard's avatar
    Ensure xcb owns socket and no other threads are writing before send_request · be0fe56c
    Keith Packard authored and Uli Schlachter's avatar Uli Schlachter committed
    
    
    send_request may only write to out.queue if no other thread is busy
    writing to the network (as that thread may be writing from out.queue).
    
    send_request may only allocate request sequence numbers if XCB owns
    the socket.
    
    Therefore, send_request must make sure that both conditions are true
    when it holds iolock, which can only be done by looping until both
    conditions are true without having dropped the lock waiting for the
    second condition.
    
    We choose to get the socket back from Xlib first as get_socket_back
    has a complicated test and checking for other threads writing is a
    simple in-lined check.
    
    This also changes the sequence number checks (64k requests with no
    reply, 4M request wrapping) to ensure that both conditions are true
    before queueing the request.
    
    Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
    Reviewed-by: default avatarUli Schlachter <psychon@znc.in>
    be0fe56c