Add a write BlockHandler?

Jeremy White jwhite at
Thu Jun 14 08:45:35 PDT 2012

I'm trying to solve an issue with the Spice xf86_video_qxl driver.[1]
It relies on X for it's mainline, and uses the block handler to detect
input from it's own clients, in addition to finding input from regular X

However, in certain circumstances, a write() call to it's (non X) client
will return EAGAIN.  In an ideal case, we would add that socket to the
writefds of the select() call and go back to waiting.  But the X server
has no facility to allow us to do that, so in theory we fallback on a
spinloop poll.[2]

The Spice maintainers feel the best solution is to modify X to allow us
to add watches to the writefds, so I am here to explore that option.
Note that I'm about as much of a babe in the woods as you can get, so
clue bats are quite welcome.  Just please be gentle.

The relevant xorg code appears nice and simple; a little tweak to
os/WaitFor.c and dix/dixutils.c, and we're all done!  Easy as that, I'm
sure <grin>.

Seriously, if any such change would be accepted, there would seem to be
two approaches, as pointed out by Alon:

  1.  Add an additional parameter (pWritemask) to the callbacks.
      While this technically breaks the ABI, is it in practice
      sufficiently compatible to pass muster?

      This would imply modifying WaitFor to always send a writemask
      to select(), which is probably not a change we want.
      Thus, we would likely have to also have some new way
      to indicate that the writemask is desired.

  2.  Add a new set of callbacks
      Borrowing from my Wine heritage, we could have
      RegisterBlockHandlerEx() and RegisterWakeupHandlerEx()
      <evil grin>.


If given a bit of guidance, I'd be willing to write a naive but earnest
patch.  That would hopefully fill a good developer with enough pity to
write it properly :-/.




[2] In practice, the code is buggy, and we never check the socket again
and the client is lost to us forever.  I have a patch to make the
polling work, but the Spice maintainers feel that the best solution
would be to add a facility to X to allow WaitFor to monitor writefds as
well.  So I'm being sent forth like a sacrificial lamb to plead our
case.  @#$@#$ open source development process :-/.

More information about the xorg-devel mailing list