gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15734 - libmicrohttpd/src/daemon


From: gnunet
Subject: [GNUnet-SVN] r15734 - libmicrohttpd/src/daemon
Date: Wed, 22 Jun 2011 00:04:16 +0200

Author: grothoff
Date: 2011-06-22 00:04:16 +0200 (Wed, 22 Jun 2011)
New Revision: 15734

Modified:
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/daemon.c
Log:
race

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2011-06-21 20:53:22 UTC (rev 
15733)
+++ libmicrohttpd/src/daemon/connection.c       2011-06-21 22:04:16 UTC (rev 
15734)
@@ -2259,9 +2259,6 @@
           continue;
         case MHD_CONNECTION_CLOSED:
          daemon = connection->daemon;
-         DLL_remove (daemon->connections_head,
-                     daemon->connections_tail,
-                     connection);
          if (0 != pthread_mutex_lock(&daemon->cleanup_connection_mutex))
            {
 #if HAVE_MESSAGES
@@ -2269,6 +2266,9 @@
 #endif
              abort();
            }
+         DLL_remove (daemon->connections_head,
+                     daemon->connections_tail,
+                     connection);
          DLL_insert (daemon->cleanup_head,
                      daemon->cleanup_tail,
                      connection);

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2011-06-21 20:53:22 UTC (rev 15733)
+++ libmicrohttpd/src/daemon/daemon.c   2011-06-21 22:04:16 UTC (rev 15734)
@@ -1073,10 +1073,23 @@
           return MHD_NO;
         }
     }
-  /* FIXME: race with removal operation! */
+  if (0 != pthread_mutex_lock(&daemon->cleanup_connection_mutex))
+    {
+#if HAVE_MESSAGES
+      MHD_DLOG (daemon, "Failed to acquire cleanup mutex\n");
+#endif
+      abort();
+    }
   DLL_insert (daemon->connections_head,
              daemon->connections_tail,
              connection);
+  if (0 != pthread_mutex_unlock(&daemon->cleanup_connection_mutex))
+    {
+#if HAVE_MESSAGES
+      MHD_DLOG (daemon, "Failed to release cleanup mutex\n");
+#endif
+      abort();
+    }
   daemon->max_connections--;
   return MHD_YES;  
 }




reply via email to

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