|
|
@@ -195,10 +195,7 @@ struct MHD_IPCount
|
|
|
static void
|
|
|
MHD_ip_count_lock (struct MHD_Daemon *daemon)
|
|
|
{
|
|
|
- if (! MHD_mutex_lock_(&daemon->per_ip_connection_mutex))
|
|
|
- {
|
|
|
- MHD_PANIC (_("Failed to acquire IP connection limit mutex\n"));
|
|
|
- }
|
|
|
+ MHD_mutex_lock_(&daemon->per_ip_connection_mutex);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -210,10 +207,7 @@ MHD_ip_count_lock (struct MHD_Daemon *daemon)
|
|
|
static void
|
|
|
MHD_ip_count_unlock (struct MHD_Daemon *daemon)
|
|
|
{
|
|
|
- if (! MHD_mutex_unlock_(&daemon->per_ip_connection_mutex))
|
|
|
- {
|
|
|
- MHD_PANIC (_("Failed to release IP connection limit mutex\n"));
|
|
|
- }
|
|
|
+ MHD_mutex_unlock_(&daemon->per_ip_connection_mutex);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -965,8 +959,7 @@ finish_upgrade_close (struct MHD_UpgradeResponseHandle *urh)
|
|
|
NULL)) )
|
|
|
MHD_PANIC (_("Failed to remove FD from epoll set\n"));
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (urh->mhd.socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (urh->mhd.socket);
|
|
|
}
|
|
|
MHD_resume_connection (connection);
|
|
|
MHD_connection_close_ (connection,
|
|
|
@@ -1536,8 +1529,7 @@ exit:
|
|
|
{
|
|
|
shutdown (con->socket_fd,
|
|
|
SHUT_WR);
|
|
|
- if (0 != MHD_socket_close_ (con->socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (con->socket_fd);
|
|
|
con->socket_fd = MHD_INVALID_SOCKET;
|
|
|
}
|
|
|
return (MHD_THRD_RTRN_TYPE_) 0;
|
|
|
@@ -1776,8 +1768,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
external_add);
|
|
|
}
|
|
|
/* all pools are at their connection limit, must refuse */
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC ("close failed\n");
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
#if ENFILE
|
|
|
errno = ENFILE;
|
|
|
#endif
|
|
|
@@ -1794,8 +1785,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
(int) client_socket,
|
|
|
(int) FD_SETSIZE);
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
#if EINVAL
|
|
|
errno = EINVAL;
|
|
|
#endif
|
|
|
@@ -1820,8 +1810,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
MHD_DLOG (daemon,
|
|
|
_("Server reached connection limit. Closing inbound connection.\n"));
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
#if ENFILE
|
|
|
errno = ENFILE;
|
|
|
#endif
|
|
|
@@ -1840,8 +1829,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
_("Connection rejected by application. Closing connection.\n"));
|
|
|
#endif
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
MHD_ip_limit_del (daemon,
|
|
|
addr,
|
|
|
addrlen);
|
|
|
@@ -1871,8 +1859,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
"Error allocating memory: %s\n",
|
|
|
MHD_strerror_ (errno));
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC ("close failed\n");
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
MHD_ip_limit_del (daemon,
|
|
|
addr,
|
|
|
addrlen);
|
|
|
@@ -1890,8 +1877,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
_("Error allocating memory: %s\n"),
|
|
|
MHD_strerror_ (errno));
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
MHD_ip_limit_del (daemon,
|
|
|
addr,
|
|
|
addrlen);
|
|
|
@@ -1911,8 +1897,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
_("Error allocating memory: %s\n"),
|
|
|
MHD_strerror_ (errno));
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
MHD_ip_limit_del (daemon,
|
|
|
addr,
|
|
|
addrlen);
|
|
|
@@ -1973,8 +1958,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
_("Failed to setup TLS credentials: unknown credential type %d\n"),
|
|
|
daemon->cred_type);
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC ("close failed\n");
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
MHD_ip_limit_del (daemon,
|
|
|
addr,
|
|
|
addrlen);
|
|
|
@@ -2001,19 +1985,19 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
|
|
|
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
{
|
|
|
- if (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex))
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
XDLL_insert (daemon->normal_timeout_head,
|
|
|
daemon->normal_timeout_tail,
|
|
|
connection);
|
|
|
+ }
|
|
|
DLL_insert (daemon->connections_head,
|
|
|
daemon->connections_tail,
|
|
|
connection);
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
|
|
|
if (NULL != daemon->notify_connection)
|
|
|
daemon->notify_connection (daemon->notify_connection_cls,
|
|
|
@@ -2093,24 +2077,25 @@ internal_add_connection (struct MHD_Daemon *daemon,
|
|
|
connection,
|
|
|
&connection->socket_context,
|
|
|
MHD_CONNECTION_NOTIFY_CLOSED);
|
|
|
- if (0 != MHD_socket_close_ (client_socket))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
- MHD_ip_limit_del (daemon, addr, addrlen);
|
|
|
+ MHD_socket_close_ (client_socket);
|
|
|
+ MHD_ip_limit_del (daemon,
|
|
|
+ addr,
|
|
|
+ addrlen);
|
|
|
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
- {
|
|
|
- if (!MHD_mutex_lock_ (&daemon->cleanup_connection_mutex))
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
- }
|
|
|
+ {
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
+ }
|
|
|
else
|
|
|
- XDLL_remove (daemon->normal_timeout_head,
|
|
|
- daemon->normal_timeout_tail,
|
|
|
- connection);
|
|
|
+ {
|
|
|
+ XDLL_remove (daemon->normal_timeout_head,
|
|
|
+ daemon->normal_timeout_tail,
|
|
|
+ connection);
|
|
|
+ }
|
|
|
DLL_remove (daemon->connections_head,
|
|
|
daemon->connections_tail,
|
|
|
connection);
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (!MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
MHD_pool_destroy (connection->pool);
|
|
|
free (connection->addr);
|
|
|
free (connection);
|
|
|
@@ -2156,8 +2141,7 @@ MHD_suspend_connection (struct MHD_Connection *connection)
|
|
|
MHD_PANIC (_("Cannot suspend connections without enabling MHD_USE_SUSPEND_RESUME!\n"));
|
|
|
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
{
|
|
|
- if (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex))
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2199,9 +2183,8 @@ MHD_suspend_connection (struct MHD_Connection *connection)
|
|
|
}
|
|
|
#endif
|
|
|
connection->suspended = MHD_YES;
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2221,9 +2204,8 @@ MHD_resume_connection (struct MHD_Connection *connection)
|
|
|
daemon = connection->daemon;
|
|
|
if (MHD_USE_SUSPEND_RESUME != (daemon->options & MHD_USE_SUSPEND_RESUME))
|
|
|
MHD_PANIC (_("Cannot resume connections without enabling MHD_USE_SUSPEND_RESUME!\n"));
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
connection->resuming = MHD_YES;
|
|
|
daemon->resuming = MHD_YES;
|
|
|
if ( (MHD_INVALID_PIPE_ != daemon->wpipe[1]) &&
|
|
|
@@ -2234,9 +2216,8 @@ MHD_resume_connection (struct MHD_Connection *connection)
|
|
|
_("Failed to signal resume via pipe."));
|
|
|
#endif
|
|
|
}
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2255,9 +2236,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
|
|
|
int ret;
|
|
|
|
|
|
ret = MHD_NO;
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
if (MHD_NO != daemon->resuming)
|
|
|
next = daemon->suspended_connections_head;
|
|
|
|
|
|
@@ -2311,9 +2291,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
|
|
|
pos->suspended = MHD_NO;
|
|
|
pos->resuming = MHD_NO;
|
|
|
}
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -2442,9 +2421,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
|
|
|
#endif
|
|
|
if (MHD_INVALID_SOCKET != s)
|
|
|
{
|
|
|
- if (0 != MHD_socket_close_ (s))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
- /* just in case */
|
|
|
+ MHD_socket_close_ (s);
|
|
|
}
|
|
|
if ( MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) )
|
|
|
{
|
|
|
@@ -2518,9 +2495,8 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
|
|
|
{
|
|
|
struct MHD_Connection *pos;
|
|
|
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
while (NULL != (pos = daemon->cleanup_head))
|
|
|
{
|
|
|
DLL_remove (daemon->cleanup_head,
|
|
|
@@ -2586,16 +2562,14 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
|
|
|
}
|
|
|
if (MHD_INVALID_SOCKET != pos->socket_fd)
|
|
|
{
|
|
|
- if (0 != MHD_socket_close_ (pos->socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (pos->socket_fd);
|
|
|
}
|
|
|
if (NULL != pos->addr)
|
|
|
free (pos->addr);
|
|
|
free (pos);
|
|
|
}
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -4829,8 +4803,7 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
(unsigned int) port,
|
|
|
MHD_socket_last_strerr_ ());
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
#ifdef TCP_FASTOPEN
|
|
|
@@ -4860,8 +4833,7 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
_("Failed to listen for connections: %s\n"),
|
|
|
MHD_socket_last_strerr_ ());
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
}
|
|
|
@@ -4883,8 +4855,7 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
/* Accept must be non-blocking. Multiple children may wake up
|
|
|
* to handle a new connection, but only one will win the race.
|
|
|
* The others must immediately return. */
|
|
|
- if (0 != MHD_socket_close_ (socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
}
|
|
|
@@ -4898,8 +4869,7 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
socket_fd,
|
|
|
FD_SETSIZE);
|
|
|
#endif
|
|
|
- if (0 != MHD_socket_close_ (socket_fd))
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
|
|
|
@@ -4936,9 +4906,8 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
MHD_DLOG (daemon,
|
|
|
_("MHD failed to initialize IP connection limit mutex\n"));
|
|
|
#endif
|
|
|
- if ( (MHD_INVALID_SOCKET != socket_fd) &&
|
|
|
- (0 != MHD_socket_close_ (socket_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ if (MHD_INVALID_SOCKET != socket_fd)
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex))
|
|
|
@@ -4947,10 +4916,9 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
MHD_DLOG (daemon,
|
|
|
_("MHD failed to initialize IP connection limit mutex\n"));
|
|
|
#endif
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
- if ( (MHD_INVALID_SOCKET != socket_fd) &&
|
|
|
- (0 != MHD_socket_close_ (socket_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
+ if (MHD_INVALID_SOCKET != socket_fd)
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
|
|
|
@@ -4963,11 +4931,10 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
MHD_DLOG (daemon,
|
|
|
_("Failed to initialize TLS support\n"));
|
|
|
#endif
|
|
|
- if ( (MHD_INVALID_SOCKET != socket_fd) &&
|
|
|
- (0 != MHD_socket_close_ (socket_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
+ if (MHD_INVALID_SOCKET != socket_fd)
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
+ MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
#endif
|
|
|
@@ -4987,11 +4954,10 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
_("Failed to create listen thread: %s\n"),
|
|
|
MHD_strerror_ (errno));
|
|
|
#endif
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
- if ( (MHD_INVALID_SOCKET != socket_fd) &&
|
|
|
- (0 != MHD_socket_close_ (socket_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
+ if (MHD_INVALID_SOCKET != socket_fd)
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
goto free_and_fail;
|
|
|
}
|
|
|
if ( (daemon->worker_pool_size > 0) &&
|
|
|
@@ -5107,7 +5073,7 @@ MHD_start_daemon_va (unsigned int flags,
|
|
|
#endif
|
|
|
/* Free memory for this worker; cleanup below handles
|
|
|
* all previously-created workers. */
|
|
|
- (void) MHD_mutex_destroy_ (&d->cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&d->cleanup_connection_mutex);
|
|
|
goto thread_failed;
|
|
|
}
|
|
|
}
|
|
|
@@ -5127,11 +5093,10 @@ thread_failed:
|
|
|
MHD_USE_SELECT_INTERNALLY mode. */
|
|
|
if (0 == i)
|
|
|
{
|
|
|
- if ( (MHD_INVALID_SOCKET != socket_fd) &&
|
|
|
- (0 != MHD_socket_close_ (socket_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
+ if (MHD_INVALID_SOCKET != socket_fd)
|
|
|
+ MHD_socket_close_ (socket_fd);
|
|
|
+ MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
if (NULL != daemon->worker_pool)
|
|
|
free (daemon->worker_pool);
|
|
|
goto free_and_fail;
|
|
|
@@ -5169,7 +5134,7 @@ thread_failed:
|
|
|
#endif
|
|
|
#ifdef DAUTH_SUPPORT
|
|
|
free (daemon->nnc);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->nnc_lock);
|
|
|
+ MHD_mutex_destroy_ (&daemon->nnc_lock);
|
|
|
#endif
|
|
|
#if HTTPS_SUPPORT
|
|
|
if (0 != (flags & MHD_USE_SSL))
|
|
|
@@ -5231,11 +5196,15 @@ close_all_connections (struct MHD_Daemon *daemon)
|
|
|
{
|
|
|
struct MHD_Connection *pos;
|
|
|
|
|
|
+ /* Give suspended connections a chance to resume to avoid
|
|
|
+ running into the check for there not being any suspended
|
|
|
+ connections left in case of a tight race with a recently
|
|
|
+ resumed connection. */
|
|
|
+ resume_suspended_connections (daemon);
|
|
|
/* first, make sure all threads are aware of shutdown; need to
|
|
|
traverse DLLs in peace... */
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to acquire cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_lock_ (&daemon->cleanup_connection_mutex);
|
|
|
if (NULL != daemon->suspended_connections_head)
|
|
|
MHD_PANIC (_("MHD_stop_daemon() called while we have suspended connections.\n"));
|
|
|
for (pos = daemon->connections_head; NULL != pos; pos = pos->next)
|
|
|
@@ -5248,9 +5217,8 @@ close_all_connections (struct MHD_Daemon *daemon)
|
|
|
MHD_PANIC (_("Failed to signal shutdown via pipe"));
|
|
|
#endif
|
|
|
}
|
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
|
|
- (! MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )
|
|
|
- MHD_PANIC (_("Failed to release cleanup mutex\n"));
|
|
|
+ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
+ MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex);
|
|
|
|
|
|
/* now, collect per-connection threads */
|
|
|
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
|
|
|
@@ -5392,15 +5360,13 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
|
|
|
if (!MHD_join_thread_ (daemon->worker_pool[i].pid))
|
|
|
MHD_PANIC (_("Failed to join a thread\n"));
|
|
|
close_all_connections (&daemon->worker_pool[i]);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->worker_pool[i].cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->worker_pool[i].cleanup_connection_mutex);
|
|
|
#ifdef EPOLL_SUPPORT
|
|
|
- if ( (-1 != daemon->worker_pool[i].epoll_fd) &&
|
|
|
- (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ if (-1 != daemon->worker_pool[i].epoll_fd)
|
|
|
+ MHD_socket_close_ (daemon->worker_pool[i].epoll_fd);
|
|
|
#if HTTPS_SUPPORT
|
|
|
- if ( (-1 != daemon->worker_pool[i].epoll_upgrade_fd) &&
|
|
|
- (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_upgrade_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ if (-1 != daemon->worker_pool[i].epoll_upgrade_fd)
|
|
|
+ MHD_socket_close_ (daemon->worker_pool[i].epoll_upgrade_fd);
|
|
|
#endif
|
|
|
#endif
|
|
|
/* Individual pipes are always used */
|
|
|
@@ -5431,9 +5397,8 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
|
|
|
}
|
|
|
}
|
|
|
close_all_connections (daemon);
|
|
|
- if ( (MHD_INVALID_SOCKET != fd) &&
|
|
|
- (0 != MHD_socket_close_ (fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ if (MHD_INVALID_SOCKET != fd)
|
|
|
+ MHD_socket_close_ (fd);
|
|
|
|
|
|
/* TLS clean up */
|
|
|
#if HTTPS_SUPPORT
|
|
|
@@ -5451,23 +5416,21 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
|
|
|
#endif
|
|
|
#ifdef EPOLL_SUPPORT
|
|
|
if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
|
|
|
- (-1 != daemon->epoll_fd) &&
|
|
|
- (0 != MHD_socket_close_ (daemon->epoll_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ (-1 != daemon->epoll_fd) )
|
|
|
+ MHD_socket_close_ (daemon->epoll_fd);
|
|
|
#if HTTPS_SUPPORT
|
|
|
if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
|
|
|
- (-1 != daemon->epoll_upgrade_fd) &&
|
|
|
- (0 != MHD_socket_close_ (daemon->epoll_upgrade_fd)) )
|
|
|
- MHD_PANIC (_("close failed\n"));
|
|
|
+ (-1 != daemon->epoll_upgrade_fd) )
|
|
|
+ MHD_socket_close_ (daemon->epoll_upgrade_fd);
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#ifdef DAUTH_SUPPORT
|
|
|
free (daemon->nnc);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->nnc_lock);
|
|
|
+ MHD_mutex_destroy_ (&daemon->nnc_lock);
|
|
|
#endif
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
- (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex);
|
|
|
+ MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex);
|
|
|
|
|
|
if (MHD_INVALID_PIPE_ != daemon->wpipe[1])
|
|
|
{
|
|
|
@@ -5735,14 +5698,16 @@ gcry_w32_mutex_destroy (void **ppmtx)
|
|
|
static int
|
|
|
gcry_w32_mutex_lock (void **ppmtx)
|
|
|
{
|
|
|
- return (MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1;
|
|
|
+ MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
static int
|
|
|
gcry_w32_mutex_unlock (void **ppmtx)
|
|
|
{
|
|
|
- return (MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1;
|
|
|
+ MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
|