Quellcode durchsuchen

fixing mantis 1434

Christian Grothoff vor 17 Jahren
Ursprung
Commit
77fad50adf
5 geänderte Dateien mit 29 neuen und 4 gelöschten Zeilen
  1. 1 0
      AUTHORS
  2. 6 1
      ChangeLog
  3. 3 1
      configure.ac
  4. 15 0
      src/daemon/connection.c
  5. 4 2
      src/examples/minimal_example_comet.c

+ 1 - 0
AUTHORS

@@ -14,6 +14,7 @@ Greg Schohn <[email protected]>
 Thomas Martin <[email protected]>
 Peter Ross <[email protected]>
 RuXu W <[email protected]>
+Matthew Moore
 
 Documentation contributions also came from:
 Marco Maggi <[email protected]>

+ 6 - 1
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 "$BCf9q(B").
+	 Unescape URIs (convert "%ef%e4%45" to "$BCf9q(B"). -CG
 
 Wed Sep 10 22:43:59 MDT 2008
 	 Releasing GNU libmicrohttpd 0.4.0pre0. -CG

+ 3 - 1
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

+ 15 - 0
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->

+ 4 - 2
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