components/libmicrohttpd/patches/003.patch
author Tomas Heran <tomas.heran@oracle.com>
Thu, 16 Apr 2015 11:08:39 +0200
branchs11-update
changeset 4142 ac544f9e49ee
child 7790 178c7062efc0
permissions -rw-r--r--
PSARC/2014/289 libmicrohttpd 20235905 GNU Libmicrohttpd - C library HTTP server should be added to Userland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4142
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     1
Tomas Heran <[email protected]>
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     2
Allow MHD to work with connections not represented by file descriptors but
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     3
rather an object that has recv and send "methods".
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     4
NOTE: This RFE hasn't been shared with upstream yet.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     5
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     6
diff -r efe4a6fcacd1 -r 6d80d5999249 src/include/microhttpd.h
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     7
--- a/src/include/microhttpd.h	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     8
+++ b/src/include/microhttpd.h	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     9
@@ -285,7 +285,7 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    10
  * with the SHOUTcast "ICY" line instad of "HTTP".
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    11
  * @ingroup specialized
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    12
  */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    13
-#define MHD_ICY_FLAG ((uint32_t)(1 << 31))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    14
+#define MHD_ICY_FLAG ((uint32_t)((uint32_t)1 << 31))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    15
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    16
 /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    17
  * @defgroup headers HTTP headers
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    18
@@ -562,7 +562,9 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    19
    * kernel >= 3.6.  On other systems, using this option cases #MHD_start_daemon
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    20
    * to fail.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    21
    */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    22
-  MHD_USE_TCP_FASTOPEN = 16384
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    23
+  MHD_USE_TCP_FASTOPEN = 16384,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    24
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    25
+  MHD_USE_STREAM_CONNS = 32768
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    26
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    27
 };
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    28
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    29
@@ -1445,6 +1447,16 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    30
 		    const struct sockaddr *addr,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    31
 		    socklen_t addrlen);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    32
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    33
+_MHD_EXTERN int
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    34
+MHD_add_stream_connection (struct MHD_Daemon *daemon,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    35
+    void *stream,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    36
+    ssize_t (*recv_cls_u) (struct MHD_Connection * conn,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    37
+	    void *write_to, size_t max_bytes),
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    38
+    ssize_t (*send_cls_u) (struct MHD_Connection * conn,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    39
+	    const void *write_to, size_t max_bytes));
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    40
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    41
+void * MHD_get_stream_connection_data(struct MHD_Connection *conn);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    42
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    43
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    44
 /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    45
  * Obtain the `select()` sets for this daemon.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    46
diff -r efe4a6fcacd1 -r 6d80d5999249 src/microhttpd/connection.c
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    47
--- a/src/microhttpd/connection.c	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    48
+++ b/src/microhttpd/connection.c	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    49
@@ -2565,7 +2565,7 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    50
 				      connection,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    51
 				      &connection->client_context,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    52
 						  MHD_REQUEST_TERMINATED_COMPLETED_OK);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    53
-            connection->client_aware = MHD_NO;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    54
+            //connection->client_aware = MHD_NO;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    55
           }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    56
           end =
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    57
             MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    58
@@ -2599,7 +2599,13 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    59
                                   connection->read_buffer,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    60
                                   connection->read_buffer_size);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    61
             }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    62
-	  connection->client_aware = MHD_NO;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    63
+	  /*
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    64
+	   * This member, if set to MHD_NO, causes completion notification *NOT*
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    65
+	   * to be fired if client closes a connection. So, in this case, if
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    66
+	   * client closed a connection after a request/response exchange was
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    67
+	   * finished, the completion handler wouldn't be called.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    68
+	   */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    69
+	  /* connection->client_aware = MHD_NO; */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    70
           connection->client_context = NULL;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    71
           connection->continue_message_write_offset = 0;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    72
           connection->responseCode = 0;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    73
diff -r efe4a6fcacd1 -r 6d80d5999249 src/microhttpd/daemon.c
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    74
--- a/src/microhttpd/daemon.c	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    75
+++ b/src/microhttpd/daemon.c	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    76
@@ -1131,7 +1131,10 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    77
 			 MHD_socket client_socket,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    78
 			 const struct sockaddr *addr,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    79
 			 socklen_t addrlen,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    80
-			 int external_add)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    81
+			 int external_add,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    82
+			 ReceiveCallback recv_cls_u,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    83
+			 TransmitCallback send_cls_u,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    84
+			 void *callback_data)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    85
 {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    86
   struct MHD_Connection *connection;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    87
   int res_thread_create;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    88
@@ -1150,7 +1153,10 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    89
 	  return internal_add_connection (&daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size],
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    90
 					  client_socket,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    91
 					  addr, addrlen,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    92
-					  external_add);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    93
+					  external_add,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    94
+					  recv_cls_u,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    95
+					  send_cls_u,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    96
+					  callback_data);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    97
       /* all pools are at their connection limit, must refuse */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    98
       if (0 != MHD_socket_close_ (client_socket))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    99
 	MHD_PANIC ("close failed\n");
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   100
@@ -1288,10 +1294,21 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   101
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   102
   /* set default connection handlers  */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   103
   MHD_set_http_callbacks_ (connection);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   104
