]> arthur.barton.de Git - ngircd-alex.git/commitdiff
New function Conn_CloseAllSockets() to close all open sockets
authorAlexander Barton <alex@barton.de>
Wed, 14 Jul 2010 08:27:55 +0000 (10:27 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 14 Jul 2010 08:27:55 +0000 (10:27 +0200)
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.

src/ngircd/conn.c
src/ngircd/conn.h

index f059d917b25f4443f900b6d531a0d7643e2c45de..d8df6274ab7ac376db618a44c6bd77e02d9d8ad4 100644 (file)
@@ -419,6 +419,23 @@ Conn_Exit( void )
 } /* Conn_Exit */
 
 
 } /* 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))
 {
 static unsigned int
 ports_initlisteners(array *a, const char *listen_addr, void (*func)(int,short))
 {
index a63fcbb602ea5f7fe7dd72231538f76346177802..a0bddaac95d090735bf652e3d3829e9436c4a376 100644 (file)
@@ -102,6 +102,8 @@ GLOBAL long WCounter;
 GLOBAL void Conn_Init PARAMS((void ));
 GLOBAL void Conn_Exit PARAMS(( void ));
 
 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 ));
 
 GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
 GLOBAL void Conn_ExitListeners PARAMS(( void ));