]> SAFE projects GIT repository - jmp/mailleur/commitdiff
"sorter" daemon variable sleep delay
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 13:44:11 +0000 (09:44 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 13:44:11 +0000 (09:44 -0400)
app/sorter.c

index c10df39a66227ef25fcfba8330bd8fd01e6cffb7..a05a381bc7775387ccec7079af0b16068b6d294b 100644 (file)
 /*     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;
 }
 /*
 \f
@@ -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