From 598a2247c4bfe684213ce3b49efa7c8f25027b19 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 4 Jun 2025 14:25:55 -0400 Subject: [PATCH] Sorting of todo list via sessid is working --- Makefile | 1 + app/sender.c | 3 ++- lib/geseml.c | 42 +++++++++++++++++++++++++++++++++++++++++- lib/geseml.h | 3 +++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0672a92..be040c2 100644 --- 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) diff --git a/app/sender.c b/app/sender.c index 3b677d4..a0b2448 100644 --- a/app/sender.c +++ b/app/sender.c @@ -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 diff --git a/lib/geseml.c b/lib/geseml.c index 4957daa..0c3ef1a 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -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); +} +/* + +*/ +/********************************************************/ +/* */ /* 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; +} diff --git a/lib/geseml.h b/lib/geseml.h index 3c97f42..2b9367c 100644 --- a/lib/geseml.h +++ b/lib/geseml.h @@ -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 -- 2.47.3