libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 77fad50adfdcd5fff1c5b7c7b5aa9f1e166ede99
parent eea5080786234ad8d8d73b49dcca2b3d1c44ae7a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  8 Nov 2008 09:21:08 +0000

fixing mantis 1434

Diffstat:
MAUTHORS | 1+
MChangeLog | 7++++++-
Mconfigure.ac | 4+++-
Msrc/daemon/connection.c | 15+++++++++++++++
Msrc/examples/minimal_example_comet.c | 6++++--
5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -14,6 +14,7 @@ Greg Schohn <greg.schohn@gmail.com> Thomas Martin <Thomas.Martin@rohde-schwarz.com> Peter Ross <pross@xvid.org> RuXu W <wrxzzj@gmail.com> +Matthew Moore Documentation contributions also came from: Marco Maggi <marco.maggi-ipsu@poste.it> diff --git a/ChangeLog b/ChangeLog @@ -1,9 +1,14 @@ +Sat Nov 8 02:18:42 MST 2008 + Unset TCP_CORK at the end of transmitting a response + to improve performance (on systems where this is + supported). -MM + Tue Sep 30 16:48:08 MDT 2008 Make MHD useful to Cygwin users; detect IPv6 headers in configure. Sun Sep 28 14:57:46 MDT 2008 - Unescape URIs (convert "%ef%e4%45" to "中国"). + Unescape URIs (convert "%ef%e4%45" to "中国"). -CG Wed Sep 10 22:43:59 MDT 2008 Releasing GNU libmicrohttpd 0.4.0pre0. -CG diff --git a/configure.ac b/configure.ac @@ -136,7 +136,7 @@ AC_SUBST(PTHREAD_CPPFLAGS) AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) # Check for optional headers -AC_CHECK_HEADERS([sys/select.h sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h time.h sys/socket.h sys/mman.h arpa/inet.h]) +AC_CHECK_HEADERS([sys/select.h sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h]) # IPv6 AC_MSG_CHECKING(for IPv6) @@ -161,6 +161,8 @@ have_inet6=no ) AC_MSG_RESULT($have_inet6) +# TCP_CORK +AC_CHECK_DECL([TCP_CORK], [], [], [[#include <netinet/tcp.h>]]) # libcurl (required for testing) SAVE_LIBS=$LIBS diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -1921,6 +1921,14 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) continue; } connection->state = MHD_CONNECTION_HEADERS_SENDING; + +#if HAVE_TCP_CORK + /* starting header send, set TCP cork */ + { + const int val = 1; + setsockopt(connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, sizeof(val)); + } +#endif break; case MHD_CONNECTION_HEADERS_SENDING: /* no default action */ @@ -1976,6 +1984,13 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) /* no default action */ break; case MHD_CONNECTION_FOOTERS_SENT: +#if HAVE_TCP_CORK + /* done sending, uncork */ + { + const int val = 0; + setsockopt(connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, sizeof(val)); + } +#endif MHD_destroy_response (connection->response); if (connection->daemon->notify_completed != NULL) connection->daemon->notify_completed (connection-> diff --git a/src/examples/minimal_example_comet.c b/src/examples/minimal_example_comet.c @@ -31,9 +31,11 @@ data_generator(void * cls, char * buf, int max) { + if (max < 80) + return 0; memset(buf, 'A', max-1); - buf[max-1] = '\n'; - return max; + buf[79] = '\n'; + return 80; } static int