New function Conn_CloseAllSockets() to close all open sockets

This is useful in forked child processes, for example, to make sure that
they don't hold connections open that the main process wants to close.
This commit is contained in:
Alexander Barton 2010-07-14 10:27:55 +02:00
parent 560492a4a4
commit cf93881dfb
2 changed files with 19 additions and 0 deletions

View File

@ -419,6 +419,23 @@ Conn_Exit( void )
} /* Conn_Exit */
/**
* Close all sockets (file descriptors) of open connections.
* This is useful in forked child processes, for example, to make sure that
* they don't hold connections open that the main process wants to close.
*/
GLOBAL void
Conn_CloseAllSockets(void)
{
CONN_ID idx;
for(idx = 0; idx < Pool_Size; idx++) {
if(My_Connections[idx].sock > NONE)
close(My_Connections[idx].sock);
}
}
static unsigned int
ports_initlisteners(array *a, const char *listen_addr, void (*func)(int,short))
{

View File

@ -102,6 +102,8 @@ GLOBAL long WCounter;
GLOBAL void Conn_Init PARAMS((void ));
GLOBAL void Conn_Exit PARAMS(( void ));
GLOBAL void Conn_CloseAllSockets PARAMS((void));
GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
GLOBAL void Conn_ExitListeners PARAMS(( void ));