libmicrohttpd

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

commit b41f753a6d0aa55ca5ef7f9e160813c007c03167
parent 6a3f419f8bbc3e5e9d42c2108e10bfc4ff70886d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 29 Mar 2011 12:19:21 +0000

fixes

Diffstat:
MChangeLog | 4++++
Msrc/daemon/daemon.c | 2+-
Msrc/daemon/memorypool.c | 2+-
Msrc/include/microhttpd.h | 3---
Msrc/testcurl/daemontest_get.c | 37+++++++++++++++++++++----------------
5 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Tue Mar 29 14:11:19 CEST 2011 + Fixed call to mmap for memory pool, extended testcase to cover + POLL. -CG + Wed Mar 23 23:24:25 CET 2011 Do not use POLLIN when we only care about POLLHUP (significantly improves performance when using MHD_USE_THREAD_PER_CONNECTION diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -1365,7 +1365,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, unsigned int poll_server; memset (p, 0, sizeof (p)); - if ( (daemon->max_connections == 0) && (daemon->socket_fd != -1) ) + if ( (daemon->max_connections > 0) && (daemon->socket_fd != -1) ) { poll_server = 1; p[0].fd = daemon->socket_fd; diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c @@ -86,7 +86,7 @@ MHD_pool_create (size_t max) return NULL; #ifdef MAP_ANONYMOUS pool->memory = MMAP (NULL, max, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS, -1, 0); + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #else pool->memory = MAP_FAILED; #endif diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -362,8 +362,6 @@ enum MHD_FLAG /** * Use poll instead of select. This allows sockets with fd >= FD_SETSIZE. - * This option only works in conjunction with MHD_USE_THREAD_PER_CONNECTION - * (at this point). */ MHD_USE_POLL = 64 }; @@ -1230,7 +1228,6 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size, crfc); - /** * Create a response object. The response object can be extended with * header information and then be used any number of times. diff --git a/src/testcurl/daemontest_get.c b/src/testcurl/daemontest_get.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007, 2009 Christian Grothoff + (C) 2007, 2009, 2011 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -97,7 +97,7 @@ ahc_echo (void *cls, static int -testInternalGet () +testInternalGet (int poll_flag) { struct MHD_Daemon *d; CURL *c; @@ -108,7 +108,7 @@ testInternalGet () cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; - d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); if (d == NULL) return 1; @@ -146,7 +146,7 @@ testInternalGet () } static int -testMultithreadedGet () +testMultithreadedGet (int poll_flag) { struct MHD_Daemon *d; CURL *c; @@ -157,7 +157,7 @@ testMultithreadedGet () cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; - d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); if (d == NULL) return 16; @@ -195,7 +195,7 @@ testMultithreadedGet () } static int -testMultithreadedPoolGet () +testMultithreadedPoolGet (int poll_flag) { struct MHD_Daemon *d; CURL *c; @@ -206,7 +206,7 @@ testMultithreadedPoolGet () cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; - d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); if (d == NULL) @@ -367,7 +367,7 @@ testExternalGet () } static int -testUnknownPortGet () +testUnknownPortGet (int poll_flag) { struct MHD_Daemon *d; const union MHD_DaemonInfo *di; @@ -386,7 +386,7 @@ testUnknownPortGet () cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; - d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 1, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_SOCK_ADDR, &addr, MHD_OPTION_END); @@ -441,13 +441,13 @@ testUnknownPortGet () static int -testStopRace () +testStopRace (int poll_flag) { struct sockaddr_in sin; int fd; struct MHD_Daemon *d; - d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, + d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); if (d == NULL) return 16; @@ -493,12 +493,17 @@ main (int argc, char *const *argv) oneone = NULL != strstr (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; - errorCount += testInternalGet (); - errorCount += testMultithreadedGet (); - errorCount += testMultithreadedPoolGet (); + errorCount += testInternalGet (0); + errorCount += testMultithreadedGet (0); + errorCount += testMultithreadedPoolGet (0); + errorCount += testUnknownPortGet (0); + errorCount += testStopRace (0); errorCount += testExternalGet (); - errorCount += testUnknownPortGet (); - errorCount += testStopRace (); + errorCount += testInternalGet (MHD_USE_POLL); + errorCount += testMultithreadedGet (MHD_USE_POLL); + errorCount += testMultithreadedPoolGet (MHD_USE_POLL); + errorCount += testUnknownPortGet (MHD_USE_POLL); + errorCount += testStopRace (MHD_USE_POLL); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup ();