]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Double connexion is preporly detected
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 10 Aug 2025 11:40:26 +0000 (07:40 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 10 Aug 2025 11:40:26 +0000 (07:40 -0400)
lib/gessql.c

index d2fc1d3b94ec9c9a235f262e51cef191e81a270d..a5aa5e92ad50684a5ef6be9a8282ceaa8b8c3370 100644 (file)
@@ -692,6 +692,7 @@ srv=(SRVTYP *)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
+  (void) rou_alert(0,"%s JMPDBG phase='%d' connect=%d",OPEP,phase,connect);
   switch (phase) {
     case 0      :       //lets lock table access
       if (sql_lock(sqlptr,RMTTBL)==false) {
@@ -700,26 +701,24 @@ while (proceed==true) {
         }
       break;
     case 1      :       //updating remotes record with links
-      if (sql_request(sqlptr,upd,RMTTBL,delta,rmtip)==0
-        phase++;        //Record not existing
+      if (sql_request(sqlptr,upd,RMTTBL,delta,rmtip)==1
+        phase++;        //Record is existing
       break; 
     case 2      :       //Let create a record
       if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
         (void) rou_alert(0,"%s Unable to create entry "
                            "for remote ip <%s> in table <%s> (DB trouble?)",
                             OPEP,rmtip,RMTTBL);
-        phase+=2;
         }
-      break;
-    case 3      :       //Let update the record
-      if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
-        (void) rou_alert(0,"%s Unable to create entry "
-                           "for remote ip <%s> in table <%s> (DB trouble?)",
-                            OPEP,rmtip,RMTTBL);
-        phase++;        //No need to return get the connexion number
+      else {
+        if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
+          (void) rou_alert(0,"%s Unable to create entry "
+                             "for remote ip <%s> in table <%s> (DB trouble?)",
+                              OPEP,rmtip,RMTTBL);
+          }
         }
       break; 
-    case 4      :       //lets find the the number of connection
+    case 3      :       //lets find the the number of connection
       if (sql_mngremote(sqlptr,sql_select,rmtip,&srv)==false) {
         (void) rou_alert(0,"%s Unable to get record "
                            "for remote ip <%s> in table <%s> (DB trouble?)",
@@ -730,7 +729,7 @@ while (proceed==true) {
         srv=sql_freesrv(srv);
         }
       break; 
-    case 5      :       //unlock database
+    case 4      :       //unlock database
       (void) sql_unlock(sqlptr,true);
       break; 
     default     :       //SAFE Guard