aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd')
-rw-r--r--src/microhttpd/connection.c1
-rw-r--r--src/microhttpd/mhd_sem.c8
-rw-r--r--src/microhttpd/response.c14
-rw-r--r--src/microhttpd/test_upgrade.c14
4 files changed, 22 insertions, 15 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 16477538..fa87a7a5 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3185,6 +3185,7 @@ MHD_queue_response (struct MHD_Connection *connection,
3185 return MHD_NO; 3185 return MHD_NO;
3186 } 3186 }
3187 if ( (NULL != response->upgrade_handler) && 3187 if ( (NULL != response->upgrade_handler) &&
3188 (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
3188 (0 == (daemon->options & MHD_USE_SUSPEND_RESUME)) ) 3189 (0 == (daemon->options & MHD_USE_SUSPEND_RESUME)) )
3189 { 3190 {
3190#ifdef HAVE_MESSAGES 3191#ifdef HAVE_MESSAGES
diff --git a/src/microhttpd/mhd_sem.c b/src/microhttpd/mhd_sem.c
index fdd5dbe4..d4d6600b 100644
--- a/src/microhttpd/mhd_sem.c
+++ b/src/microhttpd/mhd_sem.c
@@ -88,7 +88,7 @@ MHD_semaphore_create (unsigned int init)
88void 88void
89MHD_semaphore_down (struct MHD_Semaphore *sem) 89MHD_semaphore_down (struct MHD_Semaphore *sem)
90{ 90{
91 if (! pthread_mutex_lock (&sem->mutex)) 91 if (0 != pthread_mutex_lock (&sem->mutex))
92 MHD_PANIC ("pthread_mutex_lock for semaphore failed\n"); 92 MHD_PANIC ("pthread_mutex_lock for semaphore failed\n");
93 while (0 == sem->counter) 93 while (0 == sem->counter)
94 { 94 {
@@ -97,7 +97,7 @@ MHD_semaphore_down (struct MHD_Semaphore *sem)
97 MHD_PANIC ("pthread_cond_wait failed\n"); 97 MHD_PANIC ("pthread_cond_wait failed\n");
98 } 98 }
99 sem->counter--; 99 sem->counter--;
100 if (! pthread_mutex_unlock (&sem->mutex)) 100 if (0 != pthread_mutex_unlock (&sem->mutex))
101 MHD_PANIC ("pthread_mutex_unlock for semaphore failed\n"); 101 MHD_PANIC ("pthread_mutex_unlock for semaphore failed\n");
102} 102}
103 103
@@ -110,11 +110,11 @@ MHD_semaphore_down (struct MHD_Semaphore *sem)
110void 110void
111MHD_semaphore_up (struct MHD_Semaphore *sem) 111MHD_semaphore_up (struct MHD_Semaphore *sem)
112{ 112{
113 if (! pthread_mutex_lock (&sem->mutex)) 113 if (0 != pthread_mutex_lock (&sem->mutex))
114 MHD_PANIC ("pthread_mutex_lock for semaphore failed\n"); 114 MHD_PANIC ("pthread_mutex_lock for semaphore failed\n");
115 sem->counter++; 115 sem->counter++;
116 pthread_cond_signal (&sem->cv); 116 pthread_cond_signal (&sem->cv);
117 if (! pthread_mutex_unlock (&sem->mutex)) 117 if (0 != pthread_mutex_unlock (&sem->mutex))
118 MHD_PANIC ("pthread_mutex_unlock for semaphore failed\n"); 118 MHD_PANIC ("pthread_mutex_unlock for semaphore failed\n");
119} 119}
120 120
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index c08117d7..a97df80c 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -867,13 +867,6 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
867 urh->app.socket = MHD_INVALID_SOCKET; 867 urh->app.socket = MHD_INVALID_SOCKET;
868 urh->mhd.socket = MHD_INVALID_SOCKET; 868 urh->mhd.socket = MHD_INVALID_SOCKET;
869#endif 869#endif
870 response->upgrade_handler (response->upgrade_handler_cls,
871 connection,
872 connection->client_context,
873 connection->read_buffer,
874 rbo,
875 connection->socket_fd,
876 urh);
877 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION) ) 870 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION) )
878 { 871 {
879 /* Need to give the thread something to block on... */ 872 /* Need to give the thread something to block on... */
@@ -899,6 +892,13 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
899 #MHD_upgrade_action() function */ 892 #MHD_upgrade_action() function */
900 MHD_suspend_connection (connection); 893 MHD_suspend_connection (connection);
901 } 894 }
895 response->upgrade_handler (response->upgrade_handler_cls,
896 connection,
897 connection->client_context,
898 connection->read_buffer,
899 rbo,
900 connection->socket_fd,
901 urh);
902 return MHD_YES; 902 return MHD_YES;
903} 903}
904 904
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 8a7a9c02..0836f66e 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -286,7 +286,9 @@ test_upgrade_internal (int flags,
286 MHD_socket sock; 286 MHD_socket sock;
287 struct sockaddr_in sa; 287 struct sockaddr_in sa;
288 288
289 d = MHD_start_daemon (flags | MHD_USE_DEBUG | MHD_USE_SUSPEND_RESUME, 289 if (0 == (flags & MHD_USE_THREAD_PER_CONNECTION))
290 flags |= MHD_USE_SUSPEND_RESUME;
291 d = MHD_start_daemon (flags | MHD_USE_DEBUG,
290 1080, 292 1080,
291 NULL, NULL, 293 NULL, NULL,
292 &ahc_upgrade, NULL, 294 &ahc_upgrade, NULL,
@@ -325,19 +327,23 @@ main (int argc,
325{ 327{
326 int error_count = 0; 328 int error_count = 0;
327 329
330 error_count += test_upgrade_internal (MHD_USE_THREAD_PER_CONNECTION,
331 0);
332 error_count += test_upgrade_internal (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
333 0);
328 error_count += test_upgrade_internal (MHD_USE_SELECT_INTERNALLY, 334 error_count += test_upgrade_internal (MHD_USE_SELECT_INTERNALLY,
329 1); 335 0);
330 error_count += test_upgrade_internal (MHD_USE_SELECT_INTERNALLY, 336 error_count += test_upgrade_internal (MHD_USE_SELECT_INTERNALLY,
331 2); 337 2);
332#ifdef HAVE_POLL 338#ifdef HAVE_POLL
333 error_count += test_upgrade_internal (MHD_USE_POLL_INTERNALLY, 339 error_count += test_upgrade_internal (MHD_USE_POLL_INTERNALLY,
334 1); 340 0);
335 error_count += test_upgrade_internal (MHD_USE_POLL_INTERNALLY, 341 error_count += test_upgrade_internal (MHD_USE_POLL_INTERNALLY,
336 2); 342 2);
337#endif 343#endif
338#ifdef EPOLL_SUPPORT 344#ifdef EPOLL_SUPPORT
339 error_count += test_upgrade_internal (MHD_USE_EPOLL_INTERNALLY, 345 error_count += test_upgrade_internal (MHD_USE_EPOLL_INTERNALLY,
340 1); 346 0);
341 error_count += test_upgrade_internal (MHD_USE_EPOLL_INTERNALLY, 347 error_count += test_upgrade_internal (MHD_USE_EPOLL_INTERNALLY,
342 2); 348 2);
343#endif 349#endif