]> SAFE projects GIT repository - jmp/mailleur/commitdiff
sending data in batch seems to be working (no memory leak)
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 15 Jun 2025 15:54:37 +0000 (11:54 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 15 Jun 2025 15:54:37 +0000 (11:54 -0400)
Makefile
app/sender.c
lib/geseml.c
lib/geseml.h
lib/lvleml.c
lib/unisig.c
lib/unitls.c

index c0fb686c96b31732bdb3c7c1cc2244bd4efb10b8..156a2b902d904bcd26503f7051f43b647e374c7e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -154,7 +154,7 @@ dbgsend     :  clean debug
 
 #--------------------------------------------------------------------
 #testing feed
-ONEFEED=feed01.tst
+ONEFEED=feed03.tst
 
 FEEDPAR        =                                               \
                $(TESTIP)                               \
index fcc457e80cf74e34465a1e9778e6ff8bbf048a96..58910698cc3ac1f6b019a7e8cb64fe3a68fb94ef 100644 (file)
@@ -108,6 +108,8 @@ while (proceed==true) {
       break;
     case 3      :       //dispatching email
       if (dispatcher(tra)==false) {       //trouble backtracking file
+        (void) rou_alert(0,"%s JMPDBG <%s> dispatcher FALSE (Bug?)",OPEP,fname); 
+    
         (void)eml_renameqfile(fname,EXDOING,EXTODO);
         phase=999;      //No need to go further
         }
@@ -121,6 +123,7 @@ while (proceed==true) {
       break;
     case 5      :       //updating transfile 
       (void) eml_dump_list_tra(qfile,tra);
+      tra=(TRATYP **)rou_freelist((void **)tra,(genfree_t)eml_freetra);
       break;
     case 6      :       //closing file
       qfile=eml_closeqfile(qfile);
@@ -135,6 +138,7 @@ while (proceed==true) {
       status=true;
       break;
     default     :       //SAFE Guard
+      //tra=(TRATYP **)rou_freelist((void **)tra,(genfree_t)eml_freetra);
       qfile=eml_closeqfile(qfile);
       proceed=false;
       break;
index 0a72ace15e55a5700f86a1fdc8657c68ada7df73..ddce47801f01c828572a922b12c25f60f715e1e7 100644 (file)
@@ -277,6 +277,28 @@ return tra;
 */
 /********************************************************/
 /*                                                      */
+/*      Procedure to duplcate an resp list within a tra */
+/*      record.                                         */
+/*                                                      */
+/********************************************************/
+PUBLIC void eml_duptra_resp(TRATYP *tra,char **resp)
+
+{
+if (tra!=(TRATYP *)0) {
+  (void) eml_freetra_resp(tra);
+  if (resp!=(char **)0) {
+    while (*resp!=(char *)0) {
+      tra->resp=(char **)rou_addlist((void **)tra->resp,strdup(*resp));
+      resp++;
+      }
+    } 
+  }
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
 /*      Procedure to duplicate TRATYP structure         */
 /*                                                      */
 /********************************************************/
index 31d1be4863eca4dc3337aeb57b9cf5ac98526662..df3206ec620d9d8d0fc1d37e4ae56d3dfaca8462 100644 (file)
@@ -30,9 +30,12 @@ extern _Bool eml_dump_one_tra(FILE *out,TRATYP *tra);
 //procedure to dump a list of transfert record 
 extern _Bool eml_dump_list_tra(FILE *out,TRATYP **tra);
 
-//procedure to fee memory used by the resp rercord within TRATYP structure
+//procedure to fee memory used by the resp record within TRATYP structure
 extern void eml_freetra_resp(TRATYP *tra);
 
+//procedure to fee memory used to duplicate a resp list to tra resp
+extern void eml_duptra_resp(TRATYP *tra,char **resp);
+
 //procedure to fee memory used by a TRATYP structure
 extern TRATYP *eml_freetra(TRATYP *tra);
 
index d09bd7fcf15307eefbf3091017bbe2a417f47833..63ff4fcb935c5bcab76e94e6c9523767d13b9c3f 100644 (file)
@@ -1059,23 +1059,29 @@ return rmt;
 static _Bool reset_mx(RMTTYP *rmt)
 
 {
+#define OPEP    "lvleml.c:reset_mx,"
+
 _Bool ok;
-int phase;
-_Bool proceed;
+int rspcode;
+char **resp;
 
 ok=false;
-phase=0;
-proceed=true;
-while (proceed==true) {
-  switch (phase) {
-      break;
-    default     :       //SAFE Guard
-      proceed=false;
-      break;
-    }
-  phase++;
+resp=(char **)0;
+rspcode=tcp_smtp_command(rmt,&resp,"RSET");
+switch (rspcode) {
+  case CMDOK    :       //Everythin fine
+    ok=true;
+    break;
+  default       :
+    (void) rou_alert(0,"%s Unexpected code='%d' (Code?)",OPEP,rspcode);
+    for (int i=0;resp[i]!=(char *)0;i++)
+      (void) rou_alert(0,"%s resp[%d]=<%s>",OPEP,i,resp[i]);
+    break;
   }
+resp=(char **)rou_freelist((void **)resp,(genfree_t)rou_freestr);
 return ok;
+
+#undef  OPEP
 }
 /*
 ^L
@@ -1094,12 +1100,14 @@ int rspcode;
 int sent;
 TIMESPEC start;
 char *sessid;
+char **resp;
 int phase;
 _Bool proceed;
 
 rspcode=0;
 sent=0;
 sessid=(*tosend)->sessid;
+resp=(char **)0;
 phase=0;
 proceed=true;
 (void) clock_gettime(CLOCK_REALTIME,&start);
@@ -1122,7 +1130,7 @@ while (proceed==true) {
       break;
     case 2      :       //send the text termination
       (void) tcp_write(rmt->socptr,".");
-      rspcode= tcp_get_smtp_reply(rmt,WAITRMT,(char ***)0);
+      rspcode= tcp_get_smtp_reply(rmt,WAITRMT,&resp);
       break;
     case 3      :       //sending session data
       const char *fmt;
@@ -1151,6 +1159,7 @@ while (proceed==true) {
 
       dest=tosend;
       while (*dest!=(TRATYP *)0) {
+        (void) eml_duptra_resp(*dest,resp);
         switch ((*dest)->sendcode) {
           case CMDOK    :
             if (rspcode==CMDOK) {
@@ -1174,6 +1183,7 @@ while (proceed==true) {
     }
   phase++;
   }
+resp=(char **)rou_freelist((void **)resp,(genfree_t)rou_freestr);
 #undef  OPEP
 }
 /*
@@ -1763,6 +1773,7 @@ while (proceed==true) {
         *ptr='\000';
       (void) snprintf(cmt,sizeof(cmt),"main-session-id=%s",mainsesid);
       logptr=log_openlog(mainsesid,false,cmt);
+      mainsesid=rou_freestr(mainsesid);
       break;
     case 3      :       //sending all email within transaction
       (void) sending_email(logptr,tra);  
index 79bb4abba593fd2da04927bc7155e1ba1eaf7a01..3a9091505cea025ccd08d81025a6d2aad0b34839 100644 (file)
@@ -123,6 +123,7 @@ switch (sig)
                         APPNAME,debug);
     break;
   case SIGPIPE         :
+    (void) rou_alert(0,"%s JMPDBG got SIGPIPE",APPNAME);
     break;
   default              :
     (void) rou_alert(0,"Unexpected Signal [%d]/<%s> received",
@@ -185,8 +186,8 @@ if (onoff==true) {
   (void) sigaction(SIGQUIT,newsa,olds[4]);
   (void) sigaction(SIGHUP,newsa,olds[5]);
   (void) sigaction(SIGALRM,newsa,olds[6]);
-  (void) sigaction(SIGPIPE,newsa,olds[7]);
-  (void) sigaction(SIGCHLD,newsa,olds[8]);
+  (void) sigaction(SIGCHLD,newsa,olds[7]);
+  (void) sigaction(SIGPIPE,newsa,olds[8]);
   (void) free(newsa);
   if ((sfd=signalfd(-1, &mask, 0))<0) {
     (void) rou_alert(0,"%s Unable to set signalfd (error=<%s>)",
@@ -196,8 +197,8 @@ if (onoff==true) {
 else {
   int i;
 
-  (void) sigaction(SIGCHLD,olds[8],(struct sigaction *)0);
-  (void) sigaction(SIGPIPE,olds[7],(struct sigaction *)0);
+  (void) sigaction(SIGPIPE,olds[8],(struct sigaction *)0);
+  (void) sigaction(SIGCHLD,olds[7],(struct sigaction *)0);
   (void) sigaction(SIGALRM,olds[6],(struct sigaction *)0);
   (void) sigaction(SIGHUP,olds[5],(struct sigaction *)0);
   (void) sigaction(SIGQUIT,olds[4],(struct sigaction *)0);
index 5ed63492a47217d3297605695735a87be33061cd..c2cd20d13675d27714b0d247093af20126b48e01 100644 (file)
@@ -13,6 +13,7 @@
 #include        <sys/socket.h>
 #include        <netdb.h>
 #include        <poll.h>
+#include        <signal.h>
 #include        <stdio.h>
 #include        <unistd.h>
 
@@ -784,10 +785,16 @@ while (proceed==true) {
         }
       break;
     case 1      :       //set certificate
+      //valgrind is trapping SIGPIPE and stop
+      struct sigaction oldsa;
+
+      (void) sigaction(SIGPIPE,(struct sigaction *)0,&oldsa);
+      (void) signal(SIGPIPE, SIG_IGN);
       status=SSL_shutdown(tls->ssl);
       if (status<0)
         (void) rou_alert(0,"%s, Link with [%s], ssl_shutdown status='%d'",
                             OPEP,tls->peerip,status);
+      (void) sigaction(SIGPIPE,&oldsa,(struct sigaction *)0);
       break;
     default     :       //SAFE guard
       tls=freetls(tls);