--- ../../apache_1.1b4_pure/src/http_main.c Thu Jun 13 13:33:02 1996 +++ http_main.c Sat Jun 29 02:21:09 1996 @@ -104,6 +104,10 @@ #include #include #endif +#ifdef ISI_NO_NAGLE +#include +#endif /* ISI_NO_NAGLE */ + /* * Actual definitions of config globals... here because this is @@ -1115,6 +1119,28 @@ return conn; } +#ifdef ISI_NO_NAGLE +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 . + * + * 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"); +} +#endif /* ISI_NO_NAGLE */ + /***************************************************************** * Child process main loop. * The following vars are static to avoid getting clobbered by longjmp(); @@ -1215,7 +1241,21 @@ log_unixerr("getsockname", NULL, NULL, server_conf); continue; } - + +#ifdef ISI_NO_NAGLE + sock_disable_nagle(csd); +#endif /* ISI_NO_NAGLE */ + +#ifdef ISI_SOCKOPT + /* for debugging */ +{ + int size, sizelen = sizeof(size), e; + if (0 == (e = getsockopt(csd, IPPROTO_TCP, TCP_NODELAY, &size, &sizelen))) { + fprintf(stderr, "getsockopt: TCP_NODELAY = %d, (response size=%d\n", size, sizelen); + } else fprintf(stderr, "getsockopt: return=%d, errno=%d\n", e, errno); +} +#endif /* ISI_SOCKOPT */ + (void)update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); conn_io = bcreate(ptrans, B_RDWR); dupped_csd = csd; @@ -1311,6 +1351,10 @@ fprintf(stderr,"httpd: could not set socket option SO_KEEPALIVE\n"); exit(1); } + +#ifdef ISI_NO_NAGLE + sock_disable_nagle(s); +#endif /* ISI_NO_NAGLE */ #ifdef NEED_LINGER /* If puts don't complete, you could try this. */ {