Hi! On Fri, Jun 26, 2009 at 04:37:53PM +0800, Clint Webb wrote: >[...]
>2. You can check the status of the socket before you write to it. That's racey. >socklen_t err_len; >int error; >err_len = sizeof(error); >getsockopt(handle, SOL_SOCKET, SO_ERROR, &error, &err_len); >if (error != ESHUTDOWN) { > // actually, I cant remember what E code to check, > // ESHUTDOWN might not be it... you can look that up yourself. >} And then the remote side closes it, then you write and get SIGPIPE anyway. That's a classical race condition. >As an aside, most people dont get this error under 'normal' conditions >because as part of their process they tend to always do a read before >attempting a write. The same kind of race condition. It may occur much more seldom than when you write without reading (or checking SO_ERROR) before, but it *will* occur eventually. >[...] The only sane way is ignoring SIGPIPE. SIGPIPE is fine for Unix pipe filter programs. For network daemons SIGPIPE's only disposition is to be ignored (and to handle EPIPE instead). Kind regards, Hannah. _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users