From: Jean-Marc Pigeon (Delson) Date: Wed, 31 Jul 2024 13:50:07 +0000 (-0400) Subject: Very strange about TIME_WAIT.... X-Git-Tag: tag-0.4~39 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=aaf025654d312fec34451570e96f491dcf359403;p=jmp%2Fmailleur Very strange about TIME_WAIT.... --- diff --git a/kleenex/server.c b/kleenex/server.c index b94e359..5acd992 100644 --- a/kleenex/server.c +++ b/kleenex/server.c @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) { if (pid == 0) { // Child process handles client - close(server_fd); + //close(server_fd); // Receive data then send response receiveAndRespond(client_fd); diff --git a/lib/gestcp.c b/lib/gestcp.c index fcbf648..f1d9b04 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -124,15 +124,17 @@ while (proceed==true) { if (shutdown(contact->channel,SHUT_RDWR)<0) { switch (errno) { case ENOTCONN : //already disconnect by other side! + (void) rou_alert(0,"%s Already disconnected (errno=<%s>)", + OPEP,strerror(errno)); break; default : (void) rou_alert(0,"%s unable to shutdown (errno=<%s>)", - OPEP,strerror(errno)); + OPEP,strerror(errno)); break; } } (void) usleep(10000); - //(void) close(contact->channel); + (void) close(contact->channel); break; case 2 : //freeing contact memory (void) free(contact); diff --git a/lib/modrec.c b/lib/modrec.c index e8ad0ec..a482f58 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -35,6 +35,7 @@ void docontact(SOCTYP *binding) #define TESTL 4 CONTYP *contact; +pid_t child; int phase; _Bool proceed; @@ -51,7 +52,17 @@ while (proceed==true) { phase=999; //no going further } break; - case 2 : //do contact + case 2 : //forking process + if ((child=fork())!=(pid_t)0) { + (void) close(contact->channel); + (void) free(contact); + (void) sleep(8); + (void) fprintf(stdout,"JMPDBG retart\n"); + phase=0; + } + break; + case 3 : //do contact + (void) close(binding->handle); for (int i=0;ichannel,tmpbuf,sizeof(tmpbuf)); - (void) sleep(2); + (void) sleep(1); } break; - case 3 : //close contact + case 4 : //close contact contact=tcp_dropcontact(contact); + (void) exit(0); break; default : //SAFE guard proceed=false; @@ -242,7 +254,7 @@ int phase; _Bool proceed; bindings=(SOCTYP **)0; -bindings=soc_mkbindinf(bindings,pro_smtp,"127.0.0.25","2525",1); +bindings=soc_mkbindinf(bindings,pro_smtp,"127.0.0.1","2525",1); //bindings=soc_mkbindinf(bindings,pro_smtp,"127.0.0.26","2626",1); phase=0; proceed=true; diff --git a/lib/unisoc.c b/lib/unisoc.c index 0e71de9..4dc707c 100644 --- a/lib/unisoc.c +++ b/lib/unisoc.c @@ -235,7 +235,7 @@ while (proceed==true) { (void) freeaddrinfo(tobind); break; case 4 : //listening on socket - if (listen(binding->handle,binding->iteration)<0) { + if (listen(binding->handle,binding->iteration+4)<0) { (void) rou_alert(0,"%s, Unable to listen at address " "IP:port '%s:%s' (error='%s')", binding->ip,binding->port,strerror(errno)); @@ -420,7 +420,7 @@ socklen_t taille; newhandle=-1; taille=sizeof(struct sockaddr); -if ((newhandle=accept(binding->handle,addr,&taille))<0) { +if ((newhandle=accept(binding->handle,NULL,NULL))<0) { if (errno==EAGAIN) errno=EWOULDBLOCK; switch (errno) {