]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Very strange about TIME_WAIT....
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 31 Jul 2024 13:50:07 +0000 (09:50 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 31 Jul 2024 13:50:07 +0000 (09:50 -0400)
kleenex/server.c
lib/gestcp.c
lib/modrec.c
lib/unisoc.c

index b94e3592e755c001247aa4a3baacc1ff2a2ff166..5acd99225c32ad2cc49f4437d38b27a793be01d4 100644 (file)
@@ -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);
index fcbf648a1fa7f9205699bae90e518c15e586b6b5..f1d9b04cda7b0ccec31af3938b975a110e373ad3 100644 (file)
@@ -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);              
index e8ad0ecf9b316bcd5b872298d52fbb69a9cdbf15..a482f5802232e7aab3aa91a9e4a60716c4ef651c 100644 (file)
@@ -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;i<TESTL;i++) {
         int sent;
         char tmpbuf[100];
@@ -66,11 +77,12 @@ while (proceed==true) {
           break;
           }
         (void) read(contact->channel,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;
index 0e71de9e910c15bacf6501f0658ac2a2c9d60dc4..4dc707c6a79d7264bb145e6586a23e2d797137cb 100644 (file)
@@ -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) {