-  connection->recv_cls = &recv_param_adapter;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   105
-  connection->send_cls = &send_param_adapter;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   106
-
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   107
-  if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   108
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   109
+  if (recv_cls_u == NULL)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   110
+    connection->recv_cls = &recv_param_adapter;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   111
+  else
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   112
+    connection->recv_cls = recv_cls_u;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   113
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   114
+  if (send_cls_u == NULL)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   115
+    connection->send_cls = &send_param_adapter;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   116
+  else
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   117
+    connection->send_cls = send_cls_u;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   118
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   119
+  connection->callback_data = callback_data;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   120
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   121
+  if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO) &&
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   122
+      0 == (connection->daemon->options & MHD_USE_STREAM_CONNS))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   123
     {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   124
       /* non-blocking sockets are required on most systems and for GNUtls;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   125
 	 however, they somehow cause serious problems on CYGWIN (#1824);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   126
@@ -1746,11 +1763,29 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   127
 		    socklen_t addrlen)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   128
 {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   129
   make_nonblocking_noninheritable (daemon,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   130
-				   client_socket);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   131
+   client_socket);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   132
   return internal_add_connection (daemon,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   133
 				  client_socket,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   134
 				  addr, addrlen,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   135
-				  MHD_YES);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   136
+				  MHD_YES, NULL, NULL, NULL);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   137
+}
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   138
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   139
+int
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   140
+MHD_add_stream_connection (struct MHD_Daemon *daemon,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   141
+    void *stream,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   142
+    ssize_t (*recv_cls_u) (struct MHD_Connection * conn,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   143
+	    void *write_to, size_t max_bytes),
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   144
+    ssize_t (*send_cls_u) (struct MHD_Connection * conn,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   145
+	    const void *write_to, size_t max_bytes))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   146
+{
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   147
+  return internal_add_connection (daemon, -1, NULL, 0, MHD_YES, recv_cls_u,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   148
+                                  send_cls_u, stream);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   149
+}
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   150
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   151
+void *
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   152
+MHD_get_stream_connection_data(struct MHD_Connection *conn)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   153
+{
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   154
+  return (conn->callback_data);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   155
 }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   156
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   157
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   158
@@ -1826,7 +1861,7 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   159
 #endif
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   160
   (void) internal_add_connection (daemon, s,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   161
 				  addr, addrlen,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   162
-				  MHD_NO);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   163
+				  MHD_NO, NULL, NULL, NULL);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   164
   return MHD_YES;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   165
 }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   166
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   167
@@ -2097,6 +2132,45 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   168
   return MHD_YES;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   169
 }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   170
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   171
+/**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   172
+ */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   173
+static int
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   174
+MHD_poll_stream_conns (struct MHD_Daemon *daemon,
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   175
+	    int may_block)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   176
+{
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   177
+  int num_ready;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   178
+  struct MHD_Connection *pos;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   179
+  struct MHD_Connection *next;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   180
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   181
+  if (MHD_YES == daemon->shutdown)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   182
+    return MHD_NO;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   183
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   184
+  next = daemon->connections_head;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   185
+  while (NULL != (pos = next))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   186
+  {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   187
+    next = pos->next;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   188
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   189
+    /* Is there any I/O event there? */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   190
+      switch (pos->event_loop_info)
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   191
+      {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   192
+      case MHD_EVENT_LOOP_INFO_READ:
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   193
+				pos->read_handler (pos);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   194
+        break;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   195
+      case MHD_EVENT_LOOP_INFO_WRITE:
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   196
+				pos->write_handler (pos);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   197
+        break;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   198
+      case MHD_EVENT_LOOP_INFO_BLOCK:
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   199
+        break;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   200
+      case MHD_EVENT_LOOP_INFO_CLEANUP:
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   201
+        /* should never happen */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   202
+        break;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   203
+      }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   204
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   205
+    pos->idle_handler (pos);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   206
+  }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   207
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   208
+  return MHD_YES;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   209
+}
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   210
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   211
 /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   212
  * Main internal select() call.  Will compute select sets, call select()
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   213
@@ -2675,6 +2749,11 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   214
     MHD_cleanup_connections (daemon);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   215
   }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   216
 #endif
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   217
+  else if (0 != (daemon->options & MHD_USE_STREAM_CONNS))
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   218
+  {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   219
+    MHD_poll_stream_conns (daemon, MHD_NO);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   220
+    MHD_cleanup_connections (daemon);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   221
+  }
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   222
   else
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   223
   {
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   224
     MHD_select (daemon, MHD_NO);
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   225
diff -r efe4a6fcacd1 -r 6d80d5999249 src/microhttpd/internal.h
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   226
--- a/src/microhttpd/internal.h	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   227
+++ b/src/microhttpd/internal.h	Thu Dec 18 21:49:28 2014 +0100
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   228
@@ -803,6 +803,11 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   229
    */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   230
   TransmitCallback send_cls;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   231
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   232
+  /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   233
+   * User specified data that's associated with a connection.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   234
+   */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   235
+  void *callback_data;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   236
+
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   237
 #if HTTPS_SUPPORT
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   238
   /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   239
    * State required for HTTPS/SSL/TLS support.
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   240
@@ -1050,7 +1055,7 @@
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   241
   /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   242
    * Number of worker daemons
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   243
    */
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   244
-  unsigned int worker_pool_size;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   245
+  unsigned long long worker_pool_size;
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   246
 
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   247
   /**
ac544f9e49ee PSARC/2014/289 libmicrohttpd
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   248
    * The select thread handle (if we have internal select)