randy 96/07/26 21:09:05
Modified: src http_main.c Log: Disable Nagle algorithm. HTTP != telnet Reviewed by: Chuck Murko, Ben Laurie, Robert Thau and a cast of thousands Submitted by: John Heidemann <[EMAIL PROTECTED]> Revision Changes Path 1.55 +26 -1 apache/src/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.54 retrieving revision 1.55 diff -C3 -r1.54 -r1.55 *** http_main.c 1996/07/21 14:49:01 1.54 --- http_main.c 1996/07/27 04:09:03 1.55 *************** *** 106,111 **** --- 106,112 ---- #include <sys/audit.h> #include <prot.h> #endif + #include <netinet/tcp.h> #include "explain.h" *************** *** 1267,1272 **** --- 1268,1293 ---- return conn; } + void sock_disable_nagle (int s) + { + /* + * The Nagle algorithm says that we should delay sending partial + * packets in hopes of getting more data. We don't want to do + * this; we are not telnet. There are bad interactions between + * P-HTTP and Nagle's algorithm that have very severe performance + * penalties. (Failing to do disable Nagle is not much of a + * problem with simple HTTP.) A better description of these + * problems is in preparation; contact me for details. + * -John Heidemann <[EMAIL PROTECTED]>. + * + * In spite of these problems, failure here is not a shooting offense. + */ + const int just_say_no = 1; + if (0 != setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no, + sizeof(just_say_no))) + fprintf(stderr, "httpd: could not set socket option TCP_NODELAY\n"); + } + /***************************************************************** * Child process main loop. * The following vars are static to avoid getting clobbered by longjmp(); *************** *** 1397,1403 **** log_unixerr("getsockname", NULL, NULL, server_conf); continue; } ! (void)update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); conn_io = bcreate(ptrans, B_RDWR); dupped_csd = csd; --- 1418,1426 ---- log_unixerr("getsockname", NULL, NULL, server_conf); continue; } ! ! sock_disable_nagle(csd); ! (void)update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); conn_io = bcreate(ptrans, B_RDWR); dupped_csd = csd; *************** *** 1506,1511 **** --- 1529,1536 ---- exit(1); } + sock_disable_nagle(s); + #ifdef USE_SO_LINGER /* If puts don't complete, you could try this. */ { /* Unfortunately, SO_LINGER causes problems as severe as it