Fine.
The debug tools I'd like to use is rather one where you can set a flag on a thread which causes an error to be thrown whenever a blocking operation is attempted in it, and another that restricts the use of read and/or write on an fd to a single thread.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-03-19 15:54: Subject: I/O callbacks in blocking mode
That's a good suggestion.
Please don't. :-)
The real code in my daemons is closer to this:
void read_callback( mixed ignore, string x ) { while( strlen( x ) ) { int len; if( strlen( x ) < 4 ) x += fd->read( 4-strlen(x) ); sscanf( x, "%4c%s", len, x ); if( strlen( x ) < len ) x += fd->read( len-strlen(x) ); if( mixed e = catch(handle_command( x[..len-1] )) ) { werror( describe_backtrace( e ) ); exit( 1 ); } x = x[len..]; } }
Please note that I am reading data in the read callback.
It seems somewhat pointless to have to add fd->set_read_callback( 0 ) at the beginning and fd->set_read_callback( read_callback ) at the end.
What I would really like, btw, is a read callback that does not do the actual read() call.
/ Per Hedbor ()