Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!tektronix!tekcrl!soiffer From: soiffer@tekcrl.TEK.COM (Neil Soiffer) Newsgroups: comp.windows.x Subject: XNextEvent/XPending bug in v10? Message-ID: <1915@tekcrl.TEK.COM> Date: Sat, 29-Aug-87 14:16:46 EDT Article-I.D.: tekcrl.1915 Posted: Sat Aug 29 14:16:46 1987 Date-Received: Sun, 30-Aug-87 09:20:30 EDT Organization: Tektronix Inc., Beaverton, Or. Lines: 40 As has been mentioned before in this group, if the server sends a large number of events to the client, then the server blocks on write. The client in the meantime, may be sending requests to the server, but because the server is blocked, the client fills its write buffer and blocks also. Deadlock. An XIOError is eventually generated after the connection is closed. [I am told that in X11, the server will not block so this is only an X10 problem.] Most programs (mine included) have a main loop that looks like: do forever XNextEvent(&event) process event... XNextEvent (and other library calls that deal with input) limit the amount read from the server in a single call to "BUFFSIZE" bytes. This means that calling XNextEvent won't necessarily read all pending input onto the X input queue -- hence the server may not unblock. It seems like the obvious thing to do is to add "XPending()" to the top of the loop to get all pending events [assuming you don't fill the write buffer in one loop iteration]. However, XPending limits the amount it reads to "BUFFSIZE" also, hence a single call to XPending won't do. My question: why do XPending and XNextEvent have these limits? What will I break if I change the code to loop until all the pending input that 'ioctl' claims is there is read? Hint to others: looking thru the code, the only way that I can see to get around this problem is to put 'XSync(0)' at the top of the loop. This will cause all events to be read until the reply is found. This is somewhat slow because 'read' is called with bytes=sizeof(XEvent) instead of calling 'read' with a large buffer. Does anybody have any other ideas/suggestions how to handle this problem? Neil Soiffer Textronix Computer Research Lab UUCP: ...!tektronix!tekchips!soiffer ARPA: soiffer%tekchips.tek.com@relay.cs.net CSNET: soiffer%tekchips.tek.com