From ed83a18ad3c44ee02735fce69c8044c9f96a1ce0 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sat, 13 Jul 2024 03:43:43 -0400 Subject: [PATCH] modrec.c kludge function is exit properly --- lib/modrec.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/modrec.c b/lib/modrec.c index 1a3b3ad..17ce742 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -32,6 +32,10 @@ for (int i=0;i", attend-i,binding->ip,binding->port); (void) sleep(1); + if ((hangup==true)||(reload==true)){ + (void) rou_alert(0,"JMPDBG process terminated"); + break; + } } } /* @@ -102,7 +106,7 @@ while (proceed==true) { */ /********************************************************/ /* */ -/* Procedure to active child process if necessary */ +/* Procedure to activate child process if necessary*/ /* */ /********************************************************/ static void activate(SOCTYP **bindings) @@ -142,6 +146,55 @@ while (proceed==true) { */ /********************************************************/ /* */ +/* Procedure to kill all child process if necessary*/ +/* */ +/********************************************************/ +static void release(SOCTYP **bindings) + +{ +#define OPEP "modrec.c:release" + +int phase; +_Bool proceed; + +phase=0; +proceed=true; +while (proceed==true) { + switch (phase) { + case 0 : //making sur the list is defined + if (bindings==(SOCTYP **)0) { + (void) rou_alert(0,"%s bindings list pointer is NULL (Bug!?)",OPEP); + phase=999; //not going further + } + break; + case 1 : //check need to kill a dispatched process + while (*bindings!=(SOCTYP *)0) { + for (int i=0;i<(*bindings)->iteration;i++) { + if ((*bindings)->childs[i]==(pid_t)0) + continue; + if (prc_checkprocess((*bindings)->childs[i])==true) { + (void) rou_alert(0,"JMPDBG sending a SIGTERM process to '%d'", + (*bindings)->childs[i]); + (void) kill((*bindings)->childs[i],SIGTERM); + (*bindings)->childs[i]=(pid_t)0; + } + } + bindings++; + } + break; + default : //SAFE Guard + proceed=false; + break; + } + phase++; + } +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ /* Waiting and handling smtp request */ /* */ /********************************************************/ @@ -174,7 +227,8 @@ while (proceed==true) { if ((hangup==false)&&(reload==false)) phase--; //normal cycle, lets proceed to actvate again break; - case 3 : //closing all socket openend + case 3 : //closing all socket currently opened + (void) release(bindings); (void) soc_mulclose(bindings); break; default : //SAFE Guard -- 2.47.3