gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 03/03: MHD_queue_response(): check for corr


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 03/03: MHD_queue_response(): check for correct thread ID
Date: Sun, 27 Aug 2017 20:46:58 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 7934cc0777f86151b630e54f182c04015b9f488d
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sun Aug 27 21:44:40 2017 +0300

    MHD_queue_response(): check for correct thread ID
---
 src/microhttpd/connection.c | 14 +++++++++++---
 src/microhttpd/daemon.c     |  2 ++
 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,
                     unsigned int status_code,
                     struct MHD_Response *response)
 {
-#ifdef UPGRADE_SUPPORT
   struct MHD_Daemon *daemon;
-#endif /* UPGRADE_SUPPORT */
 
   if ( (NULL == connection) ||
        (NULL == response) ||
@@ -3779,8 +3777,18 @@ MHD_queue_response (struct MHD_Connection *connection,
        ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) &&
         (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) )
     return MHD_NO;
-#ifdef UPGRADE_SUPPORT
   daemon = connection->daemon;
+  if ( (!connection->suspended) &&
+       (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+       (!MHD_thread_ID_match_current_(connection->pid.ID)) )
+    {
+#ifdef HAVE_MESSAGES
+      MHD_DLOG (daemon,
+                _("Attempted to queue response on wrong thread!\n"));
+#endif
+      return MHD_NO;
+    }
+#ifdef UPGRADE_SUPPORT
   if ( (NULL != response->upgrade_handler) &&
        (0 == (daemon->options & MHD_ALLOW_UPGRADE)) )
     {
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,
          goto cleanup;
         }
     }
+  else
+    connection->pid = daemon->pid;
 #ifdef EPOLL_SUPPORT
   if (0 != (daemon->options & MHD_USE_EPOLL))
     {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]