From: wessels <> Date: Tue, 31 Mar 1998 11:09:48 +0000 (+0000) Subject: clean up reconfigure/rotate/shutdown flags and stuff X-Git-Tag: SQUID_3_0_PRE1~3687 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5cd39a10ddcaed8f70c0b3c435069fdb2c38b4da;p=thirdparty%2Fsquid.git clean up reconfigure/rotate/shutdown flags and stuff --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 8a3fdc3c8c..19130b29df 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.267 1998/03/28 18:37:05 wessels Exp $ + * $Id: cache_cf.cc,v 1.268 1998/03/31 04:09:48 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -613,7 +613,7 @@ free_cachedir(cacheSwap * swap) SwapDir *s; int i; /* DON'T FREE THESE FOR RECONFIGURE */ - if (reconfigure_pending) + if (reconfiguring) return; for (i = 0; i < swap->n_configured; i++) { s = swap->swapDirs + i; diff --git a/src/comm.cc b/src/comm.cc index 6bc65d93d2..e48c029fd4 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.239 1998/03/28 23:24:44 wessels Exp $ + * $Id: comm.cc,v 1.240 1998/03/31 04:09:49 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -482,7 +482,7 @@ commSetTimeout(int fd, int timeout, PF * handler, void *data) F->timeout_data = NULL; return F->timeout = 0; } - if (shutdown_pending || reconfigure_pending) { + if (shutdown_pending) { /* don't increase the timeout if something pending */ if (F->timeout > 0 && (int) (F->timeout - squid_curtime) < timeout) return F->timeout; @@ -888,8 +888,7 @@ comm_poll(time_t sec) /* shutdown_pending will be set to * +1 for SIGTERM * -1 for SIGINT */ - /* reconfigure_pending always == 1 when SIGHUP received */ - if (shutdown_pending > 0 || reconfigure_pending > 0) + if (shutdown_pending > 0) setSocketShutdownLifetimes(Config.shutdownLifetime); else setSocketShutdownLifetimes(1); @@ -915,7 +914,7 @@ comm_poll(time_t sec) nfds++; } } - if (shutdown_pending || reconfigure_pending) + if (shutdown_pending) debug(5, 2) ("comm_poll: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; @@ -1040,15 +1039,14 @@ comm_select(time_t sec) FD_ZERO(&readfds); FD_ZERO(&writefds); - if (shutdown_pending || reconfigure_pending) { + if (shutdown_pending) { serverConnectionsClose(); dnsShutdownServers(); redirectShutdownServers(); /* shutdown_pending will be set to * +1 for SIGTERM * -1 for SIGINT */ - /* reconfigure_pending always == 1 when SIGHUP received */ - if (shutdown_pending > 0 || reconfigure_pending > 0) + if (shutdown_pending > 0) setSocketShutdownLifetimes(Config.shutdownLifetime); else setSocketShutdownLifetimes(1); @@ -1067,7 +1065,7 @@ comm_select(time_t sec) FD_SET(i, &writefds); } } - if (shutdown_pending || reconfigure_pending) + if (shutdown_pending) debug(5, 2) ("comm_select: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; diff --git a/src/globals.h b/src/globals.h index 31af1a9cda..7660d9e6e4 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.44 1998/03/29 08:50:59 wessels Exp $ + * $Id: globals.h,v 1.45 1998/03/31 04:09:50 wessels Exp $ */ extern FILE *debug_log; /* NULL */ @@ -80,8 +80,8 @@ extern struct in_addr theOutSNMPAddr; extern struct timeval current_time; extern struct timeval squid_start; extern time_t squid_curtime; /* 0 */ -extern volatile int reconfigure_pending; /* 0 */ extern volatile int shutdown_pending; /* 0 */ +extern int reconfiguring; /* 0 */ extern int store_rebuilding; /* 1 */ extern int store_swap_size; /* 0 */ extern unsigned long store_mem_size; /* 0 */ diff --git a/src/main.cc b/src/main.cc index ba8eab1e20..f190d86072 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.239 1998/03/28 23:24:48 wessels Exp $ + * $Id: main.cc,v 1.240 1998/03/31 04:09:51 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -111,20 +111,22 @@ extern void (*failure_notify) (const char *); static int opt_send_signal = -1; static int opt_no_daemon = 0; -static volatile int rotate_pending = 0; /* set by SIGUSR1 handler */ static int httpPortNumOverride = 1; static int icpPortNumOverride = 1; /* Want to detect "-u 0" */ #if MALLOC_DBG static int malloc_debug_level = 0; #endif +static volatile int do_reconfigure = 0; +static volatile int do_rotate = 0; +static void mainRotate(void); +static void mainReconfigure(void); static SIGHDLR rotate_logs; static SIGHDLR reconfigure; #if ALARM_UPDATES_TIME static SIGHDLR time_tick; #endif static void mainInitialize(void); -static void mainReconfigure(void); static void usage(void); static void mainParseOptions(int, char **); static void sendSignal(void); @@ -278,8 +280,7 @@ mainParseOptions(int argc, char *argv[]) static void rotate_logs(int sig) { - debug(1, 1) ("rotate_logs: SIGUSR1 received.\n"); - rotate_pending = 1; + do_rotate = 1; #if !HAVE_SIGACTION signal(sig, rotate_logs); #endif @@ -302,7 +303,7 @@ time_tick(int sig) static void reconfigure(int sig) { - reconfigure_pending = 1; + do_reconfigure = 1; #if !HAVE_SIGACTION signal(sig, reconfigure); #endif @@ -312,17 +313,10 @@ void shut_down(int sig) { shutdown_pending = sig == SIGINT ? -1 : 1; - debug(1, 1) ("Preparing for shutdown after %d requests\n", - Counter.client_http.requests); - debug(1, 1) ("Waiting %d seconds for active connections to finish\n", - shutdown_pending > 0 ? (int) Config.shutdownLifetime : 0); #ifdef KILL_PARENT_OPT - { - pid_t ppid = getppid(); - if (ppid > 1) { - debug(1, 1) ("Killing RunCache, pid %d\n", ppid); - kill(ppid, sig); - } + if (getppid() > 1) { + debug(1, 1) ("Killing RunCache, pid %d\n", getppid()); + kill(getppid(), sig); } #endif #if SA_RESETHAND == 0 @@ -368,6 +362,7 @@ static void mainReconfigure(void) { debug(1, 0) ("Restarting Squid Cache (version %s)...\n", version_string); + reconfiguring = 1; /* Already called serverConnectionsClose and ipcacheShutdownServers() */ serverConnectionsClose(); icpConnectionClose(); @@ -392,6 +387,19 @@ mainReconfigure(void) neighbors_open(theOutIcpConnection); storeDirOpenSwapLogs(); debug(1, 0) ("Ready to serve requests.\n"); + reconfiguring = 0; +} + +static void +mainRotate(void) +{ + icmpClose(); + _db_rotate_log(); /* cache.log */ + storeDirWriteCleanLogs(1); + storeLogRotate(); /* store.log */ + accessLogRotate(); /* access.log */ + useragentRotateLog(); /* useragent.log */ + icmpOpen(); } static void @@ -589,18 +597,17 @@ main(int argc, char **argv) /* main loop */ for (;;) { - if (reconfigure_pending) { + if (do_reconfigure) { mainReconfigure(); - reconfigure_pending = 0; /* reset */ - } else if (rotate_pending) { - icmpClose(); - _db_rotate_log(); /* cache.log */ - storeDirWriteCleanLogs(1); - storeLogRotate(); /* store.log */ - accessLogRotate(); /* access.log */ - useragentRotateLog(); /* useragent.log */ - icmpOpen(); - rotate_pending = 0; + do_reconfigure = 0; + } else if (do_rotate) { + mainRotate(); + do_rotate = 0; + } else if (shutdown_pending) { + debug(1, 1) ("Preparing for shutdown after %d requests\n", + Counter.client_http.requests); + debug(1, 1) ("Waiting %d seconds for active connections to finish\n", + shutdown_pending > 0 ? (int) Config.shutdownLifetime : 0); } eventRun(); if ((loop_delay = eventNextTime()) < 0) @@ -692,8 +699,7 @@ watch_child(char *argv[]) execvp(prog, argv); fatal("execvp failed"); } - /* parent */ - time(&start); + /* parent */ time(&start); do { squid_signal(SIGINT, SIG_IGN, SA_RESTART); #ifdef _SQUID_NEXT_ diff --git a/src/redirect.cc b/src/redirect.cc index 401badc233..50572fe274 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.57 1998/03/03 00:31:12 rousskov Exp $ + * $Id: redirect.cc,v 1.58 1998/03/31 04:09:51 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -105,7 +105,7 @@ redirectHandleRead(int fd, void *data) memFree(MEM_8K_BUF, redirector->inbuf); redirector->inbuf = NULL; comm_close(fd); - if (--NRedirectorsOpen == 0 && !shutdown_pending && !reconfigure_pending) + if (--NRedirectorsOpen == 0 && !shutdown_pending) fatal_dump("All redirectors have exited!"); return; }