#--------------------------------------------------------------------
#testing feed
FEEDPAR = \
- -d 3 \
+ -d3 \
$(TESTIP) \
$(TESTPORT) \
$(TESTDIR)/$(DATATST)/feed*.tst \
@ bin/feeder $(FEEDPAR)
#using gdb
-gdbfeed : debug
+dbgfeed : debug
@ gdb --args \
bin/feeder $(FEEDPAR)
#starting email receiver
EMLPAR = \
- -r $(TSTDIR) \
- -d 8 \
+ -r $(TESTDIR) \
+ -d8 \
:$(TESTIP):$(TESTPORT) \
emlrcvr : debug newtest
@ echo
@ echo "--------------"
@ echo "starting $@"
- @ bin/$@ $(EMLPAR)
+ @ $(TESTDIR)/$(SBINDIR)/$@ $(EMLPAR)
@ echo "--------------"
-
+
+valrcvr : clean debug newtest #valgrin dest
+ @ echo "emlrec valgrind test"
+ @ valgrind \
+ --leak-check=full \
+ --show-leak-kinds=all \
+ --track-origins=yes \
+ --trace-children=no \
+ --track-fds=yes \
+ $(TESTDIR)/$(SBINDIR)/emlrcvr \
+ -f \
+ $(EMLPAR)
+
+dbgrcvr : clean debug newtest #using gdb
+ @ gdb --args \
+ $(TESTDIR)/$(SBINDIR)/emlrcvr \
+ -f \
+ $(EMLPAR)
+
+#--------------------------------------------------------------------
+#preparing a test area
+newtest : deltest
+#--------------------------------------------------------------------
+#test procedure
+#--------------------------------------------------------------------
+tstspf : clean debug
+ @ shell/test-spf.sh data-tst/spf.tst
+
+#todo a specfic test
+DATA = chkaddr.spf.example.com 127.0.1.255
+
#--------------------------------------------------------------------
#preparing a test area
newtest : deltest
@ mkdir -p $(TESTDIR)/var/spool/clement/{in,out}-logs
@ mkdir -p $(TESTDIR)/$(SBINDIR)
@ cp -a \
- bin/{chkspf,emlrcvr,maild} \
+ bin/{chkspf,emlrcvr} \
$(TESTDIR)/$(SBINDIR)
@ cp -a \
$(DATATST) \
deltest :
@ rm -fr $(TSTDIR)
-#--------------------------------------------------------------------
-#test procedure
-#--------------------------------------------------------------------
-test : clean debug
- @ shell/test-spf.sh data-tst/spf.tst
-
-#todo a specfic test
-DATA = chkaddr.spf.example.com 127.0.1.255
-dbgtst : debug
- @ echo "doing chkspf with \"$(DATA)\""
- @ valgrind \
- --leak-check=full \
- --show-leak-kinds=all \
- ./bin/chkspf $(DATA)
-
#--------------------------------------------------------------------
#Installation procedure
#--------------------------------------------------------------------
#definitions globale
APPNAME = MAILLEUR
#--------------------------------------------------------------------
+#Managing testarea
+SBINDIR = usr/sbin
+CURDIR = `pwd`
+#===================================================================
/* a remote TCP connection. */
/* */
/********************************************************/
-void docontact(SOCPTR *socptr,int pos)
+static void docontact(SOCPTR *socptr,int pos)
{
#define OPEP "modrec.c:contact"
else
proceed=false; //Empty Soc!?!
break;
- case 1 : //check need to dispatch a process
+ case 1 : //empty phase
+ if (foreground==true) {
+ (void) docontact(socptr,1);
+ phase++; //no fork
+ }
+ break;
+ case 2 : //check need to dispatch a process
for (int i=0;i<iterations;i++) {
(void) prc_nozombie();
if (prc_checkprocess(childs[i])==true)
}
if ((hangup==true)||(reload==true))
phase=999;
- break;
- case 2 : //Relax time
(void) sleep(5);
+ break;
+ case 3 : //Relax time
if ((hangup==false)&&(reload==false))
phase=0; //lets continue to check childs
break;
/* Procedure to start a binding+waiting process */
/* */
/********************************************************/
-PUBLIC void startwaiter(SOCPTR *socptr,int offset)
+static void startwaiter(SOCPTR *socptr)
{
#define OPEP "moderec.c:startwaiter"
//(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
switch (phase) {
case 0 : //Opening logs
+ (void) closelog();
(void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
break;
case 1 : //binding on channel
childs[i]=(pid_t)0;
}
break;
- case 2 : //starting/restarting all waiting process
+ case 2 : //starting one process only
+ if (foreground==true) {
+ (void) startwaiter(bindings[0]);
+ phase++; //no multiple fork
+ }
+ break;
+ case 3 : //starting/restarting all waiting process
for (int i=0;i<nbrbind;i++) {
- int offset;
-
- offset=random()%10;
if (childs[i]!=(pid_t)0)
continue;
+ (void) fprintf(stdout,"JMPDBG nbrint='%d' i='%d'\n",nbrbind,i);
childs[i]=fork();
- if (childs[i]==(pid_t)0) {
- (void) closelog();
- (void) startwaiter(bindings[i],offset);
- (void) exit(0);
+ switch (childs[i]) {
+ case -1 : //trouble trouble to fork?
+ (void) rou_alert(0,"%s Unable to fork smtp handler (error=<%s>)",
+ OPEP,strerror(errno));
+ childs[i]=(pid_t)0;
+ (void) sleep(1); //Weathering the storm
+ break;
+ case 0 : //Child process itself
+ (void) startwaiter(bindings[i]);
+ break;
+ default : //Main process
+ (void) usleep(10000);
+ break;
}
- (void) usleep(10000); //avoid avalanche
}
break;
- case 3 : //relax time
+ case 4 : //relax time
(void) sleep(5); //Waiting for signal
if ((hangup==false)&&(reload==false))
phase=0; //Normal process, lets restart
break;
- case 4 : //we got a signal, kill all childs
+ case 5 : //we got a signal, kill all childs
(void) prc_killchilds(childs,nbrbind,10);
break;
default : //SAFE Guard