Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 17757 invoked by uid 6000); 19 Mar 1998 14:35:04 -0000 Received: (qmail 17747 invoked from network); 19 Mar 1998 14:35:03 -0000 Received: from valis.worldgate.com (marcs@198.161.84.2) by taz.hyperreal.org with SMTP; 19 Mar 1998 14:35:03 -0000 Received: from localhost (marcs@localhost) by valis.worldgate.com (8.8.7/8.8.7) with SMTP id HAA23318 for ; Thu, 19 Mar 1998 07:35:02 -0700 (MST) Date: Thu, 19 Mar 1998 07:35:02 -0700 (MST) From: Marc Slemko To: Apache Developer ML Subject: Re: Question: select loop for reliable sockets In-Reply-To: <199803191314.OAA27772@en1.engelschall.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org 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.