[Xcb] xcb recursive write not protected in all cases?

Keith Packard keithp at keithp.com
Tue Dec 24 11:41:55 PST 2013


Keith Packard <keithp at keithp.com> writes:

> Yeah, I think we need to move the wait for reading/writing out of
> _xcb_conn_wait and do that before allocating the sequence number.

On additional review, this one looks OK -- the request sequence is
allocated and then the request immediately dumped into the output
buffer, which defines the request order.

The only requirement is that Xlib flush that buffer and prevent further
additions to it while it holds the socket, and that is not done reliably
yet.

Whew. This isn't as bad as I'd feared. I think we just need to generate
functions which prepare the socket for Xlib or XCB request writing
reliably, instead of having ad-hoc versions across the code.

For XCB, I think the invariants we must provide are:

        Xlib doesn't own the socket (out.return_socket is NULL)
        out.writing is zero
        There is space to write a couple of GetInputFocus requests to out.queue

This last will make sure that any send_sync calls that are made will
*not* drop iolock and we will call _xcb_out_send at most one time. I
think that would be easily done by simply leaving space in out.queue for
two GetInputFocus requests for 'normal' writes, and then having the
send_sync calls from xcb_send_request potentially use up that space, but
all other send_request calls leave it available.

For Xlib, this is done in xcb_take_socket and the invariants required
are:
        
        No-one else owns the socket (out.return_socket is NULL)
        out.writing is zero
        out.queue_len is zero
        
Looking at _xcb_out_flush_to, I'm confused why that waits for
out.writing to go to zero; the only requirement that function should
have is to ensure that the desired request will eventually get onto the
wire, which is satisfied by making sure that someone has called write.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20131224/1f521bfd/attachment.pgp>


More information about the Xcb mailing list