diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 3aa0d16c..e1bc1f7e 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2132,22 +2132,19 @@ update_last_activity (struct MHD_Connection *connection) | |||
2132 | struct MHD_Daemon *daemon = connection->daemon; | 2132 | struct MHD_Daemon *daemon = connection->daemon; |
2133 | 2133 | ||
2134 | connection->last_activity = MHD_monotonic_sec_counter(); | 2134 | connection->last_activity = MHD_monotonic_sec_counter(); |
2135 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | ||
2136 | return; /* each connection has personal timeout */ | ||
2137 | |||
2135 | if (connection->connection_timeout != daemon->connection_timeout) | 2138 | if (connection->connection_timeout != daemon->connection_timeout) |
2136 | return; /* custom timeout, no need to move it in "normal" DLL */ | 2139 | return; /* custom timeout, no need to move it in "normal" DLL */ |
2137 | 2140 | ||
2138 | /* move connection to head of timeout list (by remove + add operation) */ | 2141 | /* move connection to head of timeout list (by remove + add operation) */ |
2139 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
2140 | (MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | ||
2141 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | ||
2142 | XDLL_remove (daemon->normal_timeout_head, | 2142 | XDLL_remove (daemon->normal_timeout_head, |
2143 | daemon->normal_timeout_tail, | 2143 | daemon->normal_timeout_tail, |
2144 | connection); | 2144 | connection); |
2145 | XDLL_insert (daemon->normal_timeout_head, | 2145 | XDLL_insert (daemon->normal_timeout_head, |
2146 | daemon->normal_timeout_tail, | 2146 | daemon->normal_timeout_tail, |
2147 | connection); | 2147 | connection); |
2148 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
2149 | (MHD_YES != MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | ||
2150 | MHD_PANIC ("Failed to release cleanup mutex\n"); | ||
2151 | } | 2148 | } |
2152 | 2149 | ||
2153 | 2150 | ||
@@ -2397,17 +2394,22 @@ cleanup_connection (struct MHD_Connection *connection) | |||
2397 | MHD_destroy_response (connection->response); | 2394 | MHD_destroy_response (connection->response); |
2398 | connection->response = NULL; | 2395 | connection->response = NULL; |
2399 | } | 2396 | } |
2400 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 2397 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
2401 | (MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 2398 | { |
2402 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | 2399 | if (MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) |
2403 | if (connection->connection_timeout == daemon->connection_timeout) | 2400 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); |
2404 | XDLL_remove (daemon->normal_timeout_head, | 2401 | } |
2405 | daemon->normal_timeout_tail, | ||
2406 | connection); | ||
2407 | else | 2402 | else |
2408 | XDLL_remove (daemon->manual_timeout_head, | 2403 | { |
2409 | daemon->manual_timeout_tail, | 2404 | if (connection->connection_timeout == daemon->connection_timeout) |
2410 | connection); | 2405 | XDLL_remove (daemon->normal_timeout_head, |
2406 | daemon->normal_timeout_tail, | ||
2407 | connection); | ||
2408 | else | ||
2409 | XDLL_remove (daemon->manual_timeout_head, | ||
2410 | daemon->manual_timeout_tail, | ||
2411 | connection); | ||
2412 | } | ||
2411 | if (MHD_YES == connection->suspended) | 2413 | if (MHD_YES == connection->suspended) |
2412 | DLL_remove (daemon->suspended_connections_head, | 2414 | DLL_remove (daemon->suspended_connections_head, |
2413 | daemon->suspended_connections_tail, | 2415 | daemon->suspended_connections_tail, |
@@ -3040,37 +3042,33 @@ MHD_set_connection_option (struct MHD_Connection *connection, | |||
3040 | switch (option) | 3042 | switch (option) |
3041 | { | 3043 | { |
3042 | case MHD_CONNECTION_OPTION_TIMEOUT: | 3044 | case MHD_CONNECTION_OPTION_TIMEOUT: |
3043 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | 3045 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
3044 | (MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) | 3046 | (MHD_YES != connection->suspended) ) |
3045 | MHD_PANIC ("Failed to acquire cleanup mutex\n"); | ||
3046 | if (MHD_YES != connection->suspended) | ||
3047 | { | 3047 | { |
3048 | if (connection->connection_timeout == daemon->connection_timeout) | 3048 | if (connection->connection_timeout == daemon->connection_timeout) |
3049 | XDLL_remove (daemon->normal_timeout_head, | 3049 | XDLL_remove (daemon->normal_timeout_head, |
3050 | daemon->normal_timeout_tail, | 3050 | daemon->normal_timeout_tail, |
3051 | connection); | 3051 | connection); |
3052 | else | 3052 | else |
3053 | XDLL_remove (daemon->manual_timeout_head, | 3053 | XDLL_remove (daemon->manual_timeout_head, |
3054 | daemon->manual_timeout_tail, | 3054 | daemon->manual_timeout_tail, |
3055 | connection); | 3055 | connection); |
3056 | } | 3056 | } |
3057 | va_start (ap, option); | 3057 | va_start (ap, option); |
3058 | connection->connection_timeout = va_arg (ap, unsigned int); | 3058 | connection->connection_timeout = va_arg (ap, unsigned int); |
3059 | va_end (ap); | 3059 | va_end (ap); |
3060 | if (MHD_YES != connection->suspended) | 3060 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && |
3061 | (MHD_YES != connection->suspended) ) | ||
3061 | { | 3062 | { |
3062 | if (connection->connection_timeout == daemon->connection_timeout) | 3063 | if (connection->connection_timeout == daemon->connection_timeout) |
3063 | XDLL_insert (daemon->normal_timeout_head, | 3064 | XDLL_insert (daemon->normal_timeout_head, |
3064 | daemon->normal_timeout_tail, | 3065 | daemon->normal_timeout_tail, |
3065 | connection); | 3066 | connection); |
3066 | else | 3067 | else |
3067 | XDLL_insert (daemon->manual_timeout_head, | 3068 | XDLL_insert (daemon->manual_timeout_head, |
3068 | daemon->manual_timeout_tail, | 3069 | daemon->manual_timeout_tail, |
3069 | connection); | 3070 | connection); |
3070 | } | 3071 | } |
3071 | if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
3072 | (MHD_YES != MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) | ||
3073 | MHD_PANIC ("Failed to release cleanup mutex\n"); | ||
3074 | return MHD_YES; | 3072 | return MHD_YES; |
3075 | default: | 3073 | default: |
3076 | return MHD_NO; | 3074 | return MHD_NO; |