From: wessels <> Date: Fri, 11 Oct 1996 04:20:27 +0000 (+0000) Subject: Misc shutdown-related cleanup stuff... X-Git-Tag: SQUID_3_0_PRE1~5683 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7433536f52d1b6bf5cf93c55b368a92d51320e6;p=thirdparty%2Fsquid.git Misc shutdown-related cleanup stuff... --- diff --git a/src/disk.cc b/src/disk.cc index 4b36ef1f30..099122e977 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -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_) diff --git a/src/fqdncache.cc b/src/fqdncache.cc index b70213368f..aee0799246 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -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]); diff --git a/src/icmp.cc b/src/icmp.cc index cff9b3e6e0..4920867871 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -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 */ diff --git a/src/main.cc b/src/main.cc index 85f5130dfb..dab1079095 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 } diff --git a/src/redirect.cc b/src/redirect.cc index 5032e382a2..55594a93b7 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -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; } } diff --git a/src/tools.cc b/src/tools.cc index 9b68f6d5c8..2b0fe9b519 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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); }