From 2decc8345d574648ca94efd433223f234ee38f8e Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 22 Jun 2025 09:44:11 -0400 Subject: [PATCH] "sorter" daemon variable sleep delay --- app/sorter.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/sorter.c b/app/sorter.c index c10df39..a05a381 100644 --- a/app/sorter.c +++ b/app/sorter.c @@ -28,16 +28,18 @@ /* procedure to scan all files */ /* */ /********************************************************/ -static void scantrans(const char *ext,_Bool todo) +static _Bool scantrans(const char *ext,_Bool todo) { #define OPEP "sorter.c:scantrans," +_Bool action; char **fname; TRATYP **trans; int phase; _Bool proceed; +action=false; fname=(char **)0; trans=(TRATYP **)0; phase=0; @@ -51,6 +53,7 @@ while (proceed==true) { phase=999; //Nothing to do break; case 1 : //Building the "trans" list + action=true; if (fname!=(char **)0) { //always char **ptr; @@ -87,6 +90,7 @@ while (proceed==true) { phase++; } #undef OPEP +return action; } /* @@ -100,11 +104,15 @@ static void sorting() { #define OPEP "sorter.c:sorting," -#define TSLEEP 20 +#define TSLEEP 10 +_Bool action; +int delay; int phase; _Bool proceed; +action=false; +delay=1; phase=0; proceed=true; while (proceed==true) { @@ -118,23 +126,27 @@ while (proceed==true) { } break; case 1 : //got signal + action=false; if ((hangup==true)||((reload==true))) { (void) rou_alert(0,"%s got hangup or reload signal",OPEP); phase=999; } break; case 2 : //got signal - (void) scantrans(EXTRANS,true); + action|=scantrans(EXTRANS,true); break; case 3 : //got signal - (void) scantrans(EXTRANS,true); + action|=scantrans(EXTRANS,true); break; case 4 : //one passe only? if (foreground==true) phase=999; //Immediate ending break; - case 5 : //lets time pass - (void) sleep(TSLEEP); + case 5 : //lets time pass according "busy" + delay=TSLEEP; + if (action==true) + delay=1; + (void) sleep(delay); phase=0; //Looping break; default : //SAFE Guard -- 2.47.3