]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Neww to check pool verssus ppoll and waitchar
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 28 Mar 2025 00:20:54 +0000 (20:20 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 28 Mar 2025 00:20:54 +0000 (20:20 -0400)
Makefile
app/feeder.c
data-tst/feed00.tst
lib/devsoc.c
lib/modrec.c
lib/subrou.c

index 786724cd7050dcc741ccb4a27be4bffe6f517014..f11c1955d1c0f3069a2ebc04cf501f6680f1d94c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ LOCKDIR       =       $(TESTDIR)/var/run/$(APPNAME)
 TESTDIR        =       $(CURDIR)/test_area
 TESTIP =       127.127.10.25
 TESTPORT=      1025
+TESTITER=      3
 #--------------------------------------------------------------------
 #testing feed
 FEEDPAR        =                                               \
@@ -41,10 +42,10 @@ FEEDPAR     =                                               \
 
 onefeed        :       debug
                @ bin/feeder                            \
-                       -d 3                            \
+                       -d                            \
                        $(TESTIP)                       \
                        $(TESTPORT)                     \
-                       $(TESTDIR)/$(DATATST)/feed00.tst
+                       $(DATATST)/feed00.tst
 
 #direct test
 tstfeed        :       debug
@@ -61,14 +62,20 @@ dbgfeed     :       debug
 EMLPAR =                                               \
           -r $(TESTDIR)                                \
           -d 3                                         \
-          :$(TESTIP):$(TESTPORT)                       \
+          :$(TESTIP):$(TESTPORT):
+
+onercvr        :  debug
+          @ echo "starting $@"
+          @ bin/emlrcvr                                \
+               -f                                      \
+               $(EMLPAR)
 
 emlrcvr        :  clean debug newtest          #starting email receiver
           @ echo
           @ echo "--------------"
           @ echo "starting $@"
           @ $(TESTDIR)/$(SBINDIR)/$@                   \
-               $(EMLPAR) 
+               $(EMLPAR)$(TESTITER)
           @ echo "--------------"
 
 valrcvr        :  clean debug newtest          #valgring of emlrcvr
@@ -84,9 +91,9 @@ valrcvr       :  clean debug newtest          #valgring of emlrcvr
 #              --track-origins=yes                     \
 #              --trace-children=no                     \
 
-dbgrcvr        :  clean debug newtest          #debugging emlrcvr
+dbgrcvr        :  debug                        #debugging emlrcvr
           @ gdb --args                                 \
-               $(TESTDIR)/$(SBINDIR)/emlrcvr           \
+               bin/emlrcvr                             \
                -f                                      \
                $(EMLPAR) 
 
index 06287c23b28b5b88d15d43fbd1aaced618efb0fb..bdd8a5f72bb977e008a56d17ccf56ee8f37f7c86 100644 (file)
@@ -49,34 +49,131 @@ static void usage(const char *name)
 */
 /********************************************************/
 /*                                                     */
-/*     Scanning one line from test file                */
+/*     Reporting a problem with parsing test           */
+/*                                                     */
+/********************************************************/
+static void report(int numline,char *line,char *trouble)
+
+
+{
+(void) fprintf(stdout,"line %d %s\n",numline,trouble);
+(void) fprintf(stdout,"\t'%s'\n",line);
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to send a line to remote              */
+/*                                                     */
+/********************************************************/
+static void dooutgoing(SOCPTR *socptr,char *line)
+
+{
+(void) soc_writebuffer(socptr,line,strlen(line));
+(void) soc_writebuffer(socptr,"\r\n",2);
+(void) fprintf(stdout,"JMPDBG sending <%s>\n",line);
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Procedure to compare incoming data with expected*/
 /*                                                     */
 /********************************************************/
-static _Bool scanline(SOCPTR *socptr,char *line)
+static _Bool doincoming(SOCPTR *socptr,int numline,char *line)
 
 {
+#define OPEP    "tstfeed.c:doincoming"
 _Bool status;
+char *received;
+TIMESPEC attend;
 int phase;
 _Bool proceed;
 
 status=false;
+received=(char *)0;
+attend.tv_sec=2;
+attend.tv_nsec=0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  (void) fprintf(stdout,"JMPDBG %s, phase='%d'\n",OPEP,phase);
+  switch (phase) {
+    case 0      :       //check for character
+      switch (soc_waitforchar(socptr,&attend)) {
+        case -1 :
+          (void) fprintf(stdout,"JMPDBG wait =-1\n");
+          phase=999;
+          break;
+        case 0  :
+          (void) fprintf(stdout,"JMPDBG wait =0\n");
+          phase=999;
+          break;
+        default :
+          break;
+        }
+      break;
+    case 1      :       //get available character
+      break;
+    case 2      :       //get avail character
+      if (soc_getnextline(socptr,&received)>0) {
+        (void) fprintf(stdout,"Remote say <%s>\n",received);
+        received=rou_freestr(received);
+        status=true;
+        }
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*     Scanning one line from test file                */
+/*                                                     */
+/********************************************************/
+static _Bool scanline(SOCPTR *socptr,int numline,char *line)
+
+{
+_Bool status;
+int phase;
+_Bool proceed;
+
+status=true;
 phase=0;
 proceed=true;
+//(void) fprintf(stdout,"JMPDBG phase='%d' line=<%s>\n",phase,line);
 while (proceed==true) {
-  //(void) fprintf(stdout,"JMPDBG scanline phase='%d'\n",phase);
   switch (phase) {
     case 0      :       //removing first space
       while ((line[0]==' ')||(line[0]=='\t'))
         (void) memmove(line,line+1,(strlen(line+1)+1));
       break;
     case 1      :       //discarding comment
-      if (line[0]=='#') {
-        status=true;
-        phase=999;      //line is a comment no need to go further
+      switch (line[0]) {
+        case '#'        :       //line is comment
+          break;
+        case '<'        :       //incoming expected
+          status=doincoming(socptr,numline,line);
+          break;
+        case '>'        :       //incoming expected
+          (void) dooutgoing(socptr,line+1);
+          break;
+        default         :       //Unexpected
+          line[1]='\000';
+          (void) report(numline,line,"unexpected directive");
+          status=false;
+          break;
         }
       break;
-    case 2      :       //checking line
-      break;
     default     :       //SAFE Guard
       proceed=false;
       break;
@@ -98,12 +195,15 @@ static _Bool scanonefile(SOCPTR *socptr,const char *filename)
 {
 _Bool status;
 FILE *fichier;
+int numline;
 char line[200];
 int phase;
 _Bool proceed;
 
 status=false;
 fichier=(FILE *)0;
+numline=0;
+(void) strcpy(line,"");
 phase=0;
 proceed=true;
 while (proceed==true) {
@@ -119,7 +219,12 @@ while (proceed==true) {
       break;
     case 1      :       //reading line;
       while (fgets(line,sizeof(line),fichier)!=(char *)0) {
-        if (scanline(socptr,line)==false) {
+        char *ptr;
+
+        numline++;
+        while ((ptr=strrchr(line,'\n'))!=(char *)0)
+          *ptr='\000';
+        if (scanline(socptr,numline,line)==false) {
           phase=999;    //Trouble trouble exiting
           break;
           }
@@ -204,6 +309,7 @@ _Bool proceed;
 
 status=0;
 params=(ARGTYP *)0;
+foreground=true;
 numfile=0;
 phase=0;
 proceed=true;
index f425c269a172ef7e41445ee6e18c71bad314ae6c..cbf95ed2ddf20159ddf953e588a9efe367f8abe5 100644 (file)
@@ -1 +1,11 @@
 #basic test to feed SMTP server
+#Please update /etc/hosts with
+#127.127.10.25         emlrcvr
+##to have proper reverss-address within test
+# # comment
+# < incoming data
+# > outgoing data
+>
+<test test test
+>quit
+<test test test
index fc54b7d61dcfc4dd1b93d80d6af45387807ce151..8df1ae7754c0ebd1316f1995e36099d0badf4ef8 100644 (file)
@@ -337,7 +337,6 @@ while (proceed==true) {
   switch (phase) {
     case 0      :       //First prepare a new socket
       newsoc=dupsocket(soc);
-      soc->handle=-1;   //handle within sock not open
       if (openplain(newsoc)==false) 
                         //received a termination signal
         phase=999;      //return a null socket
@@ -816,6 +815,7 @@ soc=(SOCTYP *)socptr;
 phase=0;
 proceed=true;
 while (proceed==true) {
+  //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
   switch (phase) {
     case 0      :       //sanity check
       if (soc==(SOCTYP *)0) {
@@ -864,7 +864,7 @@ soc=(SOCTYP *)socptr;
 if (soc!=(SOCTYP *)0) {      
   struct pollfd polling[1];
 
-  polling[0].events=POLLIN|POLLPRI|POLLERR|POLLHUP;
+  polling[0].events=POLLIN|POLLPRI|POLLHUP;
   polling[0].revents=(short)0;
   switch (soc->modtls) {
     case true   :
@@ -934,6 +934,7 @@ while (proceed==true) {
         phase=999;      //no need to go further
         }
     case 1      :       //Do we have char available in carpile
+      (void) soc_receive(socptr);
       if (soc->carin==0)
         phase=999;      //No char,no need to check for line
       break;
index fe5233725b678bc731972c8bbc2ceabfc992298e..ab63cc2ac038f808a385e5991b71255975bec846 100644 (file)
@@ -357,9 +357,10 @@ while (proceed==true) {
         }
       break;
     case 4      :       //relax time
-      (void) sleep(2);
       if ((hangup==false)&&(reload==false))
         phase=0;        //Normal process, lets restart
+      else
+        (void) usleep(10000);
       break;
     case 5      :       //we got a signal, kill all childs
       (void) prc_killchilds(childs,nbrbind,10);
index 1ccf2eb5888ef508ce5f46b18c07e9b6f7e7a14a..1a34411d166036ee268733c70a1109d47ea0a972 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.6"
-#define RELEASE "20"
+#define RELEASE "21"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level