]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Sorting of todo list via sessid is working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 4 Jun 2025 18:25:55 +0000 (14:25 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 4 Jun 2025 18:25:55 +0000 (14:25 -0400)
Makefile
app/sender.c
lib/geseml.c
lib/geseml.h

index 0672a92baa00a220915ac1e965532fa836720020..be040c2ea4f34a599058e00c7c6091bea772da7e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,7 @@ sorter        :  clean debug
                data-$@/*                               \
                $(TESTDIR)/var/spool/$(APPNAME)/queue
           @ bin/sorter                                 \
+                  -f                                   \
                   -d 2                                 \
                   -c ./conf/mailleur.conf.dvl          \
                   -r $(TESTDIR) 
index 3b677d4c66e455592b13a96c1ed1fa86693f6914..a0b2448f5e8440e71c5f69f11d12015ba51b86d0 100644 (file)
@@ -50,9 +50,10 @@ if (tra!=(TRATYP **)0) {
     count++;
     if (((*ptr)->date+(*ptr)->delay)<=isnow) {
       (void) eml_add_delay(isnow,*ptr);
+      (void) rou_alert(0,"%s rcpt email <%s> count='%d' sessid=<%s>",
+                         OPEP,(*ptr)->rcptto,count,(*ptr)->sessid);
       switch ((*ptr)->code) {
         case 'L'  :       //local delivery
-          (void) rou_alert(0,"%s local email count='%d'",OPEP,count);
           (*ptr)->code='C';       //delivery done 'C'ompleted
           if (eml_store_email(*ptr)==false) {
             (*ptr)->code='L';       //delivery done 'D'elayed
index 4957daa5bcc55ad24f85cf134b3a28b9f0cdedbf..0c3ef1a2e8752229f1cd24565dba81a4b295029e 100644 (file)
@@ -28,6 +28,20 @@ typedef struct  {
 */
 /********************************************************/
 /*                                                      */
+/*      Procedure to compare 2 transaction struct       */
+/*                                                      */
+/********************************************************/
+static int cmp_sessid(const void *p1,const void *p2)
+
+
+{
+return strcmp((*((TRATYP **)p1))->sessid,(*((TRATYP **)p2))->sessid);
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
 /*      Procedure to display/debug TRATYP record content*/
 /*                                                      */
 /********************************************************/
@@ -356,8 +370,10 @@ if (domlist!=(REFTYP **)0) {
             phase=999;  //Trouble trouble
           break;
         case 1  :       //dumping TRANS data to file
-          if ((action=eml_dumptra(qfile,(*ptr)->todo))==true)
+          (void) eml_sort_list((*ptr)->todo);
+          if ((action=eml_dumptra(qfile,(*ptr)->todo))==true) {
             ext=EXTODO;
+            }
           break;
         case 2  :       //Closing file
           (void) eml_closeqfile(qfile);
@@ -641,3 +657,27 @@ switch (fork()) {
 return status;
 #undef   OPEP
 }
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to make sure todo list is sorted      */
+/*      according the session id.                       */
+/*                                                      */
+/********************************************************/
+PUBLIC _Bool eml_sort_list(TRATYP **list)
+
+{
+_Bool result;
+
+result=false;
+if (list!=(TRATYP **)0) { 
+  register int num;
+
+  num=rou_nbrlist((void **)list);
+  (void) qsort((void *)list,num,sizeof(TRATYP *),cmp_sessid);
+  result=true;
+  }
+return result;
+}
index 3c97f42e466b139c0dc260545c8eeffca367c9b2..2b9367c7ab736270d77ae598aef0e515d6b9bc8f 100644 (file)
@@ -51,4 +51,7 @@ extern _Bool eml_add_delay(time_t isnow,TRATYP *tra);
 //procedure to fork a process and start the "sender" process
 extern _Bool eml_start_sender(char *todo);
 
+//procedure to sort a transmission list according sessionid
+extern _Bool eml_sort_list(TRATYP **List);
+
 #endif