/*
- * $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
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;
/* 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);
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;
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);
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;
/*
- * $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
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);
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
static void
reconfigure(int sig)
{
- reconfigure_pending = 1;
+ do_reconfigure = 1;
#if !HAVE_SIGACTION
signal(sig, reconfigure);
#endif
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
mainReconfigure(void)
{
debug(1, 0) ("Restarting Squid Cache (version %s)...\n", version_string);
+ reconfiguring = 1;
/* Already called serverConnectionsClose and ipcacheShutdownServers() */
serverConnectionsClose();
icpConnectionClose();
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
/* 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)
execvp(prog, argv);
fatal("execvp failed");
}
- /* parent */
- time(&start);
+ /* parent */ time(&start);
do {
squid_signal(SIGINT, SIG_IGN, SA_RESTART);
#ifdef _SQUID_NEXT_