I see another old suggestion is to use flags not to call read_callback if read was previously called on that socket but after the last poll.
Would that solve the thread problem? It seems simpler then using buffers.
/ Mirar
Previous text:
2003-03-19 23:48: Subject: I/O callbacks in blocking mode
/.../ or that Pike loops over every socket that made poll exit until it calls poll again (which is a good idea, generally?).
That's probably it, judging from your comment at the start of __stdio_read_callback. I see two ways to solve it without resorting to peeking, which apparently is slow:
- Read out the data from all the fds before calling any callbacks.
- Read out the data from one of the fds and do the equivalent of read(0,1) on all the others, then call the callback for the one fd only.
The first solution can have tricky compatibility effects in code that reads on an fd from the read callback of another; it will no longer get any data since it has been read already. Otoh, it seems very precarious to write such code. Do you remember where you came across it?
/ Martin Stjernholm, Roxen IS