gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33742 - in libmicrohttpd: . src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r33742 - in libmicrohttpd: . src/microhttpd
Date: Sun, 22 Jun 2014 00:22:55 +0200

Author: grothoff
Date: 2014-06-22 00:22:55 +0200 (Sun, 22 Jun 2014)
New Revision: 33742

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/microhttpd/connection.c
Log:
lock when modifying response object to add missing headers

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2014-06-20 23:46:12 UTC (rev 33741)
+++ libmicrohttpd/ChangeLog     2014-06-21 22:22:55 UTC (rev 33742)
@@ -1,3 +1,7 @@
+Sun Jun 22 00:22:08 CEST 2014
+       Lock on response if adding headers, needed if response
+       object is shared across threads and connections. -CG
+
 Thu Jun 19 17:32:32 CEST 2014
        Ensure that listen FD is bound to epoll FD even before
        MHD_run() is called if running with MHD_USE_EPOLL_LINUX_ONLY

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2014-06-20 23:46:12 UTC (rev 
33741)
+++ libmicrohttpd/src/microhttpd/connection.c   2014-06-21 22:22:55 UTC (rev 
33742)
@@ -2466,13 +2466,16 @@
             continue;
           if (NULL == connection->response)
             break;              /* try again next time */
+          (void) MHD_mutex_lock_ (&connection->response->mutex);
           if (MHD_NO == build_header_response (connection))
             {
               /* oops - close! */
+              (void) MHD_mutex_unlock_ (&connection->response->mutex);
              CONNECTION_CLOSE_ERROR (connection,
                                      "Closing connection (failed to create 
response header)\n");
               continue;
             }
+          (void) MHD_mutex_unlock_ (&connection->response->mutex);
           connection->state = MHD_CONNECTION_HEADERS_SENDING;
 
 #if HAVE_DECL_TCP_CORK
@@ -2539,7 +2542,16 @@
             (void) MHD_mutex_unlock_ (&connection->response->mutex);
           break;
         case MHD_CONNECTION_BODY_SENT:
-          build_header_response (connection);
+          (void) MHD_mutex_lock_ (&connection->response->mutex);
+          if (MHD_NO == build_header_response (connection))
+            {
+              /* oops - close! */
+              (void) MHD_mutex_unlock_ (&connection->response->mutex);
+             CONNECTION_CLOSE_ERROR (connection,
+                                     "Closing connection (failed to create 
response header)\n");
+              continue;
+            }
+          (void) MHD_mutex_unlock_ (&connection->response->mutex);
           if ( (MHD_NO == connection->have_chunked_upload) ||
                (connection->write_buffer_send_offset ==
                 connection->write_buffer_append_offset) )




reply via email to

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