]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adjusting locking within sorter
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 12:55:41 +0000 (08:55 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 22 Jun 2025 12:55:41 +0000 (08:55 -0400)
app/sorter.c

index 8c6ecfda3c899bd593533a5d2c280ec5950cedd0..4938bc8610058b79ccb6745fd7992b637e431357 100644 (file)
 #include       "unisig.h"
 #include       "geseml.h"
 
-/*
-\f
-*/
-/********************************************************/
-/*                                                     */
-/*     Procedure to lock application if NOT in         */
-/*      foreground mode.                                */
-/*                                                     */
-/********************************************************/
-static void dolockunlock(_Bool locking)
-
-{
-if (foreground==false) {
-  if (prc_locking(appname,true,5)==false) {
-    switch (locking) {
-      case true   :
-        (void) rou_alert(0,"Unable to LOCK %s usage (system?)",appname);
-        break;
-      case false   :
-        (void) rou_alert(0,"Unable to UNLOCK %s usage (system?)",appname);
-        break;
-      }
-    }
-  }
-}
 /*
 \f
 */
@@ -129,6 +104,7 @@ int main(int argc,char *argv[])
 {
 #define OPEP    "sorter.c:main,"
 #define TSLEEP  5
+#define PREST   10
 
 int status;
 ARGTYP *params;
@@ -154,16 +130,20 @@ while (proceed==true) {
       (void) sig_modeunisig(true);
       (void) sig_trapsignal(true,sig_alrm);
       (void) rou_loadconfig(config,true);
-      (void) dolockunlock(false);
       break;
     case 2      :       //checking if we need to go background
       if (foreground==false) {
         if (prc_divedivedive()!=0)
           phase=999;    //direct exit
         }
+    case 3      :       //checking if we need to go background
+      if (prc_locking(appname,true,5)==false)
+        phase=999;      //Trouble trouble
       break;
-    case 3      :       //check about signal process
-      (void) sleep(TSLEEP);
+    case PREST+1:       //restart phase
+      //NO BREAK, NO BREAK
+    case 4      :       //check about signal process
+      phase=4;          //reset phase
       if (hangup==true) {
         (void) rou_alert(0,"%s got hangup signal",OPEP);
         phase=999;      //exiting loop
@@ -173,18 +153,19 @@ while (proceed==true) {
         phase=999;      //exiting loop
         }
       break;
-    case 4      :       //Scanning all ".trans" file             
+    case 5      :       //Scanning all ".trans" file             
       (void) scantrans(EXTRANS,true);
       break;
-    case 5      :       //Scanning all ".done" file             
+    case 6      :       //Scanning all ".done" file             
       (void) scantrans(EXDONE,false);
       break;
-    case 6      :       //one shot deal??
+    case 7      :       //one shot deal??
+      (void) sleep(TSLEEP);
       if (foreground==false)
-        phase=2;       //restarting
+        phase=PREST;       //restarting
       break;
     default     :       //end of task
-      (void) dolockunlock(false);
+      (void) prc_locking(appname,false,1);
       params=par_freeparams(params);
       (void) rou_loadconfig(config,false);
       (void) sig_trapsignal(false,sig_alrm);