Module: ngircd.git
Branch: master
Commit: cf93881dfbd7b6317d2a41f87e9751b74354203b
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=cf93881d…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Jul 14 10:27:55 2010 +0200
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.
---
src/ngircd/conn.c | 17 +++++++++++++++++
src/ngircd/conn.h | 2 ++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index f059d91..d8df627 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 a63fcbb..a0bddaa 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 ));
Module: ngircd.git
Branch: master
Commit: 9cd3494de92eccaa201f42fc8b02fc68c752aca8
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=9cd3494d…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Jul 13 22:29:06 2010 +0200
Don't Proc_Kill() childs after Proc_Read(): done there already.
---
src/ngircd/irc-login.c | 3 ---
src/ngircd/proc.c | 2 ++
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 8ac5471..93ee07e 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -847,9 +847,6 @@ cb_Read_Auth_Result(int r_fd, UNUSED short events)
if (len == 0)
return;
- /* Make sure authenticator sub-process is dead now ... */
- Proc_Kill(proc);
-
if (len != sizeof(result)) {
Log(LOG_CRIT, "Auth: Got malformed result!");
Reject_Client(client);
diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c
index 11cb039..1e8cac3 100644
--- a/src/ngircd/proc.c
+++ b/src/ngircd/proc.c
@@ -119,6 +119,8 @@ Proc_GenericSignalHandler(int Signal)
/**
* Read bytes from a pipe of a forked child process.
+ * In addition, this function makes sure that the child process is dead
+ * after all data has been read or a fatal error occurred.
*/
GLOBAL size_t
Proc_Read(PROC_STAT *proc, void *buffer, size_t buflen)