diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-04 14:26:46 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-04 14:26:46 +0300 |
commit | 5c28c2ffcbd886b6dda0dae480cd459890f76cb1 (patch) | |
tree | 76f535dddc2f5c71b1b7d1e1c2633ce9b5becc34 | |
parent | 44a92f9f53feccebb45d5cfb3a3d73c1eecd80c8 (diff) | |
download | libmicrohttpd-5c28c2ffcbd886b6dda0dae480cd459890f76cb1.tar.gz libmicrohttpd-5c28c2ffcbd886b6dda0dae480cd459890f76cb1.zip |
internal_add_connection(): improved thread safety in epoll mode with 'external' add
-rw-r--r-- | src/microhttpd/daemon.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 01306045..8e11b4c0 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -2625,21 +2625,11 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2625 | goto cleanup; | 2625 | goto cleanup; |
2626 | } | 2626 | } |
2627 | } | 2627 | } |
2628 | else | ||
2629 | if ( (external_add) && | ||
2630 | (MHD_ITC_IS_VALID_(daemon->itc)) && | ||
2631 | (! MHD_itc_activate_ (daemon->itc, "n")) ) | ||
2632 | { | ||
2633 | #ifdef HAVE_MESSAGES | ||
2634 | MHD_DLOG (daemon, | ||
2635 | _("Failed to signal new connection via inter-thread communication channel.")); | ||
2636 | #endif | ||
2637 | } | ||
2638 | #ifdef EPOLL_SUPPORT | 2628 | #ifdef EPOLL_SUPPORT |
2639 | if (0 != (daemon->options & MHD_USE_EPOLL)) | 2629 | if (0 != (daemon->options & MHD_USE_EPOLL)) |
2640 | { | 2630 | { |
2641 | if (0 == (daemon->options & MHD_USE_TURBO)) | 2631 | if ((0 == (daemon->options & MHD_USE_TURBO)) || (external_add)) |
2642 | { | 2632 | { /* Do not manipulate EReady DL-list in 'external_add' mode. */ |
2643 | struct epoll_event event; | 2633 | struct epoll_event event; |
2644 | 2634 | ||
2645 | event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; | 2635 | event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; |
@@ -2668,7 +2658,18 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2668 | connection); | 2658 | connection); |
2669 | } | 2659 | } |
2670 | } | 2660 | } |
2661 | else /* This 'else' is combined with next 'if'. */ | ||
2671 | #endif | 2662 | #endif |
2663 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
2664 | (external_add) && | ||
2665 | (MHD_ITC_IS_VALID_(daemon->itc)) && | ||
2666 | (! MHD_itc_activate_ (daemon->itc, "n")) ) | ||
2667 | { | ||
2668 | #ifdef HAVE_MESSAGES | ||
2669 | MHD_DLOG (daemon, | ||
2670 | _("Failed to signal new connection via inter-thread communication channel.")); | ||
2671 | #endif | ||
2672 | } | ||
2672 | daemon->connections++; | 2673 | daemon->connections++; |
2673 | return MHD_YES; | 2674 | return MHD_YES; |
2674 | cleanup: | 2675 | cleanup: |