httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject proposed modifications to lingering_close()
Date Wed, 22 Jan 1997 07:56:23 GMT
Comments on the below?  It is the start of my suggested changes to
lingering_close.  Things to still be done:
	- add Dead's FD_ISSET tests after thinking
	- probably make up a new timeout and not use hard_timeout()
	- if what I wrote in my last message about lingering_close()
	  being called after a soft_timeout is right, perhaps
	  something to stop that.
	- perhaps not just use keep_alive_timeout, but something a
	  little smarter to pick the select() timeout.

Untested, uncompiled, unfinished.  Unless someone gives me a reason
not to, when they are done I will be submitting these for voting
for inclusion in the next beta...

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.108
diff -u -r1.108 http_main.c
--- 1.108	1997/01/20 04:28:08
+++ http_main.c	1997/01/22 07:50:00
@@ -312,23 +312,30 @@
  */
 
 #ifndef NO_LINGCLOSE
-static void lingering_close (int sd, server_rec *server_conf)
+static void lingering_close (request_rec *r)
 {
     int dummybuf[512];
     struct timeval tv;
     fd_set fds, fds_read, fds_err;
     int select_rv = 0, read_rv = 0;
+    int sd = r->client->fd;
+
+    kill_timeouts(r);
+    hard_timeout("lingering_close", r);
 
     /* Close our half of the connection --- send client a FIN */
 
-    if ((shutdown (sd, 1)) != 0)
-	log_unixerr("shutdown", NULL, "lingering_close", server_conf);
+    if ((shutdown (sd, 1)) != 0) {
+	log_unixerr("shutdown", NULL, "lingering_close", r->server);
+	close(sd);
+	return;
+    }
 
     /* Set up to wait for readable data on socket... */
 
     FD_ZERO (&fds);
     FD_SET (sd, &fds);
-    tv.tv_sec = server_conf->keep_alive_timeout;
+    tv.tv_sec = r->server->keep_alive_timeout;
     tv.tv_usec = 0;
 
     fds_read = fds; fds_err = fds;
@@ -347,22 +354,24 @@
 	    break;
 	else {
 	    fds_read = fds; fds_err = fds;
+	    tv.tv_sec = r->server->keep_alive_timeout;
+	    tv.tv-usec = 0;
 	}
     }
 
     /* 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);
+	log_unixerr("select", NULL, "lingering_close", r->server);
     else if (read_rv < 0 && errno != ECONNRESET)
-	log_unixerr("read", NULL, "lingering_close", server_conf);
+	log_unixerr("read", NULL, "lingering_close", r->server);
 
     /* 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", r->server);
+    }
 }
-#endif
+#endif /* ndef NO_LINGCLOSE */
 
 void usage(char *bin)
 {
@@ -1673,7 +1682,7 @@
 	bclose(conn_io);	/* just close it */
 #else
 	if (r)
-	    lingering_close (conn_io->fd, r->server);
+	    lingering_close (r);
 	else
 	    close (conn_io->fd);
 #endif	


Mime
View raw message