httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Ralf S. Engelschall)
Subject Re: Question: select loop for reliable sockets
Date Thu, 19 Mar 1998 16:32:52 GMT

In article <> you wrote:
> 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 write is done in mod_log_config.c while the Apache core tries to maintain
the registered socket in its probe_writeable_fds() function.  So the return
code from write is useless here, I think. Because I cannot send any
information from there to the Apache core.

> 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.

That's a possible alternative, yes. Thanks for the hint. 

BUT: Why does it work for reliable piped logs, but not for
     reliable socket logs? Is this a coincidence or why does
     it work for the reliable piped logs in Apache this way?

                                       Ralf S. Engelschall

View raw message