diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-29 12:19:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-29 12:19:21 +0000 |
commit | b41f753a6d0aa55ca5ef7f9e160813c007c03167 (patch) | |
tree | 2c6764206a4a9cc1a768a954c75f411a1733a0a7 | |
parent | 6a3f419f8bbc3e5e9d42c2108e10bfc4ff70886d (diff) | |
download | libmicrohttpd-b41f753a6d0aa55ca5ef7f9e160813c007c03167.tar.gz libmicrohttpd-b41f753a6d0aa55ca5ef7f9e160813c007c03167.zip |
fixes
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/daemon/daemon.c | 2 | ||||
-rw-r--r-- | src/daemon/memorypool.c | 2 | ||||
-rw-r--r-- | src/include/microhttpd.h | 3 | ||||
-rw-r--r-- | src/testcurl/daemontest_get.c | 37 |
5 files changed, 27 insertions, 21 deletions
@@ -1,3 +1,7 @@ | |||
1 | Tue Mar 29 14:11:19 CEST 2011 | ||
2 | Fixed call to mmap for memory pool, extended testcase to cover | ||
3 | POLL. -CG | ||
4 | |||
1 | Wed Mar 23 23:24:25 CET 2011 | 5 | Wed Mar 23 23:24:25 CET 2011 |
2 | Do not use POLLIN when we only care about POLLHUP (significantly | 6 | Do not use POLLIN when we only care about POLLHUP (significantly |
3 | improves performance when using MHD_USE_THREAD_PER_CONNECTION | 7 | improves performance when using MHD_USE_THREAD_PER_CONNECTION |
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 22d53a2d..4ac6b121 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -1365,7 +1365,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
1365 | unsigned int poll_server; | 1365 | unsigned int poll_server; |
1366 | 1366 | ||
1367 | memset (p, 0, sizeof (p)); | 1367 | memset (p, 0, sizeof (p)); |
1368 | if ( (daemon->max_connections == 0) && (daemon->socket_fd != -1) ) | 1368 | if ( (daemon->max_connections > 0) && (daemon->socket_fd != -1) ) |
1369 | { | 1369 | { |
1370 | poll_server = 1; | 1370 | poll_server = 1; |
1371 | p[0].fd = daemon->socket_fd; | 1371 | p[0].fd = daemon->socket_fd; |
diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c index 6df5cb5f..329a11c0 100644 --- a/src/daemon/memorypool.c +++ b/src/daemon/memorypool.c | |||
@@ -86,7 +86,7 @@ MHD_pool_create (size_t max) | |||
86 | return NULL; | 86 | return NULL; |
87 | #ifdef MAP_ANONYMOUS | 87 | #ifdef MAP_ANONYMOUS |
88 | pool->memory = MMAP (NULL, max, PROT_READ | PROT_WRITE, | 88 | pool->memory = MMAP (NULL, max, PROT_READ | PROT_WRITE, |
89 | MAP_ANONYMOUS, -1, 0); | 89 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
90 | #else | 90 | #else |
91 | pool->memory = MAP_FAILED; | 91 | pool->memory = MAP_FAILED; |
92 | #endif | 92 | #endif |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 9537c962..d4dd9042 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -362,8 +362,6 @@ enum MHD_FLAG | |||
362 | 362 | ||
363 | /** | 363 | /** |
364 | * Use poll instead of select. This allows sockets with fd >= FD_SETSIZE. | 364 | * Use poll instead of select. This allows sockets with fd >= FD_SETSIZE. |
365 | * This option only works in conjunction with MHD_USE_THREAD_PER_CONNECTION | ||
366 | * (at this point). | ||
367 | */ | 365 | */ |
368 | MHD_USE_POLL = 64 | 366 | MHD_USE_POLL = 64 |
369 | }; | 367 | }; |
@@ -1230,7 +1228,6 @@ struct MHD_Response *MHD_create_response_from_callback (uint64_t size, | |||
1230 | crfc); | 1228 | crfc); |
1231 | 1229 | ||
1232 | 1230 | ||
1233 | |||
1234 | /** | 1231 | /** |
1235 | * Create a response object. The response object can be extended with | 1232 | * Create a response object. The response object can be extended with |
1236 | * header information and then be used any number of times. | 1233 | * header information and then be used any number of times. |
diff --git a/src/testcurl/daemontest_get.c b/src/testcurl/daemontest_get.c index c8e47cd5..ffcbbf90 100644 --- a/src/testcurl/daemontest_get.c +++ b/src/testcurl/daemontest_get.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007, 2009 Christian Grothoff | 3 | (C) 2007, 2009, 2011 Christian Grothoff |
4 | 4 | ||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | 5 | libmicrohttpd is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -97,7 +97,7 @@ ahc_echo (void *cls, | |||
97 | 97 | ||
98 | 98 | ||
99 | static int | 99 | static int |
100 | testInternalGet () | 100 | testInternalGet (int poll_flag) |
101 | { | 101 | { |
102 | struct MHD_Daemon *d; | 102 | struct MHD_Daemon *d; |
103 | CURL *c; | 103 | CURL *c; |
@@ -108,7 +108,7 @@ testInternalGet () | |||
108 | cbc.buf = buf; | 108 | cbc.buf = buf; |
109 | cbc.size = 2048; | 109 | cbc.size = 2048; |
110 | cbc.pos = 0; | 110 | cbc.pos = 0; |
111 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 111 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
112 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 112 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
113 | if (d == NULL) | 113 | if (d == NULL) |
114 | return 1; | 114 | return 1; |
@@ -146,7 +146,7 @@ testInternalGet () | |||
146 | } | 146 | } |
147 | 147 | ||
148 | static int | 148 | static int |
149 | testMultithreadedGet () | 149 | testMultithreadedGet (int poll_flag) |
150 | { | 150 | { |
151 | struct MHD_Daemon *d; | 151 | struct MHD_Daemon *d; |
152 | CURL *c; | 152 | CURL *c; |
@@ -157,7 +157,7 @@ testMultithreadedGet () | |||
157 | cbc.buf = buf; | 157 | cbc.buf = buf; |
158 | cbc.size = 2048; | 158 | cbc.size = 2048; |
159 | cbc.pos = 0; | 159 | cbc.pos = 0; |
160 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 160 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, |
161 | 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 161 | 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
162 | if (d == NULL) | 162 | if (d == NULL) |
163 | return 16; | 163 | return 16; |
@@ -195,7 +195,7 @@ testMultithreadedGet () | |||
195 | } | 195 | } |
196 | 196 | ||
197 | static int | 197 | static int |
198 | testMultithreadedPoolGet () | 198 | testMultithreadedPoolGet (int poll_flag) |
199 | { | 199 | { |
200 | struct MHD_Daemon *d; | 200 | struct MHD_Daemon *d; |
201 | CURL *c; | 201 | CURL *c; |
@@ -206,7 +206,7 @@ testMultithreadedPoolGet () | |||
206 | cbc.buf = buf; | 206 | cbc.buf = buf; |
207 | cbc.size = 2048; | 207 | cbc.size = 2048; |
208 | cbc.pos = 0; | 208 | cbc.pos = 0; |
209 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 209 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
210 | 1081, NULL, NULL, &ahc_echo, "GET", | 210 | 1081, NULL, NULL, &ahc_echo, "GET", |
211 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 211 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); |
212 | if (d == NULL) | 212 | if (d == NULL) |
@@ -367,7 +367,7 @@ testExternalGet () | |||
367 | } | 367 | } |
368 | 368 | ||
369 | static int | 369 | static int |
370 | testUnknownPortGet () | 370 | testUnknownPortGet (int poll_flag) |
371 | { | 371 | { |
372 | struct MHD_Daemon *d; | 372 | struct MHD_Daemon *d; |
373 | const union MHD_DaemonInfo *di; | 373 | const union MHD_DaemonInfo *di; |
@@ -386,7 +386,7 @@ testUnknownPortGet () | |||
386 | cbc.buf = buf; | 386 | cbc.buf = buf; |
387 | cbc.size = 2048; | 387 | cbc.size = 2048; |
388 | cbc.pos = 0; | 388 | cbc.pos = 0; |
389 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 389 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
390 | 1, NULL, NULL, &ahc_echo, "GET", | 390 | 1, NULL, NULL, &ahc_echo, "GET", |
391 | MHD_OPTION_SOCK_ADDR, &addr, | 391 | MHD_OPTION_SOCK_ADDR, &addr, |
392 | MHD_OPTION_END); | 392 | MHD_OPTION_END); |
@@ -441,13 +441,13 @@ testUnknownPortGet () | |||
441 | 441 | ||
442 | 442 | ||
443 | static int | 443 | static int |
444 | testStopRace () | 444 | testStopRace (int poll_flag) |
445 | { | 445 | { |
446 | struct sockaddr_in sin; | 446 | struct sockaddr_in sin; |
447 | int fd; | 447 | int fd; |
448 | struct MHD_Daemon *d; | 448 | struct MHD_Daemon *d; |
449 | 449 | ||
450 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 450 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, |
451 | 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 451 | 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
452 | if (d == NULL) | 452 | if (d == NULL) |
453 | return 16; | 453 | return 16; |
@@ -493,12 +493,17 @@ main (int argc, char *const *argv) | |||
493 | oneone = NULL != strstr (argv[0], "11"); | 493 | oneone = NULL != strstr (argv[0], "11"); |
494 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 494 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) |
495 | return 2; | 495 | return 2; |
496 | errorCount += testInternalGet (); | 496 | errorCount += testInternalGet (0); |
497 | errorCount += testMultithreadedGet (); | 497 | errorCount += testMultithreadedGet (0); |
498 | errorCount += testMultithreadedPoolGet (); | 498 | errorCount += testMultithreadedPoolGet (0); |
499 | errorCount += testUnknownPortGet (0); | ||
500 | errorCount += testStopRace (0); | ||
499 | errorCount += testExternalGet (); | 501 | errorCount += testExternalGet (); |
500 | errorCount += testUnknownPortGet (); | 502 | errorCount += testInternalGet (MHD_USE_POLL); |
501 | errorCount += testStopRace (); | 503 | errorCount += testMultithreadedGet (MHD_USE_POLL); |
504 | errorCount += testMultithreadedPoolGet (MHD_USE_POLL); | ||
505 | errorCount += testUnknownPortGet (MHD_USE_POLL); | ||
506 | errorCount += testStopRace (MHD_USE_POLL); | ||
502 | if (errorCount != 0) | 507 | if (errorCount != 0) |
503 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 508 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
504 | curl_global_cleanup (); | 509 | curl_global_cleanup (); |