]> SAFE projects GIT repository - jmp/mailleur/commitdiff
TRying to improve contact credit management
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 6 Aug 2025 18:15:21 +0000 (14:15 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 6 Aug 2025 18:15:21 +0000 (14:15 -0400)
app/feeder.c
lib/lvleml.c
lib/modrec.c

index 2aaf7fc2579c78a0c8d8072625526b35ac887c42..48f60db0583c14600dabbef43395e69420dcb2dc 100644 (file)
@@ -24,7 +24,7 @@
 
 #define FNAME   "feeder"
 
-#define        WRESP   5               //wait 5 sec for SMTP server
+#define        WRESP   30              //wait 30 sec for SMTP server
                                 //to answer
 
 static  char titre[100];        //test title
index 51423149914ba6d58b7b798bbc3be450f2bc3cde..4d5963d200213afa4c41f97e19b8a540493245ca 100644 (file)
@@ -1619,6 +1619,7 @@ while (proceed==true) {
           break;
         case rel_plain          :       //remote IP is plain
           if ((status=checkcredit(contact))!=CMDOK) {
+            contact->credit=-1;         //found bad guy.
             (void) transmit(contact,true,"%d 5.5.4 Closing connection",status);
             phase=999;      //bad credit not need to go further
             }
@@ -2383,7 +2384,8 @@ while (proceed==true) {
 /*         0 contact timeout                            */
 /*        -1 signal received                            */
 /*        -2 remote disconnected                        */
-/*        -3 BUG!                                       */
+/*        -3 Multiple remote connection                 */
+/*        -4 BUG!                                       */
 /*                                                      */
 /********************************************************/
 PUBLIC int eml_docontact(CONTYP *contact)
index a99dbcfb8655ebc0cd000f2c9eb490ba62cbf2be..fcb045ac5386660c47491899a4123115d2993bd3 100644 (file)
@@ -178,18 +178,16 @@ while (proceed==true) {
       if ((contact=eml_getcontact(socptr,pos))==(CONTYP *)0)
         phase=999;      //No contact!
       break;
-    case 1      :       //within forked process
-      (void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]",
-                           appname,contact->peerip,
-                           contact->locname,contact->locserv);
-      break;
-    case 2      :       //check if remote link is acceptable
+    case 1      :       //check if remote link is acceptable
       if (sql_newconnect(contact->sqlptr,contact->peerip,1)==false) {
         contact->credit-=1;
-        phase=999;      //connection rejected
+        phase++;        //connection rejected
         }
       break;
-    case 3      :       //do contact
+    case 2      :       //do contact
+      (void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]",
+                           appname,contact->peerip,
+                           contact->locname,contact->locserv);
       intstat=eml_docontact(contact);
       switch (intstat) {
         case  1 :       //command 'quit' recieved
@@ -208,19 +206,24 @@ while (proceed==true) {
           break;
         }
       break;
-    case 4      :       //connection terminated
+    case 3      :   {   //connection terminated
+      static const char *cmt;
+      SRVTYP *srv;
+      int total;
+
+      cmt="(Contact terminated, credit='%3d/%3d' condition=<%s>)";
+      total=0;
+      if (sql_mngremote(contact->sqlptr,sql_select,contact->peerip,&srv)==true) {
+        total=srv->credit;
+        srv=sql_freesrv(srv);
+        }
+      (void) log_fprintlog(contact->logptr,true,cmt,contact->credit,total,
+                                                    contact->termend);
+      (void) sql_newconnect(contact->sqlptr,contact->peerip,-1);
+      contact=eml_dropcontact(contact);
+      }
       break;
     default     :       //SAFE guard
-      if (contact!=(CONTYP *)0) {
-        static const char *cmt;
-  
-        cmt="(Contact terminated, credit='%d' condition=<%s>)";
-        (void) log_fprintlog(contact->logptr,true,cmt,
-                                                  contact->credit,
-                                                  contact->termend);
-        (void) sql_newconnect(contact->sqlptr,contact->peerip,-1);
-        contact=eml_dropcontact(contact);
-        }
       proceed=false;
       break;
     }