httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <>
Subject Re: Question: select loop for reliable sockets
Date Thu, 19 Mar 1998 14:35:02 GMT
On Thu, 19 Mar 1998, Ralf S. Engelschall wrote:

> I'm currently trying to enhance my patch for logfile network socket support by
> making those socket logs reliable, i.e. when the connection breaks (e.g. the
> logfile master server rebooted, etc.) the socket connection should be
> re-initiated again. My idea is to use the maintainance functionality already
> used for reliable piped logs.  Now I discovered that the probe_writable_fds()
> function from http_main.c is run correctly but never is able to see the broken
> socket. The FD_ISSET always returns true for the socket, although the
> logfile-server already is down and mod_log_custom.c already sends to the
> broken socket.
> To trace it down I've extracted the relevant peace of code into a little
> stand-alone program, and it showed the same behaviour: Sure, when the server
> wents down, my program (the client) receives a SIGPIPE.  But the select-based
> loop still is unable to recognize the fact that the socket is now broken. The
> question is: WHY? Or what have to be arranged to let the FD_ISSET fail for the
> socket? Perhaps some fiddling with setsockopt() or some fcntl()'s? Please
> help!

A socket will be ready for writing if the connection is closed or 
there is an error pending.  You have to check the return code from
your write if you want to know if anything is being written.

The other alternative is to also check if they are readable and, if so,
see if you get an EOF or error.  If so, it is closed.

View raw message