aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-08-27 21:44:40 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-08-27 21:45:50 +0300
commit7934cc0777f86151b630e54f182c04015b9f488d (patch)
tree18be72618ab582ae159cd450a791ff2da1a3022c
parent953942677b185da6bf5a66adbf968446dd901841 (diff)
downloadlibmicrohttpd-7934cc0777f86151b630e54f182c04015b9f488d.tar.gz
libmicrohttpd-7934cc0777f86151b630e54f182c04015b9f488d.zip
MHD_queue_response(): check for correct thread ID
-rw-r--r--src/microhttpd/connection.c14
-rw-r--r--src/microhttpd/daemon.c2
2 files changed, 13 insertions, 3 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index bbebfc57..95823992 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3769,9 +3769,7 @@ MHD_queue_response (struct MHD_Connection *connection,
3769 unsigned int status_code, 3769 unsigned int status_code,
3770 struct MHD_Response *response) 3770 struct MHD_Response *response)
3771{ 3771{
3772#ifdef UPGRADE_SUPPORT
3773 struct MHD_Daemon *daemon; 3772 struct MHD_Daemon *daemon;
3774#endif /* UPGRADE_SUPPORT */
3775 3773
3776 if ( (NULL == connection) || 3774 if ( (NULL == connection) ||
3777 (NULL == response) || 3775 (NULL == response) ||
@@ -3779,8 +3777,18 @@ MHD_queue_response (struct MHD_Connection *connection,
3779 ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && 3777 ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) &&
3780 (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) 3778 (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) )
3781 return MHD_NO; 3779 return MHD_NO;
3782#ifdef UPGRADE_SUPPORT
3783 daemon = connection->daemon; 3780 daemon = connection->daemon;
3781 if ( (!connection->suspended) &&
3782 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
3783 (!MHD_thread_ID_match_current_(connection->pid.ID)) )
3784 {
3785#ifdef HAVE_MESSAGES
3786 MHD_DLOG (daemon,
3787 _("Attempted to queue response on wrong thread!\n"));
3788#endif
3789 return MHD_NO;
3790 }
3791#ifdef UPGRADE_SUPPORT
3784 if ( (NULL != response->upgrade_handler) && 3792 if ( (NULL != response->upgrade_handler) &&
3785 (0 == (daemon->options & MHD_ALLOW_UPGRADE)) ) 3793 (0 == (daemon->options & MHD_ALLOW_UPGRADE)) )
3786 { 3794 {
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 2f8945c1..51b05d8e 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2397,6 +2397,8 @@ internal_add_connection (struct MHD_Daemon *daemon,
2397 goto cleanup; 2397 goto cleanup;
2398 } 2398 }
2399 } 2399 }
2400 else
2401 connection->pid = daemon->pid;
2400#ifdef EPOLL_SUPPORT 2402#ifdef EPOLL_SUPPORT
2401 if (0 != (daemon->options & MHD_USE_EPOLL)) 2403 if (0 != (daemon->options & MHD_USE_EPOLL))
2402 { 2404 {