You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1997/02/09 08:30:45 UTC
[PATCH] lingering_close performance improvement
This should make lingering_close as efficient as a NO_LINGCLOSE
without keepalives. Note, however, that it is still necessary
to disable keepalive for OSes without FIN_WAIT_2 timeouts, since
it isn't possible for us to fix that browser bug.
.....Roy
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.116
diff -c -r1.116 http_main.c
*** http_main.c 1997/02/04 23:54:23 1.116
--- http_main.c 1997/02/09 07:21:58
***************
*** 329,339 ****
kill_timeout(r); /* Remove any leftover timeouts */
! /* Close our half of the connection --- send client a FIN */
! if ((shutdown(sd, 1)) != 0) {
/* if it fails, no need to go through the rest of the routine */
! log_unixerr("shutdown", NULL, "lingering_close", r->server);
close(sd);
return;
}
--- 329,342 ----
kill_timeout(r); /* Remove any leftover timeouts */
! /* Close our half of the connection --- send client a FIN and
! * set the socket to non-blocking for later reads.
! */
! if (((shutdown(sd, 1)) != 0) || (fcntl(sd, F_SETFL, FNDELAY) == -1)) {
/* if it fails, no need to go through the rest of the routine */
! if (errno != ENOTCONN)
! log_unixerr("shutdown", NULL, "lingering_close", r->server);
close(sd);
return;
}
***************
*** 355,366 ****
hard_timeout("lingering_close", r);
do {
! /* If keep_alive_timeout is too low, using it as a timeout
! * can cause undesirable behavior so pick some pseudo-arbitrary
! * minimum value, currently 10 seconds. These parameters are
! * reset on each pass, since they may be changed by select.
! */
! tv.tv_sec = max(r->server->keep_alive_timeout, 10);
tv.tv_usec = 0;
read_rv = 0;
fds_read = fds;
--- 358,373 ----
hard_timeout("lingering_close", r);
do {
! /* We use a 1 second timeout because current (Feb 97) browsers
! * fail to close a connection after the server closes it. Thus,
! * to avoid keeping the child busy, we are only lingering long enough
! * for a client that is actively sending data on a connection.
! * This should be sufficient unless the connection is massively
! * losing packets, in which case we might have missed the RST anyway.
! * These parameters are reset on each pass, since they might be
! * changed by select.
! */
! tv.tv_sec = 1;
tv.tv_usec = 0;
read_rv = 0;
fds_read = fds;