]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Misc shutdown-related cleanup stuff...
authorwessels <>
Fri, 11 Oct 1996 04:20:27 +0000 (04:20 +0000)
committerwessels <>
Fri, 11 Oct 1996 04:20:27 +0000 (04:20 +0000)
src/disk.cc
src/fqdncache.cc
src/icmp.cc
src/main.cc
src/redirect.cc
src/tools.cc

index 4b36ef1f30f23975ac0d31b730e40ce048bf17b2..099122e977e10b9eea4fab74e59c3f9ad5fcb279 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: disk.cc,v 1.32 1996/10/09 15:34:24 wessels Exp $
+ * $Id: disk.cc,v 1.33 1996/10/10 22:20:27 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -154,8 +154,6 @@ file_open(char *path, int (*handler) _PARAMS((void)), int mode)
     FD_ENTRY *conn;
     int fd;
 
-    if (mode & O_RDWR)
-       fatal_dump("file_open: O_RDWR not allowed");
     if (mode & O_WRONLY)
        mode |= O_APPEND;
 #if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
index b70213368f34cf8efcecc5b71ae55c87e21c4283..aee0799246d1621725f4b251fe5586351d7ef55a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.23 1996/10/10 19:04:14 wessels Exp $
+ * $Id: fqdncache.cc,v 1.24 1996/10/10 22:20:28 wessels Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -367,7 +367,6 @@ fqdncache_create(void)
     meta_data.fqdncache_count++;
     new = xcalloc(1, sizeof(fqdncache_entry));
     return new;
-
 }
 
 static void
@@ -878,16 +877,17 @@ fqdncacheFreeMemory(void)
 {
     fqdncache_entry *f;
     fqdncache_entry **list;
+    int i = 0;
+    int j = 0;
     int k = 0;
-    int j;
     list = xcalloc(meta_data.fqdncache_count, sizeof(fqdncache_entry *));
     f = (fqdncache_entry *) hash_first(fqdn_table);
-    while (f && k < meta_data.fqdncache_count) {
-        *(list + k) = f;
-        k++;
+    while (f && i < meta_data.fqdncache_count) {
+        *(list + i) = f;
+        i++;
         f = (fqdncache_entry *) hash_next(fqdn_table);
     }
-    for (j = 0; j < k; j++) {
+    for (j = 0; j < i; j++) {
         f = *(list + j);
         for (k = 0; k < (int) f->name_count; k++)
             safe_free(f->names[k]);
index cff9b3e6e08bf825da8869f1e0a7995649b5d196..4920867871cc36238b28fe3979cad73201ded2ee 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icmp.cc,v 1.15 1996/10/10 18:48:49 wessels Exp $
+ * $Id: icmp.cc,v 1.16 1996/10/10 22:20:28 wessels Exp $
  *
  * DEBUG: section 37    ICMP Routines
  * AUTHOR: Duane Wessels
@@ -42,7 +42,7 @@ typedef struct _icmpQueueData {
     char *msg;
     int len;
     struct _icmpQueueData *next;
-    void (*free) _PARAMS((void *));
+    void (*free_func) _PARAMS((void *));
 } icmpQueueData;
 
 static icmpQueueData *IcmpQueueHead = NULL;
@@ -52,7 +52,7 @@ int icmp_sock = -1;
 static void icmpRecv _PARAMS((int, void *));
 static void icmpQueueSend _PARAMS((pingerEchoData * pkt,
        int len,
-       void          (*free) _PARAMS((void *))));
+       void          (*free_func) _PARAMS((void *))));
 static void icmpSend _PARAMS((int fd, icmpQueueData * queue));
 static void icmpHandleSourcePing _PARAMS((struct sockaddr_in * from, char *buf));
 
@@ -124,10 +124,15 @@ icmpClose(void)
     icmpQueueData *queue;
     debug(29,0,"Closing ICMP socket on FD %d\n", icmp_sock);
     comm_close(icmp_sock);
+    comm_set_select_handler(icmp_sock,
+       COMM_SELECT_READ,
+       NULL,
+       NULL);
+    icmp_sock = -1;
     while ((queue = IcmpQueueHead)) {
        IcmpQueueHead = queue->next;
-       if (queue->free)
-           queue->free(queue->msg);
+       if (queue->free_func)
+           queue->free_func(queue->msg);
        safe_free(queue);
     }
 }
@@ -189,15 +194,20 @@ icmpRecv(int unused1, void *unused2)
 static void
 icmpQueueSend(pingerEchoData * pkt,
     int len,
-    void (*free) _PARAMS((void *)))
+    void (*free_func) _PARAMS((void *)))
 {
     icmpQueueData *q = NULL;
     icmpQueueData **H = NULL;
+    if (icmp_sock < 0) {
+       if (free_func)
+           free_func(pkt);
+       return;
+    }
     debug(37, 3, "icmpQueueSend: Queueing %d bytes\n", len);
     q = xcalloc(1, sizeof(icmpQueueData));
     q->msg = (char *) pkt;
     q->len = len;
-    q->free = free;
+    q->free_func = free_func;
     for (H = &IcmpQueueHead; *H; H = &(*H)->next);
     *H = q;
     comm_set_select_handler(icmp_sock,
@@ -224,8 +234,8 @@ icmpSend(int fd, icmpQueueData * queue)
            debug(37, 0, "icmpSend: Wrote %d of %d bytes\n", x, queue->len);
        }
        IcmpQueueHead = queue->next;
-       if (queue->free)
-           queue->free(queue->msg);
+       if (queue->free_func)
+           queue->free_func(queue->msg);
        safe_free(queue);
     }
     /* Reinstate handler if needed */
