diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index ac1a01e5..e634d4a8 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2010,7 +2010,7 @@ process_request_body (struct MHD_Connection *connection) | |||
2010 | handling the rest of the request */ | 2010 | handling the rest of the request */ |
2011 | if ( ( (0 != (connection->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || | 2011 | if ( ( (0 != (connection->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || |
2012 | (0 != (connection->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ) && | 2012 | (0 != (connection->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ) && |
2013 | (MHD_NO == connection->suspended) ) | 2013 | (! connection->suspended) ) |
2014 | MHD_DLOG (connection->daemon, | 2014 | MHD_DLOG (connection->daemon, |
2015 | _("WARNING: incomplete POST processing and connection not suspended will result in hung connection.\n")); | 2015 | _("WARNING: incomplete POST processing and connection not suspended will result in hung connection.\n")); |
2016 | #endif | 2016 | #endif |
@@ -2666,17 +2666,14 @@ cleanup_connection (struct MHD_Connection *connection) | |||
2666 | if (connection->in_cleanup) | 2666 | if (connection->in_cleanup) |
2667 | return; /* Prevent double cleanup. */ | 2667 | return; /* Prevent double cleanup. */ |
2668 | 2668 | ||
2669 | connection->in_cleanup = !0; | 2669 | connection->in_cleanup = true; |
2670 | if (NULL != connection->response) | 2670 | if (NULL != connection->response) |
2671 | { | 2671 | { |
2672 | MHD_destroy_response (connection->response); | 2672 | MHD_destroy_response (connection->response); |
2673 | connection->response = NULL; | 2673 | connection->response = NULL; |
2674 | } | 2674 | } |
2675 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2675 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); |
2676 | { | 2676 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
2677 | MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); | ||
2678 | } | ||
2679 | else | ||
2680 | { | 2677 | { |
2681 | if (connection->connection_timeout == daemon->connection_timeout) | 2678 | if (connection->connection_timeout == daemon->connection_timeout) |
2682 | XDLL_remove (daemon->normal_timeout_head, | 2679 | XDLL_remove (daemon->normal_timeout_head, |
@@ -2687,7 +2684,7 @@ cleanup_connection (struct MHD_Connection *connection) | |||
2687 | daemon->manual_timeout_tail, | 2684 | daemon->manual_timeout_tail, |
2688 | connection); | 2685 | connection); |
2689 | } | 2686 | } |
2690 | if (MHD_YES == connection->suspended) | 2687 | if (connection->suspended) |
2691 | DLL_remove (daemon->suspended_connections_head, | 2688 | DLL_remove (daemon->suspended_connections_head, |
2692 | daemon->suspended_connections_tail, | 2689 | daemon->suspended_connections_tail, |
2693 | connection); | 2690 | connection); |
@@ -2698,12 +2695,12 @@ cleanup_connection (struct MHD_Connection *connection) | |||
2698 | DLL_insert (daemon->cleanup_head, | 2695 | DLL_insert (daemon->cleanup_head, |
2699 | daemon->cleanup_tail, | 2696 | daemon->cleanup_tail, |
2700 | connection); | 2697 | connection); |
2701 | connection->suspended = MHD_NO; | 2698 | connection->suspended = false; |
2702 | connection->resuming = MHD_NO; | 2699 | connection->resuming = false; |
2703 | connection->in_idle = MHD_NO; | 2700 | connection->in_idle = false; |
2701 | MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex); | ||
2704 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 2702 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
2705 | { | 2703 | { |
2706 | MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex); | ||
2707 | /* if we were at the connection limit before and are in | 2704 | /* if we were at the connection limit before and are in |
2708 | thread-per-connection mode, signal the main thread | 2705 | thread-per-connection mode, signal the main thread |
2709 | to resume accepting connections */ | 2706 | to resume accepting connections */ |
@@ -2739,7 +2736,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2739 | size_t line_len; | 2736 | size_t line_len; |
2740 | int client_close; | 2737 | int client_close; |
2741 | 2738 | ||
2742 | connection->in_idle = MHD_YES; | 2739 | connection->in_idle = true; |
2743 | while (1) | 2740 | while (1) |
2744 | { | 2741 | { |
2745 | #if DEBUG_STATES | 2742 | #if DEBUG_STATES |
@@ -2839,7 +2836,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2839 | if (MHD_CONNECTION_CLOSED == connection->state) | 2836 | if (MHD_CONNECTION_CLOSED == connection->state) |
2840 | continue; | 2837 | continue; |
2841 | connection->state = MHD_CONNECTION_HEADERS_PROCESSED; | 2838 | connection->state = MHD_CONNECTION_HEADERS_PROCESSED; |
2842 | if (MHD_YES == connection->suspended) | 2839 | if (connection->suspended) |
2843 | break; | 2840 | break; |
2844 | continue; | 2841 | continue; |
2845 | case MHD_CONNECTION_HEADERS_PROCESSED: | 2842 | case MHD_CONNECTION_HEADERS_PROCESSED: |
@@ -2869,7 +2866,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2869 | } | 2866 | } |
2870 | connection->state = (0 == connection->remaining_upload_size) | 2867 | connection->state = (0 == connection->remaining_upload_size) |
2871 | ? MHD_CONNECTION_FOOTERS_RECEIVED : MHD_CONNECTION_CONTINUE_SENT; | 2868 | ? MHD_CONNECTION_FOOTERS_RECEIVED : MHD_CONNECTION_CONTINUE_SENT; |
2872 | if (MHD_YES == connection->suspended) | 2869 | if (connection->suspended) |
2873 | break; | 2870 | break; |
2874 | continue; | 2871 | continue; |
2875 | case MHD_CONNECTION_CONTINUE_SENDING: | 2872 | case MHD_CONNECTION_CONTINUE_SENDING: |
@@ -2902,7 +2899,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2902 | connection->state = MHD_CONNECTION_BODY_RECEIVED; | 2899 | connection->state = MHD_CONNECTION_BODY_RECEIVED; |
2903 | else | 2900 | else |
2904 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 2901 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
2905 | if (MHD_YES == connection->suspended) | 2902 | if (connection->suspended) |
2906 | break; | 2903 | break; |
2907 | continue; | 2904 | continue; |
2908 | } | 2905 | } |
@@ -2925,7 +2922,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2925 | if (0 == line[0]) | 2922 | if (0 == line[0]) |
2926 | { | 2923 | { |
2927 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 2924 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
2928 | if (MHD_YES == connection->suspended) | 2925 | if (connection->suspended) |
2929 | break; | 2926 | break; |
2930 | continue; | 2927 | continue; |
2931 | } | 2928 | } |
@@ -2962,7 +2959,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2962 | if (0 == line[0]) | 2959 | if (0 == line[0]) |
2963 | { | 2960 | { |
2964 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 2961 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
2965 | if (MHD_YES == connection->suspended) | 2962 | if (connection->suspended) |
2966 | break; | 2963 | break; |
2967 | continue; | 2964 | continue; |
2968 | } | 2965 | } |
@@ -3205,7 +3202,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
3205 | { | 3202 | { |
3206 | MHD_connection_close_ (connection, | 3203 | MHD_connection_close_ (connection, |
3207 | MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); | 3204 | MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); |
3208 | connection->in_idle = MHD_NO; | 3205 | connection->in_idle = false; |
3209 | return MHD_YES; | 3206 | return MHD_YES; |
3210 | } | 3207 | } |
3211 | MHD_connection_update_event_loop_info (connection); | 3208 | MHD_connection_update_event_loop_info (connection); |
@@ -3305,7 +3302,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection) | |||
3305 | } | 3302 | } |
3306 | connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; | 3303 | connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; |
3307 | } | 3304 | } |
3308 | connection->in_idle = MHD_NO; | 3305 | connection->in_idle = false; |
3309 | return MHD_YES; | 3306 | return MHD_YES; |
3310 | } | 3307 | } |
3311 | #endif | 3308 | #endif |
@@ -3396,7 +3393,7 @@ MHD_set_connection_option (struct MHD_Connection *connection, | |||
3396 | { | 3393 | { |
3397 | case MHD_CONNECTION_OPTION_TIMEOUT: | 3394 | case MHD_CONNECTION_OPTION_TIMEOUT: |
3398 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 3395 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
3399 | (MHD_YES != connection->suspended) ) | 3396 | (! connection->suspended) ) |
3400 | { | 3397 | { |
3401 | if (connection->connection_timeout == daemon->connection_timeout) | 3398 | if (connection->connection_timeout == daemon->connection_timeout) |
3402 | XDLL_remove (daemon->normal_timeout_head, | 3399 | XDLL_remove (daemon->normal_timeout_head, |
@@ -3412,7 +3409,7 @@ MHD_set_connection_option (struct MHD_Connection *connection, | |||
3412 | unsigned int); | 3409 | unsigned int); |
3413 | va_end (ap); | 3410 | va_end (ap); |
3414 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 3411 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
3415 | (MHD_YES != connection->suspended) ) | 3412 | (! connection->suspended) ) |
3416 | { | 3413 | { |
3417 | if (connection->connection_timeout == daemon->connection_timeout) | 3414 | if (connection->connection_timeout == daemon->connection_timeout) |
3418 | XDLL_insert (daemon->normal_timeout_head, | 3415 | XDLL_insert (daemon->normal_timeout_head, |
@@ -3504,7 +3501,7 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
3504 | connection->read_closed = MHD_YES; | 3501 | connection->read_closed = MHD_YES; |
3505 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 3502 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
3506 | } | 3503 | } |
3507 | if (MHD_NO == connection->in_idle) | 3504 | if (! connection->in_idle) |
3508 | (void) MHD_connection_handle_idle (connection); | 3505 | (void) MHD_connection_handle_idle (connection); |
3509 | return MHD_YES; | 3506 | return MHD_YES; |
3510 | } | 3507 | } |