commit 9e87c9a225ddcb3092fd3cd9ec428801edac69b4
parent 475b350b710463111893bf4b9deb3c8e5a1c62cc
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 2 Sep 2015 14:45:28 +0000
patch from FC to fix use of resume in combination with external select
Diffstat:
5 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/AUTHORS b/AUTHORS
@@ -54,6 +54,7 @@ Guy Martin <gmsoft@tuxicoman.be>
Robert Groenenberg <robert.groenenberg@broadforward.com>
Denis Dowling <denis.dowling@hsd.com.au>
Louis Benoit <louisbenoit@videotron.ca>
+Flavio Coelin <flavio.ceolin@intel.com>
Documentation contributions also came from:
Marco Maggi <marco.maggi-ipsu@poste.it>
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Sep 2 16:50:31 CEST 2015
+ Call resume_suspended_connections() when the user is running
+ its own mainloop and calls MHD_run_from_select() to support
+ resuming connections with external select. -FC
+
Sun Aug 30 14:53:51 CEST 2015
Correct documentation as to when MHD_USE_EPOLL_LINUX_ONLY
is allowed. -CG
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
* Current version of the library.
* 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00094210
+#define MHD_VERSION 0x00094211
/**
* MHD-internal return code for "YES".
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -2220,6 +2220,12 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
char tmp;
struct MHD_Connection *pos;
struct MHD_Connection *next;
+ unsigned int mask = MHD_USE_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY |
+ MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION;
+
+ /* Resuming external connections when using an extern mainloop */
+ if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask))
+ resume_suspended_connections (daemon);
#if EPOLL_SUPPORT
if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY))
diff --git a/src/testcurl/test_callback.c b/src/testcurl/test_callback.c
@@ -17,59 +17,63 @@
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
/**
* @file test_callback.c
* @brief Testcase for MHD not calling the callback too often
- * @author Jan Seeger
+ * @author Jan Seeger
* @author Christian Grothoff
*/
-
-
#include "MHD_config.h"
#include "platform.h"
#include <curl/curl.h>
#include <microhttpd.h>
-struct callback_closure {
+struct callback_closure
+{
unsigned int called;
};
-static ssize_t
-called_twice(void *cls, uint64_t pos, char *buf, size_t max)
+static ssize_t
+called_twice(void *cls, uint64_t pos, char *buf, size_t max)
{
struct callback_closure *cls2 = cls;
-
- if (cls2->called == 0)
+
+ if (cls2->called == 0)
{
memset(buf, 0, max);
strcat(buf, "test");
cls2->called = 1;
return strlen(buf);
}
- if (cls2->called == 1)
+ if (cls2->called == 1)
{
cls2->called = 2;
return MHD_CONTENT_READER_END_OF_STREAM;
}
- fprintf(stderr,
+ fprintf(stderr,
"Handler called after returning END_OF_STREAM!\n");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
static int
-callback(void *cls, struct MHD_Connection *connection, const char *url,
- const char *method, const char *version, const char *upload_data,
- size_t *upload_data_size, void **con_cls) {
+callback(void *cls,
+ struct MHD_Connection *connection,
+ const char *url,
+ const char *method,
+ const char *version,
+ const char *upload_data,
+ size_t *upload_data_size,
+ void **con_cls)
+{
struct callback_closure *cbc = calloc(1, sizeof(struct callback_closure));
struct MHD_Response *r;
- r = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024,
- &called_twice, cbc,
+ r = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024,
+ &called_twice, cbc,
&free);
- MHD_queue_response(connection, 200, r);
+ MHD_queue_response(connection, MHD_HTTP_OK, r);
MHD_destroy_response(r);
return MHD_YES;
}
@@ -82,7 +86,8 @@ discard_buffer (void *ptr, size_t size, size_t nmemb, void *ctx)
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
struct MHD_Daemon *d;
fd_set rs;
@@ -97,11 +102,11 @@ int main(int argc, char **argv)
struct timeval tv;
int extra;
- d = MHD_start_daemon(0,
+ d = MHD_start_daemon(0,
8000,
NULL,
NULL,
- callback,
+ &callback,
NULL,
MHD_OPTION_END);
c = curl_easy_init ();
@@ -145,7 +150,7 @@ int main(int argc, char **argv)
curl_easy_cleanup (c);
MHD_stop_daemon (d);
return 3;
- }
+ }
}
if (MHD_YES !=
MHD_get_fdset(d, &rs, &ws, &es, &max))