How would there be a "disastrous hang"? The read callback will only be called when there is something to read, in which case read(N,1) returns immediately. If you use read() to empty the data before the callback gets to it, then the read() in the callback will of course block until there's more data, but that's self-inflicted and rather what you expect would happen if you manually do read() on a blocking fd. If you want to "protect" the user from shooting himself in the foot, I'd rather suggest a check in the read() function that you don't have a read_callback at the same time as you are manually doing a read(). That would break fewer programs. I still think it would be unnecessary pampering though.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-03-19 13:29: Subject: I/O callbacks in blocking mode
It was added to detect races where some code changes a socket to blocking code while other code (i.e. the callbacks) are still using it in nonblocking mode. Without that check, the result is typically a disastrous hang of the backend thread in that situation.
I can't think of a situation where one want to combine callbacks with blocking mode, because of the obvious risk to get a hanging backend. When and why is that used?
/ Martin Stjernholm, Roxen IS