httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: lingering_close questions?
Date Sat, 18 Jan 1997 21:43:07 GMT
On Fri, 17 Jan 1997, Jim Jagielski wrote:
> >>>>>>	   fds_read = fds; fds_err = fds;
> Why are we resetting fds_read/fds_err?

Well you have to reset them because they are "in out" parameters.  At any
rate, this loop looks bogus to me.  It doesn't check FD_ISSET( sd,
&fds_err ), and it doesn't check FD_ISSET( sd, &fds_read ). 

I don't think select will ever return 0 'cause of the timeout thing.  But
if it is, then the logging code doesn't do the right thing.

Anyone want to try this patch on their server with FIN_WAIT_2s?  (I had to
back out of 1.2 on the hotwired servers 'cause of problems with the
hotwired part of the code.)

Dean

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.106
diff -u -r1.106 http_main.c
--- http_main.c	1997/01/12 20:38:12	1.106
+++ http_main.c	1997/01/18 21:41:08
@@ -315,7 +315,7 @@
     int dummybuf[512];
     struct timeval tv;
     fd_set fds, fds_read, fds_err;
-    int select_rv = 0, read_rv = 0;
+    int select_rv = 0, read_rv = 0, close_rv;
 
     /* Close our half of the connection --- send client a FIN */
 
@@ -341,24 +341,29 @@
 #else
     while ((select_rv = select (sd + 1, &fds_read, NULL, &fds_err, &tv)) >
0) {
 #endif
-	if ((read_rv = read (sd, dummybuf, sizeof(dummybuf))) <= 0)
+	if( FD_ISSET( sd, &fds_err ) ) {
+	    read_rv = 0;
 	    break;
-	else {
+	} else if ( FD_ISSET( sd, &fds_read )
+	    && (read_rv = read (sd, dummybuf, sizeof(dummybuf))) <= 0) {
+	    break;
+	} else {
 	    fds_read = fds; fds_err = fds;
 	}
     }
 
     /* Log any errors that occured (client closing their end isn't an error) */
-    
+
     if (select_rv < 0)
 	log_unixerr("select", NULL, "lingering_close", server_conf);
-    else if (read_rv < 0 && errno != ECONNRESET)
+    else if (select_rv > 0 && read_rv < 0 && errno != ECONNRESET)
 	log_unixerr("read", NULL, "lingering_close", server_conf);
 
     /* Should now have seen final ack.  Safe to finally kill socket */
 
-    shutdown (sd, 2);
-    close (sd);
+    if ( ( close_rv = close (sd) ) < 0 ) {
+	log_unixerr("close", NULL, "lingering_close", server_conf);
+    }
 }
 #endif
 


Mime
View raw message