diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-03-26 12:03:18 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-03-26 13:45:04 +0300 |
commit | ab04f53b950cdaaee58607e9217159112e033372 (patch) | |
tree | 537cc1136ca14c5c154802d1446fb013c568f2e2 | |
parent | ad75fbc085aac7e1963e642582ad452a24b4f102 (diff) | |
download | libmicrohttpd-ab04f53b950cdaaee58607e9217159112e033372.tar.gz libmicrohttpd-ab04f53b950cdaaee58607e9217159112e033372.zip |
Simplified checks for allowed suspend, fixed false positive for daemons with MHD_USE_ITC
-rw-r--r-- | src/microhttpd/daemon.c | 19 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 6 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index aa915af6..161ce5e0 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -2728,7 +2728,7 @@ MHD_suspend_connection (struct MHD_Connection *connection) | |||
2728 | { | 2728 | { |
2729 | struct MHD_Daemon *daemon = connection->daemon; | 2729 | struct MHD_Daemon *daemon = connection->daemon; |
2730 | 2730 | ||
2731 | if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) | 2731 | if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) |
2732 | MHD_PANIC (_("Cannot suspend connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); | 2732 | MHD_PANIC (_("Cannot suspend connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); |
2733 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); | 2733 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); |
2734 | if (connection->resuming) | 2734 | if (connection->resuming) |
@@ -2797,7 +2797,7 @@ MHD_resume_connection (struct MHD_Connection *connection) | |||
2797 | struct MHD_Daemon *daemon; | 2797 | struct MHD_Daemon *daemon; |
2798 | 2798 | ||
2799 | daemon = connection->daemon; | 2799 | daemon = connection->daemon; |
2800 | if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) | 2800 | if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) |
2801 | MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); | 2801 | MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); |
2802 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); | 2802 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); |
2803 | connection->resuming = true; | 2803 | connection->resuming = true; |
@@ -3332,8 +3332,7 @@ internal_run_from_select (struct MHD_Daemon *daemon, | |||
3332 | struct MHD_UpgradeResponseHandle *urh; | 3332 | struct MHD_UpgradeResponseHandle *urh; |
3333 | struct MHD_UpgradeResponseHandle *urhn; | 3333 | struct MHD_UpgradeResponseHandle *urhn; |
3334 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 3334 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
3335 | unsigned int mask = MHD_ALLOW_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNAL_THREAD | | 3335 | unsigned int mask = MHD_TEST_ALLOW_SUSPEND_RESUME | MHD_USE_INTERNAL_POLLING_THREAD; |
3336 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_POLL_INTERNAL_THREAD; | ||
3337 | 3336 | ||
3338 | /* Reset. New value will be set when connections are processed. */ | 3337 | /* Reset. New value will be set when connections are processed. */ |
3339 | /* Note: no-op for thread-per-connection as it is always false in that mode. */ | 3338 | /* Note: no-op for thread-per-connection as it is always false in that mode. */ |
@@ -3348,7 +3347,7 @@ internal_run_from_select (struct MHD_Daemon *daemon, | |||
3348 | MHD_itc_clear_ (daemon->itc); | 3347 | MHD_itc_clear_ (daemon->itc); |
3349 | 3348 | ||
3350 | /* Resuming external connections when using an extern mainloop */ | 3349 | /* Resuming external connections when using an extern mainloop */ |
3351 | if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask)) | 3350 | if (MHD_TEST_ALLOW_SUSPEND_RESUME == (daemon->options & mask)) |
3352 | resume_suspended_connections (daemon); | 3351 | resume_suspended_connections (daemon); |
3353 | 3352 | ||
3354 | #ifdef EPOLL_SUPPORT | 3353 | #ifdef EPOLL_SUPPORT |
@@ -3517,7 +3516,7 @@ MHD_select (struct MHD_Daemon *daemon, | |||
3517 | err_state = MHD_NO; | 3516 | err_state = MHD_NO; |
3518 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 3517 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
3519 | { | 3518 | { |
3520 | if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) && | 3519 | if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && |
3521 | (MHD_YES == resume_suspended_connections (daemon)) ) | 3520 | (MHD_YES == resume_suspended_connections (daemon)) ) |
3522 | may_block = MHD_NO; | 3521 | may_block = MHD_NO; |
3523 | 3522 | ||
@@ -3669,7 +3668,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
3669 | struct MHD_UpgradeResponseHandle *urhn; | 3668 | struct MHD_UpgradeResponseHandle *urhn; |
3670 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 3669 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
3671 | 3670 | ||
3672 | if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) && | 3671 | if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && |
3673 | (MHD_YES == resume_suspended_connections (daemon)) ) | 3672 | (MHD_YES == resume_suspended_connections (daemon)) ) |
3674 | may_block = MHD_NO; | 3673 | may_block = MHD_NO; |
3675 | 3674 | ||
@@ -4375,7 +4374,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
4375 | 4374 | ||
4376 | /* we handle resumes here because we may have ready connections | 4375 | /* we handle resumes here because we may have ready connections |
4377 | that will not be placed into the epoll list immediately. */ | 4376 | that will not be placed into the epoll list immediately. */ |
4378 | if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME)) | 4377 | if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) |
4379 | (void) resume_suspended_connections (daemon); | 4378 | (void) resume_suspended_connections (daemon); |
4380 | 4379 | ||
4381 | /* process events for connections */ | 4380 | /* process events for connections */ |
@@ -6126,7 +6125,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
6126 | running into the check for there not being any suspended | 6125 | running into the check for there not being any suspended |
6127 | connections left in case of a tight race with a recently | 6126 | connections left in case of a tight race with a recently |
6128 | resumed connection. */ | 6127 | resumed connection. */ |
6129 | if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options)) | 6128 | if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) |
6130 | { | 6129 | { |
6131 | daemon->resuming = true; /* Force check for pending resume. */ | 6130 | daemon->resuming = true; /* Force check for pending resume. */ |
6132 | resume_suspended_connections (daemon); | 6131 | resume_suspended_connections (daemon); |
@@ -6249,7 +6248,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
6249 | if (NULL == daemon) | 6248 | if (NULL == daemon) |
6250 | return; | 6249 | return; |
6251 | 6250 | ||
6252 | if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options)) | 6251 | if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) |
6253 | resume_suspended_connections (daemon); | 6252 | resume_suspended_connections (daemon); |
6254 | 6253 | ||
6255 | daemon->shutdown = true; | 6254 | daemon->shutdown = true; |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 1356e92e..52bd8520 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -192,6 +192,12 @@ enum MHD_ConnectionEventLoopInfo | |||
192 | 192 | ||
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Additional test value for enum MHD_FLAG to check only for MHD_ALLOW_SUSPEND_RESUME and | ||
196 | * NOT for MHD_USE_ITC. | ||
197 | */ | ||
198 | #define MHD_TEST_ALLOW_SUSPEND_RESUME 8192 | ||
199 | |||
200 | /** | ||
195 | * Maximum length of a nonce in digest authentication. 32(MD5 Hex) + | 201 | * Maximum length of a nonce in digest authentication. 32(MD5 Hex) + |
196 | * 8(Timestamp Hex) + 1(NULL); hence 41 should suffice, but Opera | 202 | * 8(Timestamp Hex) + 1(NULL); hence 41 should suffice, but Opera |
197 | * (already) takes more (see Mantis #1633), so we've increased the | 203 | * (already) takes more (see Mantis #1633), so we've increased the |