$(TESTPORT) \
$(TESTDIR)/$(DATATST)/feed*.tst \
-onefeed : debug
+onefeed :
@ bin/feeder \
-d3 \
$(TESTIP) \
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
#include <unistd.h>
#include "subrou.h"
_Bool status;
char *received;
-TIMESPEC attend;
int phase;
_Bool proceed;
status=false;
received=(char *)0;
-attend.tv_sec=WAITLINE;
-attend.tv_nsec=0;
phase=0;
proceed=true;
while (proceed==true) {
- (void) fprintf(stdout,"JMPDBG %s, phase='%d'\n",OPEP,phase);
+ //(void) fprintf(stdout,"JMPDBG %s, phase='%d'\n",OPEP,phase);
switch (phase) {
case 0 : //waiting for a line with CRLF
- if (tcp_getline(socptr,&attend,&received)==0) {
+ if (tcp_getline(socptr,WAITLINE,&received)==0) {
(void) fprintf(stdout,"Unable to receive line in due time\n");
phase=999; //No need to go further
}
}
break;
case 2 : //opening remote channel
+ (void) openlog("feeder",LOG_NDELAY|LOG_PID,LOG_DAEMON);
numfile=scanallfiles(params->argc,params->argv);
if (numfile==(params->argc-2))
(void) fprintf(stdout,"%d file successfully transmitted to <%s.%s>\n",
numfile,params->argv[0],params->argv[1]);
+ (void) closelog();
break;
default : //end of task
params=par_freeparams(params);
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <string.h>
#include <unistd.h>
handle=-1;
slg.l_onoff=true;
-slg.l_linger=0; /*0 sec timeout on close*/
+slg.l_linger=2; /*0 sec timeout on close*/
reuse=1;
phase=0;
proceed=true;
/* socket, waiting up to attend second. */
/* */
/********************************************************/
-PUBLIC int soc_waitforchar(SOCPTR *socptr,TIMESPEC *attend)
+PUBLIC int soc_waitforchar(SOCPTR *socptr,u_long microsec)
{
#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];
polling[0].fd=soc->handle;
break;
}
-
- status=ppoll(polling,1,attend,(sigset_t *)0);
+ (void) sigprocmask(SIG_SETMASK,(sigset_t *)0,&origmask);
+ status=poll(polling,1,timeout);
+ (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",OPEP);
break;
case 1 :
if ((polling[0].revents&POLLHUP)==POLLHUP) {
(void) rou_alert(0,"%s JMPDBG connection reset by peer",OPEP);
break;
default :
+ foreground=false; //JMPDBG?
(void) rou_alert(0,"%s Unexpected error=%d <%s> (Bug)",
OPEP,errno,strerror(errno));
+ (void) exit(1); //JMPDBG!
break;
}
break;
extern void soc_closebinding(SOCPTR *socptr);
//procedure to wait for character from contact
-extern int soc_waitforchar(SOCPTR *socptr,TIMESPEC *attend);
+extern int soc_waitforchar(SOCPTR *socptr,u_long microsec);
//procedure to return a char array with the available line
extern int soc_getnextline(SOCPTR *socptr,char **lineptr);
/* for a CRLF AS EOL. */
/* */
/********************************************************/
-PUBLIC int tcp_getline(SOCPTR *socptr,TIMESPEC *attend,char **lineptr)
+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) {
if ((got=soc_getnextline(socptr,lineptr))>0)
phase=999; //we got a line.
break;
- case 2 : //waiting for new character presence
- got=soc_waitforchar(socptr,attend);
+ 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);
switch (got) {
case -1 : //trouble? signal?
if ((hangup==true)||(reload==true))
phase=999; //we got a real signal
break; //no need to read line
case 0 : //normal time out
- phase=999; //no need to go further, no need to read line
- (void) rou_alert(0,"%s JMPDBG no char? sec='%d', nsec='%d'",
- OPEP,attend->tv_sec,attend->tv_nsec);
- if ((attend->tv_sec>0)||(attend->tv_nsec>0))
- phase=0; //waiting for a full line
+ phase=0; //still waiting for a full line
break;
default : //char available
phase=0; //check for new line
#define WAITLINE 10 //full line waiting time
//read a line from contact up to CRLF
-extern int tcp_getline(SOCPTR *socptr,TIMESPEC *attend,char **lineptr);
+extern int tcp_getline(SOCPTR *socptr,u_int secwait,char **lineptr);
//Transmit formated data to the contact channel
extern int tcp_write(SOCPTR *socptr,char *buffer,int tosend);
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include "subrou.h"
#include "unieml.h"
(void) signon(contact);
while (proceed==true) {
char *line;
- TIMESPEC attend;
- attend.tv_sec=delay;
- attend.tv_nsec=0;
- status=tcp_getline(contact->socptr,&attend,&line);
+ status=tcp_getline(contact->socptr,delay,&line);
//(void) rou_alert(0,"%s, JMPDBG tcp_getline status='%d'",OPEP,status);
if (status<=0) { //timeout or trouble?
(void) log_fprintlog(contact->logptr,false,"%s","Lost contact with remote");
proceed=doehlo(contact,line);
break;
case c_quit : //QUIT SMTP protocol
- (void) transmit(contact,"%d 2.0.0 Bye, closing connection %s",
+ //(void) rou_alert(0,"%s JMPDBG sleep started",OPEP);
+ (void) transmit(contact,"%d 2.0.0 Bye, closing connection %s",
QUITOK,contact->mainsesid);
+ //(void) rou_alert(0,"%s JMPDBG Bye transmitted",OPEP);
proceed=false;
break;
case c_mail : //MAIL FROM: checking originator
//version definition
#define VERSION "0.6"
-#define RELEASE "22"
+#define RELEASE "23"
//Public variables
PUBLIC int debug=0; //debug level