From: wessels <> Date: Thu, 11 Apr 1996 02:45:24 +0000 (+0000) Subject: make SIGHUP reconfigure the cache; SIGUSR1 rotates logs X-Git-Tag: SQUID_3_0_PRE1~6226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ffd22bc7fc25406b3af97a8a1f436245185b6b6;p=thirdparty%2Fsquid.git make SIGHUP reconfigure the cache; SIGUSR1 rotates logs --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 35655e5db4..b564a8397d 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,10 +1,9 @@ -/* $Id: cache_cf.cc,v 1.29 1996/04/10 03:54:42 wessels Exp $ */ +/* $Id: cache_cf.cc,v 1.30 1996/04/10 20:45:24 wessels Exp $ */ /* DEBUG: Section 3 cache_cf: Configuration file parsing */ #include "squid.h" - static struct { struct { int maxSize; @@ -72,6 +71,13 @@ static struct { char *file; int rate; } Announce; + wordlist *cache_dirs; + wordlist *http_stoplist; + wordlist *gopher_stoplist; + wordlist *ftp_stoplist; + wordlist *bind_addr_list; + wordlist *local_domain_list; + wordlist *inside_firewall_list; } Config; #define DefaultMemMaxSize (16 << 20) /* 16 MB */ @@ -140,13 +146,6 @@ static struct { extern char *config_file; -stoplist *http_stoplist = NULL; -stoplist *gopher_stoplist = NULL; -stoplist *ftp_stoplist = NULL; -stoplist *bind_addr_list = NULL; -stoplist *local_domain_list = NULL; -stoplist *inside_firewall_list = NULL; - /* default CONNECT ports */ intlist snews = { @@ -176,8 +175,9 @@ int getDnsChildren(); char w_space[] = " \t\n"; -static void configSetFactoryDefaults(); -static void configDoConfigure(); +static void configSetFactoryDefaults _PARAMS((void)); +static void configFreeMemory _PARAMS((void)); +static void configDoConfigure _PARAMS((void)); static char fatal_str[BUFSIZ]; void self_destruct(in_string) @@ -414,22 +414,37 @@ void addToIPACL(list, ip_str, access) #endif /* ndef IPACL_INTS */ -void addToStopList(list, key) - stoplist **list; +static void wordlistDestroy(list) + wordlist **list; +{ + wordlist *w = NULL; + wordlist *n = NULL; + + for (w = *list; w; w=n) { + n = w->next; + safe_free(w->key); + safe_free(w); + } + *list = NULL; +} + +void wordlistAdd(list, key) + wordlist **list; char *key; { - stoplist *p, *q; + wordlist *p = NULL; + wordlist *q = NULL; if (!(*list)) { /* empty list */ - *list = (stoplist *) xcalloc(1, sizeof(stoplist)); + *list = (wordlist *) xcalloc(1, sizeof(wordlist)); (*list)->key = xstrdup(key); (*list)->next = NULL; } else { p = *list; while (p->next) p = p->next; - q = (stoplist *) xcalloc(1, sizeof(stoplist)); + q = (wordlist *) xcalloc(1, sizeof(wordlist)); q->key = xstrdup(key); q->next = NULL; p->next = q; @@ -782,8 +797,7 @@ static void parseDirLine(line_in) token = strtok(NULL, w_space); if (token == (char *) NULL) self_destruct(line_in); - storeAddSwapDisk(xstrdup(token)); - + wordlistAdd(&Config.cache_dirs, token); } static void parseHttpdAccelLine(line_in) @@ -1022,7 +1036,7 @@ static void parseHttpStopLine(line_in) token = strtok(NULL, w_space); if (token == (char *) NULL) return; - addToStopList(&http_stoplist, token); + wordlistAdd(&Config.http_stoplist, token); } static void parseGopherStopLine(line_in) @@ -1032,7 +1046,7 @@ static void parseGopherStopLine(line_in) token = strtok(NULL, w_space); if (token == (char *) NULL) return; - addToStopList(&gopher_stoplist, token); + wordlistAdd(&Config.gopher_stoplist, token); } static void parseFtpStopLine(line_in) char *line_in; @@ -1041,7 +1055,7 @@ static void parseFtpStopLine(line_in) token = strtok(NULL, w_space); if (token == (char *) NULL) return; - addToStopList(&ftp_stoplist, token); + wordlistAdd(&Config.ftp_stoplist, token); } static void parseAppendDomainLine(line_in) @@ -1065,7 +1079,7 @@ static void parseBindAddressLine(line_in) if (token == (char *) NULL) self_destruct(line_in); debug(3, 1, "parseBindAddressLine: adding %s\n", token); - addToStopList(&bind_addr_list, token); + wordlistAdd(&Config.bind_addr_list, token); } static void parseBlockListLine(line_in) @@ -1083,7 +1097,7 @@ static void parseLocalDomainLine(line_in) { char *token; while ((token = strtok(NULL, w_space))) { - addToStopList(&local_domain_list, token); + wordlistAdd(&Config.local_domain_list, token); } } @@ -1092,7 +1106,7 @@ static void parseInsideFirewallLine(line_in) { char *token; while ((token = strtok(NULL, w_space))) { - addToStopList(&inside_firewall_list, token); + wordlistAdd(&Config.inside_firewall_list, token); } } @@ -1234,8 +1248,7 @@ int parseConfigFile(file_name) static char tmp_line[BUFSIZ]; static char line_in[BUFSIZ]; - /* Initialize a few global strings, in case they aren't user defined */ - + configFreeMemory(); configSetFactoryDefaults(); if ((fp = fopen(file_name, "r")) == NULL) { @@ -1511,7 +1524,7 @@ int parseConfigFile(file_name) } /* Add INADDR_ANY to end of bind_addr_list as last chance */ - addToStopList(&bind_addr_list, "0.0.0.0"); + wordlistAdd(&Config.bind_addr_list, "0.0.0.0"); /* Sanity checks */ if (getClientLifetime() < getReadTimeout()) { @@ -1765,6 +1778,34 @@ int getAnnounceRate() { return Config.Announce.rate; } +wordlist * getHttpStoplist() +{ + return Config.http_stoplist; +} +wordlist * getFtpStoplist() +{ + return Config.ftp_stoplist; +} +wordlist * getGopherStoplist() +{ + return Config.gopher_stoplist; +} +wordlist * getLocalDomainList() +{ + return Config.local_domain_list; +} +wordlist * getCacheDirs() +{ + return Config.cache_dirs; +} +wordlist * getInsideFirewallList() +{ + return Config.inside_firewall_list; +} +wordlist * getBindAddrList() +{ + return Config.bind_addr_list; +} int setAsciiPortNum(p) int p; @@ -1790,6 +1831,36 @@ int safe_strlen(p) return p ? strlen(p) : -1; } +static void configFreeMemory() +{ + safe_free(Config.Wais.relayHost); + safe_free(Config.Log.log); + safe_free(Config.Log.access); + safe_free(Config.Log.hierarchy); + safe_free(Config.adminEmail); + safe_free(Config.effectiveUser); + safe_free(Config.effectiveGroup); + safe_free(Config.Program.ftpget); + safe_free(Config.Program.ftpget_opts); + safe_free(Config.Program.dnsserver); + safe_free(Config.Accel.host); + safe_free(Config.Accel.prefix); + safe_free(Config.appendDomain); + safe_free(Config.debugOptions); + safe_free(Config.pidFilename); + safe_free(Config.visibleHostname); + safe_free(Config.ftpUser); + safe_free(Config.Announce.host); + safe_free(Config.Announce.file); + wordlistDestroy(&Config.cache_dirs); + wordlistDestroy(&Config.http_stoplist); + wordlistDestroy(&Config.gopher_stoplist); + wordlistDestroy(&Config.ftp_stoplist); + wordlistDestroy(&Config.bind_addr_list); + wordlistDestroy(&Config.local_domain_list); + wordlistDestroy(&Config.inside_firewall_list); +} + static void configSetFactoryDefaults() { diff --git a/src/comm.cc b/src/comm.cc index 0291715f95..8289b0006d 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,5 +1,5 @@ -/* $Id: comm.cc,v 1.19 1996/04/09 18:18:48 wessels Exp $ */ +/* $Id: comm.cc,v 1.20 1996/04/10 20:45:26 wessels Exp $ */ /* DEBUG: Section 5 comm: socket level functions */ @@ -105,7 +105,7 @@ int comm_open(io_type, port, handler, note) int new_socket; FD_ENTRY *conn = NULL; int sock_type = io_type & COMM_DGRAM ? SOCK_DGRAM : SOCK_STREAM; - stoplist *p = NULL; + wordlist *p = NULL; /* Create socket for accepting new connections. */ if ((new_socket = socket(AF_INET, sock_type, 0)) < 0) { @@ -145,10 +145,10 @@ int comm_open(io_type, port, handler, note) } } if (port) { - for (p = bind_addr_list; p; p = p->next) { + for (p = getBindAddrList(); p; p = p->next) { if (do_bind(new_socket, p->key, port) == COMM_OK) break; - if (p->next == (stoplist *) NULL) + if (p->next == (wordlist *) NULL) return COMM_ERROR; } } diff --git a/src/ftp.cc b/src/ftp.cc index d0dd15a5b0..4c5a0acd18 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,4 +1,4 @@ -/* $Id: ftp.cc,v 1.31 1996/04/10 05:06:57 wessels Exp $ */ +/* $Id: ftp.cc,v 1.32 1996/04/10 20:45:26 wessels Exp $ */ /* * DEBUG: Section 9 ftp: FTP @@ -122,14 +122,12 @@ int ftp_url_parser(url, data) int ftpCachable(url) char *url; { - stoplist *p = NULL; + wordlist *p = NULL; /* scan stop list */ - p = ftp_stoplist; - while (p) { + for (p = getFtpStoplist(); p; p=p->next) { if (strstr(url, p->key)) return 0; - p = p->next; } /* else cachable */ diff --git a/src/gopher.cc b/src/gopher.cc index 72f7e05802..5b7a5a1627 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,4 +1,4 @@ -/* $Id: gopher.cc,v 1.22 1996/04/10 03:53:59 wessels Exp $ */ +/* $Id: gopher.cc,v 1.23 1996/04/10 20:45:27 wessels Exp $ */ /* * DEBUG: Section 10 gopher: GOPHER @@ -221,12 +221,12 @@ int gopher_url_parser(url, host, port, type_id, request) int gopherCachable(url) char *url; { - stoplist *p = NULL; + wordlist *p = NULL; GopherData *data = NULL; int cachable = 1; /* scan stop list */ - for (p = gopher_stoplist; p; p = p->next) + for (p = getGopherStoplist(); p; p = p->next) if (strstr(url, p->key)) return 0; diff --git a/src/http.cc b/src/http.cc index 21df2a5a92..8e9835b211 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,4 +1,4 @@ -/* $Id: http.cc,v 1.35 1996/04/10 00:18:49 wessels Exp $ */ +/* $Id: http.cc,v 1.36 1996/04/10 20:45:27 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP @@ -86,14 +86,14 @@ int httpCachable(url, method, req_hdr) int method; char *req_hdr; { - stoplist *p = NULL; + wordlist *p = NULL; /* GET and HEAD are cachable. Others are not. */ if (method != METHOD_GET && method != METHOD_HEAD) return 0; /* scan stop list */ - for (p = http_stoplist; p; p = p->next) { + for (p = getHttpStoplist(); p; p = p->next) { if (strstr(url, p->key)) return 0; } diff --git a/src/ipcache.cc b/src/ipcache.cc index cf585deba5..eedf3323bf 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,4 +1,4 @@ -/* $Id: ipcache.cc,v 1.18 1996/04/10 17:58:05 wessels Exp $ */ +/* $Id: ipcache.cc,v 1.19 1996/04/10 20:45:28 wessels Exp $ */ /* * DEBUG: Section 14 ipcache: IP Cache @@ -84,9 +84,10 @@ extern int file_update_open _PARAMS((int, char *)); void update_dns_child_alive() { int i; + int N = getDnsChildren(); dns_child_alive = 0; - for (i = 0; i < getDnsChildren(); ++i) { + for (i = 0; i < N; ++i) { if (dns_child_table[i]->alive) { dns_child_alive = 1; break; @@ -1060,48 +1061,25 @@ int ipcache_nbgethostbyname(name, fd, handler, data) } -/* initialize the ipcache */ -void ipcache_init() +void ipcacheOpenServers() { - int i, dnssocket; - char fd_note_buf[FD_ASCII_NOTE_SZ]; - - debug(14, 3, "ipcache_init: Called. ipcache_initialized=%d getDnsChildren()=%d\n", ipcache_initialized, getDnsChildren()); - - if (ipcache_initialized) - return; + int N = getDnsChildren(); + char *prg = getDnsProgram(); + int i; + int dnssocket; + static char fd_note_buf[FD_ASCII_NOTE_SZ]; - if (mkdir("dns", 0755) < 0 && errno != EEXIST) { - debug(14, 0, "ipcache_init: mkdir %s\n", xstrerror()); - } - last_dns_dispatched = getDnsChildren() - 1; - dns_error_message = xcalloc(1, 256); + if (mkdir("dns", 0755) < 0 && errno != EEXIST) + debug(14, 0, "ipcacheOpenServers: mkdir %s\n", xstrerror()); - /* test naming lookup */ - if (!do_dns_test) { - debug(14, 4, "ipcache_init: Skipping DNS name lookup tests, -D flag given.\n"); - } else if (ipcache_testname() < 0) { - fatal("ipcache_init: DNS name lookup appears to be broken on this machine."); - } else { - debug(14, 1, "Successful DNS name lookup tests...\n"); - } - - ip_table = hash_create(urlcmp, 229); /* small hash table */ - /* init static area */ - static_result = (struct hostent *) xcalloc(1, sizeof(struct hostent)); - static_result->h_length = 4; - /* Need a terminating NULL address (h_addr_list[1]) */ - static_result->h_addr_list = (char **) xcalloc(2, sizeof(char *)); - static_result->h_addr_list[0] = (char *) xcalloc(1, 4); - static_result->h_name = (char *) xcalloc(1, MAX_HOST_NAME + 1); /* start up companion process */ - dns_child_table = (dnsserver_entry **) xcalloc(getDnsChildren(), sizeof(dnsserver_entry)); + safe_free(dns_child_table); + dns_child_table = (dnsserver_entry **) xcalloc(N, sizeof(dnsserver_entry)); dns_child_alive = 0; - debug(14, 1, "ipcache_init: Starting %d 'dns_server' processes\n", - getDnsChildren()); - for (i = 0; i < getDnsChildren(); i++) { + debug(14, 1, "ipcache_init: Starting %d 'dns_server' processes\n", N); + for (i = 0; i < N; i++) { dns_child_table[i] = (dnsserver_entry *) xcalloc(1, sizeof(dnsserver_entry)); - if ((dnssocket = ipcache_create_dnsserver(getDnsProgram())) < 0) { + if ((dnssocket = ipcache_create_dnsserver(prg)) < 0) { debug(14, 1, "ipcache_init: WARNING: Cannot run 'dnsserver' process.\n"); debug(14, 1, " Fallling back to the blocking version.\n"); dns_child_table[i]->alive = 0; @@ -1120,7 +1098,7 @@ void ipcache_init() /* update fd_stat */ sprintf(fd_note_buf, "%s #%d", - getDnsProgram(), + prg, dns_child_table[i]->id); file_update_open(dns_child_table[i]->inpipe, fd_note_buf); @@ -1148,12 +1126,46 @@ void ipcache_init() debug(14, 3, "ipcache_init: 'dns_server' %d started\n", i); } } +} + +/* initialize the ipcache */ +void ipcache_init() +{ + + debug(14, 3, "ipcache_init: Called. ipcache_initialized=%d getDnsChildren()=%d\n", ipcache_initialized, getDnsChildren()); + + if (ipcache_initialized) + return; + + last_dns_dispatched = getDnsChildren() - 1; + if (!dns_error_message) + dns_error_message = xcalloc(1, 256); + + /* test naming lookup */ + if (!do_dns_test) { + debug(14, 4, "ipcache_init: Skipping DNS name lookup tests, -D flag given.\n"); + } else if (ipcache_testname() < 0) { + fatal("ipcache_init: DNS name lookup appears to be broken on this machine."); + } else { + debug(14, 1, "Successful DNS name lookup tests...\n"); + } + + ip_table = hash_create(urlcmp, 229); /* small hash table */ + /* init static area */ + static_result = (struct hostent *) xcalloc(1, sizeof(struct hostent)); + static_result->h_length = 4; + /* Need a terminating NULL address (h_addr_list[1]) */ + static_result->h_addr_list = (char **) xcalloc(2, sizeof(char *)); + static_result->h_addr_list[0] = (char *) xcalloc(1, 4); + static_result->h_name = (char *) xcalloc(1, MAX_HOST_NAME + 1); + + ipcacheOpenServers(); + ipcache_high = (long) (((float) MAX_IP * (float) IP_HIGH_WATER) / (float) 100); ipcache_low = (long) (((float) MAX_IP * (float) IP_LOW_WATER) / (float) 100); - ipcache_initialized = 1; } @@ -1354,8 +1366,8 @@ void ipcacheShutdownServers() for (i = 0; i < getDnsChildren(); i++) { dns = *(dns_child_table + i); - debug(14, 1, "ipcacheShutdownServers: sending '$shutdown' to dnsserver #%d\n", i); - debug(14, 1, "ipcacheShutdownServers: --> FD %d\n", dns->outpipe); + debug(14, 3, "ipcacheShutdownServers: sending '$shutdown' to dnsserver #%d\n", i); + debug(14, 3, "ipcacheShutdownServers: --> FD %d\n", dns->outpipe); file_write(dns->outpipe, xstrdup(shutdown), strlen(shutdown), diff --git a/src/main.cc b/src/main.cc index 2ee70a05a9..60554e8c0e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,4 +1,4 @@ -/* $Id: main.cc,v 1.28 1996/04/10 17:58:26 wessels Exp $ */ +/* $Id: main.cc,v 1.29 1996/04/10 20:45:30 wessels Exp $ */ /* DEBUG: Section 1 main: startup and main loop */ @@ -160,12 +160,19 @@ void serverConnectionsClose() } } -static void mainUninitialize() +static void mainReinitialize() { + debug(1, 0, "Retarting Harvest Cache (version %s)...\n", SQUID_VERSION); + /* Already called serverConnectionsClose and ipcacheShutdownServers() */ neighborsDestroy(); - serverConnectionsClose(); - /* ipcache_uninit() */ - /* neighbors_uninit(); */ + + parseConfigFile(config_file); + neighbors_init(); + ipcacheOpenServers(); + serverConnectionsOpen(); + if (theUdpConnection >= 0 && (!httpd_accel_mode || getAccelWithProxy())) + neighbors_open(theUdpConnection); + debug(1, 0, "Ready to serve requests.\n"); } static void mainInitialize() @@ -274,9 +281,10 @@ int main(argc, argv) } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sig_child); - signal(SIGHUP, rotate_logs); + signal(SIGUSR1, rotate_logs); signal(SIGTERM, shut_down); signal(SIGINT, shut_down); + signal(SIGHUP, reconfigure); mainInitialize(); @@ -321,12 +329,12 @@ int main(argc, argv) normal_shutdown(); exit(0); } else if (reread_pending) { - mainUninitialize(); - mainInitialize(); + mainReinitialize(); reread_pending = 0; /* reset */ } else { fatal_dump("MAIN: SHUTDOWN from comm_select, but nothing pending."); } + break; default: fatal_dump("MAIN: Internal error -- this should never happen."); break; diff --git a/src/neighbors.cc b/src/neighbors.cc index 625df96fe4..91912e2cf6 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,4 +1,4 @@ -/* $Id: neighbors.cc,v 1.13 1996/04/10 17:57:44 wessels Exp $ */ +/* $Id: neighbors.cc,v 1.14 1996/04/10 20:45:31 wessels Exp $ */ /* TODO: * - change 'neighbor' to 'sibling' @@ -219,14 +219,15 @@ void neighborsDestroy() edge *e = NULL; edge *next = NULL; - debug(15, 1, "neighborEdgesFree()\n"); + debug(15, 3, "neighborsDestroy: called\n"); for (e = friends->edges_head; e; e = next) { next = e->next; safe_free(e->host); safe_free(e); } - friends->edges_head = NULL; + safe_free(friends); + friends = NULL; } static void neighborsOpenLog(fname) @@ -378,8 +379,8 @@ int neighborsUdpPing(proto) /* e->header.reqnum++; */ e->header.reqnum = atoi(entry->key); - debug(15, 1, "neighborsUdpPing: key = '%s'\n", entry->key); - debug(15, 1, "neighborsUdpPing: reqnum = %d\n", e->header.reqnum); + debug(15, 3, "neighborsUdpPing: key = '%s'\n", entry->key); + debug(15, 3, "neighborsUdpPing: reqnum = %d\n", e->header.reqnum); if (e->udp_port == echo_port) { debug(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n"); @@ -702,8 +703,9 @@ void neighbors_init() friends->edges_tail = e; friends->n++; - xfree(t); + safe_free(t); } + Neighbor_cf = NULL; } void neighbors_rotate_log() diff --git a/src/stat.cc b/src/stat.cc index 59329c5f28..94ecf4c86b 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,4 +1,4 @@ -/* $Id: stat.cc,v 1.18 1996/04/10 03:52:56 wessels Exp $ */ +/* $Id: stat.cc,v 1.19 1996/04/10 20:45:32 wessels Exp $ */ /* * DEBUG: Section 18 stat @@ -394,6 +394,7 @@ void info_get(obj, sentry) { char *tod = NULL; static char line[MAX_LINELEN]; + wordlist *p = NULL; #if defined(HAVE_GETRUSAGE) && defined(RUSAGE_SELF) struct rusage rusage; @@ -589,9 +590,7 @@ void info_get(obj, sentry) sprintf(line, "{Stop List:}\n"); storeAppend(sentry, line, strlen(line)); - if (http_stoplist) { - stoplist *p; - p = http_stoplist; + if ((p = getHttpStoplist())) { sprintf(line, "{\tHTTP:}\n"); storeAppend(sentry, line, strlen(line)); while (p) { @@ -600,9 +599,7 @@ void info_get(obj, sentry) p = p->next; } } - if (gopher_stoplist) { - stoplist *p; - p = gopher_stoplist; + if ((p = getGopherStoplist())) { sprintf(line, "{\tGOPHER:}\n"); storeAppend(sentry, line, strlen(line)); while (p) { @@ -611,9 +608,7 @@ void info_get(obj, sentry) p = p->next; } } - if (ftp_stoplist) { - stoplist *p; - p = ftp_stoplist; + if ((p = getFtpStoplist())) { sprintf(line, "{\tFTP:}\n"); storeAppend(sentry, line, strlen(line)); while (p) { diff --git a/src/store.cc b/src/store.cc index 08d13b3465..7eb043b194 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ -/* $Id: store.cc,v 1.39 1996/04/10 05:07:27 wessels Exp $ */ -#ident "$Id: store.cc,v 1.39 1996/04/10 05:07:27 wessels Exp $" +/* $Id: store.cc,v 1.40 1996/04/10 20:45:33 wessels Exp $ */ +#ident "$Id: store.cc,v 1.40 1996/04/10 20:45:33 wessels Exp $" /* * DEBUG: Section 20 store @@ -933,7 +933,9 @@ int storeAddSwapDisk(path) { if (cache_dirs == NULL) cache_dirs = create_dynamic_array(5, 5); - insert_dynamic_array(cache_dirs, path); + /* XXX note xstrdup here prob means we + can't use destroy_dynamic_array() */ + insert_dynamic_array(cache_dirs, xstrdup(path)); return ++ncache_dirs; } @@ -1048,8 +1050,7 @@ int storeSwapInStart(e) e->mem_obj = new_MemObject(); path = storeSwapFullPath(e->swap_file_number, NULL); - fd = e->mem_obj->swap_fd = file_open(path, NULL, O_RDONLY); - if (fd < 0) { + if ((fd = file_open(path, NULL, O_RDONLY)) < 0) { debug(20, 0, "storeSwapInStart: Unable to open swapfile: %s\n", path); debug(20, 0, "storeSwapInStart: --> for \n", @@ -1058,6 +1059,7 @@ int storeSwapInStart(e) /* Invoke a store abort that should free the memory object */ return -1; } + e->mem_obj->swap_fd = (short) fd; debug(20, 5, "storeSwapInStart: initialized swap file '%s' for \n", path, e->url); @@ -1183,7 +1185,7 @@ static int storeSwapOutStart(e) e->swap_file_number = -1; return -1; } - e->mem_obj->swap_fd = fd; + e->mem_obj->swap_fd = (short) fd; debug(20, 5, "storeSwapOutStart: Begin SwapOut to FD %d FILE %s.\n", e->url, fd, swapfilename); @@ -2421,9 +2423,12 @@ static void storeCreateSwapSubDirs() int storeInit() { int dir_created; + wordlist *w = NULL; storelog_fd = file_open("store.log", NULL, O_WRONLY | O_APPEND | O_CREAT); + for (w = getCacheDirs(); w; w=w->next) + storeAddSwapDisk(w->key); storeSanityCheck(); file_map_create(MAX_SWAP_FILE); dir_created = storeVerifySwapDirs(zap_disk_store); diff --git a/src/tools.cc b/src/tools.cc index ca6e9c2c49..66373dedd1 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,5 +1,5 @@ -/* $Id: tools.cc,v 1.27 1996/04/10 05:10:28 wessels Exp $ */ +/* $Id: tools.cc,v 1.28 1996/04/10 20:45:34 wessels Exp $ */ /* * DEBUG: Section 21 tools @@ -139,7 +139,7 @@ void death(sig) void rotate_logs(sig) int sig; { - debug(21, 1, "rotate_logs: SIGHUP received.\n"); + debug(21, 1, "rotate_logs: SIGUSR1 received.\n"); storeWriteCleanLog(); neighbors_rotate_log(); @@ -398,13 +398,15 @@ time_t getCurrentTime() } -void usr1_handle(sig) +void reconfigure(sig) int sig; { - debug(21, 1, "usr1_handle: SIGUSR1 received.\n"); + debug(21, 1, "reconfigure: SIGHUP received.\n"); + serverConnectionsClose(); + ipcacheShutdownServers(); reread_pending = 1; #if defined(_SQUID_SYSV_SIGNALS_) - signal(sig, rotate_logs); + signal(sig, reconfigure); #endif }