Received: by taz.hyperreal.com (8.8.4/V2.0) id MAA25690; Sat, 15 Feb 1997 12:17:30 -0800 (PST) Received: from twinlark.arctic.org by taz.hyperreal.com (8.8.4/V2.0) with SMTP id MAA25684; Sat, 15 Feb 1997 12:17:27 -0800 (PST) Received: (qmail 24887 invoked by uid 500); 15 Feb 1997 20:17:42 -0000 Date: Sat, 15 Feb 1997 12:17:42 -0800 (PST) From: Dean Gaudet To: new-httpd@hyperreal.com Subject: Re: [PATCH] Big fixes to main loop, lingering_close In-Reply-To: <9702151043.aa02400@paris.ics.uci.edu> 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@hyperreal.com (Still reviewing the patch.) Just a side note about this code from l_c: #ifdef SELECT_NEEDS_CAST select_rv = select(lsd+1, (int*)&fds_read, NULL, (int*)&fds_err, &tv); #else select_rv = select(lsd+1, &fds_read, NULL, &fds_err, &tv); #endif } while ((select_rv > 0) && /* Something to see on socket */ !FD_ISSET(lsd, &fds_err) && /* that isn't an error condition */ FD_ISSET(lsd, &fds_read) && /* and is worth trying to read */ ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0)); On Linux, a select() on an fd which has "EOF in the queue" will return the fd bit in both the read and exception sets (i.e. there's still data to be read, but the Unix knows for certain that the other end has gone away on pipes or sockets). I haven't seen any other Unix do this -- but I did run into it in my mud code when using pipe()s. At this point the code would proceed with the close(). Since the kernel has already received the data, everything might just work "correctly" without us having to even read() it. But otherwise a change like the following would be required: #ifdef SELECT_NEEDS_CAST select_rv = select(lsd+1, (int*)&fds_read, NULL, (int*)&fds_err, &tv); #else select_rv = select(lsd+1, &fds_read, NULL, &fds_err, &tv); #endif if( select_rv <= 0 ) { break; } /* is there something to read? */ if( FD_ISSET(lsd, &fds_read) && ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0) ) { continue; } /* is there an exceptional condition? */ if( read_rv < 0 || FD_ISSET(lsd, &fds_err) ) { break; } } I've always been confused about the except set, isn't it overloaded to mean both error or out-of-band data? Dean