From 2cfcbe44e7e07c475c95f3960f7cae7c3b7ae4fa Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 30 Mar 2025 14:04:27 -0400 Subject: [PATCH] Set waitforchar in millsec --- lib/devsoc.c | 9 ++++----- lib/devsoc.h | 2 +- lib/gestcp.c | 10 ++-------- lib/subrou.c | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/devsoc.c b/lib/devsoc.c index 0c1eaf8..2e81c09 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -856,17 +856,15 @@ while (proceed==true) { /* socket, waiting up to attend second. */ /* */ /********************************************************/ -PUBLIC int soc_waitforchar(SOCPTR *socptr,u_long microsec) +PUBLIC int soc_waitforchar(SOCPTR *socptr,u_int millisec) { #define OPEP "devsoc.c:soc_waitforchar" register int status; -int timeout; sigset_t origmask; SOCTYP *soc; status=-1; -timeout=microsec/1000; //From microsec to millisec soc=(SOCTYP *)socptr; if (soc!=(SOCTYP *)0) { struct pollfd polling[1]; @@ -882,16 +880,17 @@ if (soc!=(SOCTYP *)0) { break; } (void) sigprocmask(SIG_SETMASK,(sigset_t *)0,&origmask); - status=poll(polling,1,timeout); + status=poll(polling,1,millisec); (void) sigprocmask(SIG_SETMASK,&origmask,(sigset_t *)0); switch (status) { case -1 : (void) rou_alert(0,"%s Polling error (error=<%s>)",OPEP,strerror(errno)); break; case 0 : - //(void) rou_alert(0,"%s Polling timeout",OPEP); + (void) rou_alert(0,"%s Polling timeout millisec='%d'",OPEP,millisec); break; case 1 : + (void) rou_alert(0,"%s Polling return millisec='%d'",OPEP,millisec); if ((polling[0].revents&POLLHUP)==POLLHUP) { (void) close(soc->handle); soc->handle=-1; diff --git a/lib/devsoc.h b/lib/devsoc.h index a33cbcc..01643e3 100644 --- a/lib/devsoc.h +++ b/lib/devsoc.h @@ -55,7 +55,7 @@ extern _Bool soc_openbinding(SOCPTR *socptr); extern void soc_closebinding(SOCPTR *socptr); //procedure to wait for character from contact -extern int soc_waitforchar(SOCPTR *socptr,u_long microsec); +extern int soc_waitforchar(SOCPTR *socptr,u_int millisec); //procedure to return a char array with the available line extern int soc_getnextline(SOCPTR *socptr,char **lineptr); diff --git a/lib/gestcp.c b/lib/gestcp.c index d8081fe..20f7a7c 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -35,12 +35,10 @@ PUBLIC int tcp_getline(SOCPTR *socptr,u_int secwait,char **lineptr) #define OPEP "gestcp.c:tcp_getline" int got; -u_long milliwait; int phase; _Bool proceed; got=0; -milliwait=secwait*100; //10 msec increment phase=0; proceed=true; while (proceed==true) { @@ -57,13 +55,9 @@ while (proceed==true) { phase=999; //we got a line. break; case 2 : //still need to wait - //(void) rou_alert(0,"%s JMPDBG milliwait='%d'",OPEP,milliwait); - if (milliwait==0) //waiting time expired? - phase=999; - milliwait--; break; - case 3 : //lets wait 10 ms for input - got=soc_waitforchar(socptr,10000); + case 3 : //lets wait secwait*1000 millisec for input + got=soc_waitforchar(socptr,secwait*1000); switch (got) { case -1 : //trouble? signal? if ((hangup==true)||(reload==true)) diff --git a/lib/subrou.c b/lib/subrou.c index 6224b1a..3e0e566 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.6" -#define RELEASE "26" +#define RELEASE "27" //Public variables PUBLIC int debug=0; //debug level -- 2.47.3