index 85f5130dfbf6aa0b8cec39b8d6ee6ee66d9e6446..dab1079095a0c36fb0e861b10f7b820685660218 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.cc,v 1.89 1996/10/09 15:43:52 wessels Exp $
+ * $Id: main.cc,v 1.90 1996/10/10 22:20:29 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -431,7 +431,8 @@ serverConnectionsClose(void)
        theInIcpConnection = -1;
     }
 #if USE_ICMP
-    icmpClose();
+    if (icmp_sock > -1)
+        icmpClose();
 #endif
 }
 
index 5032e382a210ca97bedb9140bebcb104138fc44b..55594a93b7f2fb50bfc9a51ece1daff10e8d5516 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: redirect.cc,v 1.23 1996/10/09 22:49:41 wessels Exp $
+ * $Id: redirect.cc,v 1.24 1996/10/10 22:20:30 wessels Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -32,7 +32,7 @@
 
 #define REDIRECT_FLAG_ALIVE            0x01
 #define REDIRECT_FLAG_BUSY             0x02
-#define REDIRECT_FLAG_CLOSING  0x04
+#define REDIRECT_FLAG_CLOSING          0x04
 
 typedef struct {
     int fd;
@@ -77,7 +77,6 @@ static redirectStateData *Dequeue _PARAMS((void));
 static void Enqueue _PARAMS((redirectStateData *));
 static void redirectDispatch _PARAMS((redirector_t *, redirectStateData *));
 
-
 static redirector_t **redirect_child_table = NULL;
 static int NRedirectors = 0;
 static int NRedirectorsOpen = 0;
@@ -423,6 +422,7 @@ redirectShutdownServers(void)
            redirect->index + 1, redirect->fd);
        comm_close(redirect->fd);
        redirect->flags |= REDIRECT_FLAG_CLOSING;
+       redirect->flags |= REDIRECT_FLAG_BUSY;
     }
 }
 
index 9b68f6d5c88f711661e5e1f2764147386bbe4b71..2b0fe9b519a379907aa063fabed21cd6a9f0047d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.69 1996/10/10 19:04:20 wessels Exp $
+ * $Id: tools.cc,v 1.70 1996/10/10 22:20:30 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -297,7 +297,6 @@ normal_shutdown(void)
     PrintRusage(NULL, debug_log);
     storeCloseLog();
     statCloseLog();
-    fclose(debug_log);
     configFreeMemory();
     diskFreeMemory();
     storeFreeMemory();
@@ -313,6 +312,7 @@ normal_shutdown(void)
     fqdncacheFreeMemory();
     debug(21, 0, "Squid Cache (Version %s): Exiting normally.\n",
        version_string);
+    fclose(debug_log);
     exit(0);
 }