diff options
-rw-r--r-- | src/microhttpd/daemon.c | 114 | ||||
-rw-r--r-- | src/microhttpd/test_upgrade_large.c | 39 |
2 files changed, 93 insertions, 60 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 3fc992de..7ce0fbb3 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -721,8 +721,8 @@ int | |||
721 | MHD_get_fdset (struct MHD_Daemon *daemon, | 721 | MHD_get_fdset (struct MHD_Daemon *daemon, |
722 | fd_set *read_fd_set, | 722 | fd_set *read_fd_set, |
723 | fd_set *write_fd_set, | 723 | fd_set *write_fd_set, |
724 | fd_set *except_fd_set, | 724 | fd_set *except_fd_set, |
725 | MHD_socket *max_fd) | 725 | MHD_socket *max_fd) |
726 | { | 726 | { |
727 | return MHD_get_fdset2 (daemon, | 727 | return MHD_get_fdset2 (daemon, |
728 | read_fd_set, | 728 | read_fd_set, |
@@ -2344,11 +2344,11 @@ psk_gnutls_adapter (gnutls_session_t session, | |||
2344 | */ | 2344 | */ |
2345 | static int | 2345 | static int |
2346 | internal_add_connection (struct MHD_Daemon *daemon, | 2346 | internal_add_connection (struct MHD_Daemon *daemon, |
2347 | MHD_socket client_socket, | 2347 | MHD_socket client_socket, |
2348 | const struct sockaddr *addr, | 2348 | const struct sockaddr *addr, |
2349 | socklen_t addrlen, | 2349 | socklen_t addrlen, |
2350 | bool external_add, | 2350 | bool external_add, |
2351 | bool non_blck) | 2351 | bool non_blck) |
2352 | { | 2352 | { |
2353 | struct MHD_Connection *connection; | 2353 | struct MHD_Connection *connection; |
2354 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 2354 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
@@ -2362,8 +2362,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2362 | if ((external_add) && (NULL != daemon->worker_pool)) | 2362 | if ((external_add) && (NULL != daemon->worker_pool)) |
2363 | { | 2363 | { |
2364 | /* have a pool, try to find a pool with capacity; we use the | 2364 | /* have a pool, try to find a pool with capacity; we use the |
2365 | socket as the initial offset into the pool for load | 2365 | socket as the initial offset into the pool for load |
2366 | balancing */ | 2366 | balancing */ |
2367 | for (i = 0; i < daemon->worker_pool_size; ++i) | 2367 | for (i = 0; i < daemon->worker_pool_size; ++i) |
2368 | { | 2368 | { |
2369 | struct MHD_Daemon * const worker = | 2369 | struct MHD_Daemon * const worker = |
@@ -2448,7 +2448,7 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2448 | /* apply connection acceptance policy if present */ | 2448 | /* apply connection acceptance policy if present */ |
2449 | if ( (NULL != daemon->apc) && | 2449 | if ( (NULL != daemon->apc) && |
2450 | (MHD_NO == daemon->apc (daemon->apc_cls, | 2450 | (MHD_NO == daemon->apc (daemon->apc_cls, |
2451 | addr, | 2451 | addr, |
2452 | addrlen)) ) | 2452 | addrlen)) ) |
2453 | { | 2453 | { |
2454 | #if DEBUG_CLOSE | 2454 | #if DEBUG_CLOSE |
@@ -2472,8 +2472,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2472 | eno = errno; | 2472 | eno = errno; |
2473 | #ifdef HAVE_MESSAGES | 2473 | #ifdef HAVE_MESSAGES |
2474 | MHD_DLOG (daemon, | 2474 | MHD_DLOG (daemon, |
2475 | "Error allocating memory: %s\n", | 2475 | "Error allocating memory: %s\n", |
2476 | MHD_strerror_ (errno)); | 2476 | MHD_strerror_ (errno)); |
2477 | #endif | 2477 | #endif |
2478 | MHD_socket_close_chk_ (client_socket); | 2478 | MHD_socket_close_chk_ (client_socket); |
2479 | MHD_ip_limit_del (daemon, | 2479 | MHD_ip_limit_del (daemon, |
@@ -2487,8 +2487,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2487 | { | 2487 | { |
2488 | #ifdef HAVE_MESSAGES | 2488 | #ifdef HAVE_MESSAGES |
2489 | MHD_DLOG (daemon, | 2489 | MHD_DLOG (daemon, |
2490 | _("Error allocating memory: %s\n"), | 2490 | _("Error allocating memory: %s\n"), |
2491 | MHD_strerror_ (errno)); | 2491 | MHD_strerror_ (errno)); |
2492 | #endif | 2492 | #endif |
2493 | MHD_socket_close_chk_ (client_socket); | 2493 | MHD_socket_close_chk_ (client_socket); |
2494 | MHD_ip_limit_del (daemon, | 2494 | MHD_ip_limit_del (daemon, |
@@ -2507,8 +2507,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2507 | eno = errno; | 2507 | eno = errno; |
2508 | #ifdef HAVE_MESSAGES | 2508 | #ifdef HAVE_MESSAGES |
2509 | MHD_DLOG (daemon, | 2509 | MHD_DLOG (daemon, |
2510 | _("Error allocating memory: %s\n"), | 2510 | _("Error allocating memory: %s\n"), |
2511 | MHD_strerror_ (errno)); | 2511 | MHD_strerror_ (errno)); |
2512 | #endif | 2512 | #endif |
2513 | MHD_socket_close_chk_ (client_socket); | 2513 | MHD_socket_close_chk_ (client_socket); |
2514 | MHD_ip_limit_del (daemon, | 2514 | MHD_ip_limit_del (daemon, |
@@ -2566,8 +2566,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2566 | /* set needed credentials for certificate authentication. */ | 2566 | /* set needed credentials for certificate authentication. */ |
2567 | case GNUTLS_CRD_CERTIFICATE: | 2567 | case GNUTLS_CRD_CERTIFICATE: |
2568 | gnutls_credentials_set (connection->tls_session, | 2568 | gnutls_credentials_set (connection->tls_session, |
2569 | GNUTLS_CRD_CERTIFICATE, | 2569 | GNUTLS_CRD_CERTIFICATE, |
2570 | daemon->x509_cred); | 2570 | daemon->x509_cred); |
2571 | break; | 2571 | break; |
2572 | case GNUTLS_CRD_PSK: | 2572 | case GNUTLS_CRD_PSK: |
2573 | gnutls_credentials_set (connection->tls_session, | 2573 | gnutls_credentials_set (connection->tls_session, |
@@ -2596,18 +2596,18 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2596 | } | 2596 | } |
2597 | #if (GNUTLS_VERSION_NUMBER+0 >= 0x030109) && !defined(_WIN64) | 2597 | #if (GNUTLS_VERSION_NUMBER+0 >= 0x030109) && !defined(_WIN64) |
2598 | gnutls_transport_set_int (connection->tls_session, | 2598 | gnutls_transport_set_int (connection->tls_session, |
2599 | (int)(client_socket)); | 2599 | (int)(client_socket)); |
2600 | #else /* GnuTLS before 3.1.9 or Win x64 */ | 2600 | #else /* GnuTLS before 3.1.9 or Win x64 */ |
2601 | gnutls_transport_set_ptr (connection->tls_session, | 2601 | gnutls_transport_set_ptr (connection->tls_session, |
2602 | (gnutls_transport_ptr_t)(intptr_t)(client_socket)); | 2602 | (gnutls_transport_ptr_t)(intptr_t)(client_socket)); |
2603 | #endif /* GnuTLS before 3.1.9 */ | 2603 | #endif /* GnuTLS before 3.1.9 */ |
2604 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC | 2604 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC |
2605 | gnutls_transport_set_push_function (connection->tls_session, | 2605 | gnutls_transport_set_push_function (connection->tls_session, |
2606 | MHD_tls_push_func_); | 2606 | MHD_tls_push_func_); |
2607 | #endif /* MHD_TLSLIB_NEED_PUSH_FUNC */ | 2607 | #endif /* MHD_TLSLIB_NEED_PUSH_FUNC */ |
2608 | if (daemon->https_mem_trust) | 2608 | if (daemon->https_mem_trust) |
2609 | gnutls_certificate_server_set_request (connection->tls_session, | 2609 | gnutls_certificate_server_set_request (connection->tls_session, |
2610 | GNUTLS_CERT_REQUEST); | 2610 | GNUTLS_CERT_REQUEST); |
2611 | #else /* ! HTTPS_SUPPORT */ | 2611 | #else /* ! HTTPS_SUPPORT */ |
2612 | eno = EINVAL; | 2612 | eno = EINVAL; |
2613 | goto cleanup; | 2613 | goto cleanup; |
@@ -2641,8 +2641,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2641 | connection); | 2641 | connection); |
2642 | } | 2642 | } |
2643 | DLL_insert (daemon->connections_head, | 2643 | DLL_insert (daemon->connections_head, |
2644 | daemon->connections_tail, | 2644 | daemon->connections_tail, |
2645 | connection); | 2645 | connection); |
2646 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 2646 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
2647 | MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); | 2647 | MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); |
2648 | #endif | 2648 | #endif |
@@ -2661,13 +2661,13 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2661 | &thread_main_handle_connection, | 2661 | &thread_main_handle_connection, |
2662 | connection)) | 2662 | connection)) |
2663 | { | 2663 | { |
2664 | eno = errno; | 2664 | eno = errno; |
2665 | #ifdef HAVE_MESSAGES | 2665 | #ifdef HAVE_MESSAGES |
2666 | MHD_DLOG (daemon, | 2666 | MHD_DLOG (daemon, |
2667 | "Failed to create a thread: %s\n", | 2667 | "Failed to create a thread: %s\n", |
2668 | MHD_strerror_ (eno)); | 2668 | MHD_strerror_ (eno)); |
2669 | #endif | 2669 | #endif |
2670 | goto cleanup; | 2670 | goto cleanup; |
2671 | } | 2671 | } |
2672 | } | 2672 | } |
2673 | else | 2673 | else |
@@ -2683,9 +2683,9 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2683 | event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; | 2683 | event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; |
2684 | event.data.ptr = connection; | 2684 | event.data.ptr = connection; |
2685 | if (0 != epoll_ctl (daemon->epoll_fd, | 2685 | if (0 != epoll_ctl (daemon->epoll_fd, |
2686 | EPOLL_CTL_ADD, | 2686 | EPOLL_CTL_ADD, |
2687 | client_socket, | 2687 | client_socket, |
2688 | &event)) | 2688 | &event)) |
2689 | { | 2689 | { |
2690 | eno = errno; | 2690 | eno = errno; |
2691 | #ifdef HAVE_MESSAGES | 2691 | #ifdef HAVE_MESSAGES |
@@ -2702,8 +2702,8 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
2702 | connection->epoll_state |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY | 2702 | connection->epoll_state |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY |
2703 | | MHD_EPOLL_STATE_IN_EREADY_EDLL; | 2703 | | MHD_EPOLL_STATE_IN_EREADY_EDLL; |
2704 | EDLL_insert (daemon->eready_head, | 2704 | EDLL_insert (daemon->eready_head, |
2705 | daemon->eready_tail, | 2705 | daemon->eready_tail, |
2706 | connection); | 2706 | connection); |
2707 | } | 2707 | } |
2708 | } | 2708 | } |
2709 | else /* This 'else' is combined with next 'if'. */ | 2709 | else /* This 'else' is combined with next 'if'. */ |
@@ -4263,7 +4263,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) | |||
4263 | * will be moved immediately to cleanup list. Otherwise | 4263 | * will be moved immediately to cleanup list. Otherwise |
4264 | * connection will stay in suspended list until 'pos' will | 4264 | * connection will stay in suspended list until 'pos' will |
4265 | * be marked with 'was_closed' by application. */ | 4265 | * be marked with 'was_closed' by application. */ |
4266 | MHD_resume_connection(pos->connection); | 4266 | MHD_resume_connection (pos->connection); |
4267 | } | 4267 | } |
4268 | } | 4268 | } |
4269 | 4269 | ||
@@ -4346,8 +4346,8 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
4346 | } | 4346 | } |
4347 | 4347 | ||
4348 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) | 4348 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) |
4349 | if ( (! daemon->upgrade_fd_in_epoll) && | 4349 | if ( ( (! daemon->upgrade_fd_in_epoll) && |
4350 | (-1 != daemon->epoll_upgrade_fd) ) | 4350 | (-1 != daemon->epoll_upgrade_fd) ) ) |
4351 | { | 4351 | { |
4352 | event.events = EPOLLIN | EPOLLOUT; | 4352 | event.events = EPOLLIN | EPOLLOUT; |
4353 | event.data.ptr = (void *) upgrade_marker; | 4353 | event.data.ptr = (void *) upgrade_marker; |
@@ -4388,7 +4388,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
4388 | if (MHD_YES == may_block) | 4388 | if (MHD_YES == may_block) |
4389 | { | 4389 | { |
4390 | if (MHD_YES == MHD_get_timeout (daemon, | 4390 | if (MHD_YES == MHD_get_timeout (daemon, |
4391 | &timeout_ll)) | 4391 | &timeout_ll)) |
4392 | { | 4392 | { |
4393 | if (timeout_ll >= (MHD_UNSIGNED_LONG_LONG) INT_MAX) | 4393 | if (timeout_ll >= (MHD_UNSIGNED_LONG_LONG) INT_MAX) |
4394 | timeout_ms = INT_MAX; | 4394 | timeout_ms = INT_MAX; |
@@ -4824,26 +4824,26 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
4824 | if (NULL != daemon->worker_pool) | 4824 | if (NULL != daemon->worker_pool) |
4825 | for (i = 0; i < daemon->worker_pool_size; i++) | 4825 | for (i = 0; i < daemon->worker_pool_size; i++) |
4826 | { | 4826 | { |
4827 | daemon->worker_pool[i].was_quiesced = true; | 4827 | daemon->worker_pool[i].was_quiesced = true; |
4828 | #ifdef EPOLL_SUPPORT | 4828 | #ifdef EPOLL_SUPPORT |
4829 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && | 4829 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && |
4830 | (-1 != daemon->worker_pool[i].epoll_fd) && | 4830 | (-1 != daemon->worker_pool[i].epoll_fd) && |
4831 | (daemon->worker_pool[i].listen_socket_in_epoll) ) | 4831 | (daemon->worker_pool[i].listen_socket_in_epoll) ) |
4832 | { | ||
4833 | if (0 != epoll_ctl (daemon->worker_pool[i].epoll_fd, | ||
4834 | EPOLL_CTL_DEL, | ||
4835 | ret, | ||
4836 | NULL)) | ||
4837 | MHD_PANIC (_("Failed to remove listen FD from epoll set\n")); | ||
4838 | daemon->worker_pool[i].listen_socket_in_epoll = false; | ||
4839 | } | ||
4840 | else | ||
4841 | #endif | ||
4842 | if (MHD_ITC_IS_VALID_(daemon->worker_pool[i].itc)) | ||
4843 | { | 4832 | { |
4844 | if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "q")) | 4833 | if (0 != epoll_ctl (daemon->worker_pool[i].epoll_fd, |
4845 | MHD_PANIC (_("Failed to signal quiesce via inter-thread communication channel")); | 4834 | EPOLL_CTL_DEL, |
4835 | ret, | ||
4836 | NULL)) | ||
4837 | MHD_PANIC (_("Failed to remove listen FD from epoll set\n")); | ||
4838 | daemon->worker_pool[i].listen_socket_in_epoll = false; | ||
4846 | } | 4839 | } |
4840 | else | ||
4841 | #endif | ||
4842 | if (MHD_ITC_IS_VALID_(daemon->worker_pool[i].itc)) | ||
4843 | { | ||
4844 | if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "q")) | ||
4845 | MHD_PANIC (_("Failed to signal quiesce via inter-thread communication channel")); | ||
4846 | } | ||
4847 | } | 4847 | } |
4848 | #endif | 4848 | #endif |
4849 | daemon->was_quiesced = true; | 4849 | daemon->was_quiesced = true; |
@@ -4858,7 +4858,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
4858 | NULL)) && | 4858 | NULL)) && |
4859 | (ENOENT != errno) ) /* ENOENT can happen due to race with | 4859 | (ENOENT != errno) ) /* ENOENT can happen due to race with |
4860 | #MHD_epoll() */ | 4860 | #MHD_epoll() */ |
4861 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); | 4861 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); |
4862 | daemon->listen_socket_in_epoll = false; | 4862 | daemon->listen_socket_in_epoll = false; |
4863 | } | 4863 | } |
4864 | #endif | 4864 | #endif |
@@ -4892,8 +4892,8 @@ typedef void | |||
4892 | */ | 4892 | */ |
4893 | static int | 4893 | static int |
4894 | parse_options_va (struct MHD_Daemon *daemon, | 4894 | parse_options_va (struct MHD_Daemon *daemon, |
4895 | const struct sockaddr **servaddr, | 4895 | const struct sockaddr **servaddr, |
4896 | va_list ap); | 4896 | va_list ap); |
4897 | 4897 | ||
4898 | 4898 | ||
4899 | /** | 4899 | /** |
@@ -4931,8 +4931,8 @@ parse_options (struct MHD_Daemon *daemon, | |||
4931 | */ | 4931 | */ |
4932 | static int | 4932 | static int |
4933 | parse_options_va (struct MHD_Daemon *daemon, | 4933 | parse_options_va (struct MHD_Daemon *daemon, |
4934 | const struct sockaddr **servaddr, | 4934 | const struct sockaddr **servaddr, |
4935 | va_list ap) | 4935 | va_list ap) |
4936 | { | 4936 | { |
4937 | enum MHD_OPTION opt; | 4937 | enum MHD_OPTION opt; |
4938 | struct MHD_OptionItem *oa; | 4938 | struct MHD_OptionItem *oa; |
diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c index fdf2edf7..6f2a1b94 100644 --- a/src/microhttpd/test_upgrade_large.c +++ b/src/microhttpd/test_upgrade_large.c | |||
@@ -67,6 +67,8 @@ | |||
67 | 67 | ||
68 | static int verbose = 0; | 68 | static int verbose = 0; |
69 | 69 | ||
70 | static int kicker[2] = {-1, -1} ; | ||
71 | |||
70 | enum tls_tool | 72 | enum tls_tool |
71 | { | 73 | { |
72 | TLS_CLI_NO_TOOL = 0, | 74 | TLS_CLI_NO_TOOL = 0, |
@@ -570,7 +572,17 @@ make_blocking (MHD_socket fd) | |||
570 | 572 | ||
571 | ioctlsocket (fd, FIONBIO, &flags); | 573 | ioctlsocket (fd, FIONBIO, &flags); |
572 | #endif /* MHD_WINSOCK_SOCKETS */ | 574 | #endif /* MHD_WINSOCK_SOCKETS */ |
575 | } | ||
576 | |||
573 | 577 | ||
578 | static void | ||
579 | kick_select () | ||
580 | { | ||
581 | if (-1 != kicker[1]) | ||
582 | { | ||
583 | write (kicker[1], "K", 1); | ||
584 | fprintf (stderr, "KICKING\n"); | ||
585 | } | ||
574 | } | 586 | } |
575 | 587 | ||
576 | 588 | ||
@@ -588,6 +600,7 @@ send_all (struct wr_socket *sock, | |||
588 | ret = wr_send (sock, | 600 | ret = wr_send (sock, |
589 | &text[off], | 601 | &text[off], |
590 | len - off); | 602 | len - off); |
603 | kick_select (); | ||
591 | if (0 > ret) | 604 | if (0 > ret) |
592 | { | 605 | { |
593 | if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) | 606 | if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) |
@@ -621,6 +634,7 @@ recv_hdr (struct wr_socket *sock) | |||
621 | ret = wr_recv (sock, | 634 | ret = wr_recv (sock, |
622 | &c, | 635 | &c, |
623 | 1); | 636 | 1); |
637 | kick_select (); | ||
624 | if (0 > ret) | 638 | if (0 > ret) |
625 | { | 639 | { |
626 | if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) | 640 | if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) |
@@ -889,7 +903,10 @@ run_mhd_select_loop (struct MHD_Daemon *daemon) | |||
889 | MHD_socket max_fd; | 903 | MHD_socket max_fd; |
890 | MHD_UNSIGNED_LONG_LONG to; | 904 | MHD_UNSIGNED_LONG_LONG to; |
891 | struct timeval tv; | 905 | struct timeval tv; |
906 | char drain[128]; | ||
892 | 907 | ||
908 | if (0 != pipe (kicker)) | ||
909 | abort (); | ||
893 | while (! done) | 910 | while (! done) |
894 | { | 911 | { |
895 | FD_ZERO (&rs); | 912 | FD_ZERO (&rs); |
@@ -898,6 +915,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon) | |||
898 | max_fd = -1; | 915 | max_fd = -1; |
899 | to = 1000; | 916 | to = 1000; |
900 | 917 | ||
918 | FD_SET (kicker[0], &rs); | ||
901 | if (MHD_YES != | 919 | if (MHD_YES != |
902 | MHD_get_fdset (daemon, | 920 | MHD_get_fdset (daemon, |
903 | &rs, | 921 | &rs, |
@@ -917,11 +935,17 @@ run_mhd_select_loop (struct MHD_Daemon *daemon) | |||
917 | &es, | 935 | &es, |
918 | &tv)) | 936 | &tv)) |
919 | abort (); | 937 | abort (); |
938 | if (FD_ISSET (kicker[0], &rs)) | ||
939 | (void) read (kicker[0], drain, sizeof (drain)); | ||
920 | MHD_run_from_select (daemon, | 940 | MHD_run_from_select (daemon, |
921 | &rs, | 941 | &rs, |
922 | &ws, | 942 | &ws, |
923 | &es); | 943 | &es); |
924 | } | 944 | } |
945 | close (kicker[0]); | ||
946 | close (kicker[1]); | ||
947 | kicker[0] = -1; | ||
948 | kicker[1] = -1; | ||
925 | } | 949 | } |
926 | 950 | ||
927 | #ifdef HAVE_POLL | 951 | #ifdef HAVE_POLL |
@@ -955,15 +979,18 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon) | |||
955 | MHD_UNSIGNED_LONG_LONG to; | 979 | MHD_UNSIGNED_LONG_LONG to; |
956 | struct timeval tv; | 980 | struct timeval tv; |
957 | int ret; | 981 | int ret; |
982 | char drain[128]; | ||
958 | 983 | ||
959 | di = MHD_get_daemon_info (daemon, | 984 | di = MHD_get_daemon_info (daemon, |
960 | MHD_DAEMON_INFO_EPOLL_FD); | 985 | MHD_DAEMON_INFO_EPOLL_FD); |
961 | ep = di->listen_fd; | 986 | ep = di->listen_fd; |
987 | if (0 != pipe (kicker)) | ||
988 | abort (); | ||
962 | while (! done) | 989 | while (! done) |
963 | { | 990 | { |
964 | FD_ZERO (&rs); | 991 | FD_ZERO (&rs); |
965 | to = 1000; | 992 | to = 1000; |
966 | 993 | FD_SET (kicker[0], &rs); | |
967 | FD_SET (ep, &rs); | 994 | FD_SET (ep, &rs); |
968 | (void) MHD_get_timeout (daemon, | 995 | (void) MHD_get_timeout (daemon, |
969 | &to); | 996 | &to); |
@@ -980,8 +1007,14 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon) | |||
980 | (EAGAIN != errno) && | 1007 | (EAGAIN != errno) && |
981 | (EINTR != errno) ) | 1008 | (EINTR != errno) ) |
982 | abort (); | 1009 | abort (); |
1010 | if (FD_ISSET (kicker[0], &rs)) | ||
1011 | (void) read (kicker[0], drain, sizeof (drain)); | ||
983 | MHD_run (daemon); | 1012 | MHD_run (daemon); |
984 | } | 1013 | } |
1014 | close (kicker[0]); | ||
1015 | close (kicker[1]); | ||
1016 | kicker[0] = -1; | ||
1017 | kicker[1] = -1; | ||
985 | } | 1018 | } |
986 | #endif /* EPOLL_SUPPORT */ | 1019 | #endif /* EPOLL_SUPPORT */ |
987 | 1020 | ||
@@ -1080,8 +1113,8 @@ test_upgrade (int flags, | |||
1080 | sa.sin_port = htons (dinfo->port); | 1113 | sa.sin_port = htons (dinfo->port); |
1081 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 1114 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
1082 | if (0 != wr_connect (sock, | 1115 | if (0 != wr_connect (sock, |
1083 | (struct sockaddr *) &sa, | 1116 | (struct sockaddr *) &sa, |
1084 | sizeof (sa))) | 1117 | sizeof (sa))) |
1085 | abort (); | 1118 | abort (); |
1086 | } | 1119 | } |
1087 | else | 1120 | else |