about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2010-07-14 10:27:55 +0200
committerAlexander Barton <alex@barton.de>2010-07-14 10:27:55 +0200
commitcf93881dfbd7b6317d2a41f87e9751b74354203b (patch)
tree7a7e5d15915e5d8307a520b5cb94c5ce077e34fb /src
parent560492a4a4bd2182e3eaa32a5d5db7582be97963 (diff)
downloadngircd-cf93881dfbd7b6317d2a41f87e9751b74354203b.tar.gz
ngircd-cf93881dfbd7b6317d2a41f87e9751b74354203b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conn.c17
-rw-r--r--src/ngircd/conn.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index f059d917..d8df6274 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -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))
 {
diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h
index a63fcbb6..a0bddaac 100644
--- a/src/ngircd/conn.h
+++ b/src/ngircd/conn.h
@@ -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 ));