|
|
@@ -1054,6 +1054,24 @@ MHD_add_connection (struct MHD_Daemon *daemon,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
/* attempt to create handler thread */
|
|
|
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
{
|
|
|
@@ -1068,27 +1086,27 @@ MHD_add_connection (struct MHD_Daemon *daemon,
|
|
|
SHUTDOWN (client_socket, SHUT_RDWR);
|
|
|
CLOSE (client_socket);
|
|
|
MHD_ip_limit_del (daemon, addr, addrlen);
|
|
|
- free (connection->addr);
|
|
|
- free (connection);
|
|
|
- return MHD_NO;
|
|
|
- }
|
|
|
- }
|
|
|
- if (0 != pthread_mutex_lock(&daemon->cleanup_connection_mutex))
|
|
|
- {
|
|
|
+ if (0 != pthread_mutex_lock(&daemon->cleanup_connection_mutex))
|
|
|
+ {
|
|
|
#if HAVE_MESSAGES
|
|
|
- MHD_DLOG (daemon, "Failed to acquire cleanup mutex\n");
|
|
|
+ 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))
|
|
|
- {
|
|
|
+ abort();
|
|
|
+ }
|
|
|
+ DLL_remove (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");
|
|
|
+ MHD_DLOG (daemon, "Failed to release cleanup mutex\n");
|
|
|
#endif
|
|
|
- abort();
|
|
|
+ abort();
|
|
|
+ }
|
|
|
+ free (connection->addr);
|
|
|
+ free (connection);
|
|
|
+ return MHD_NO;
|
|
|
+ }
|
|
|
}
|
|
|
daemon->max_connections--;
|
|
|
return MHD_YES;
|