From 7690e8eb7e104d50d4b4b5214369673202d1941c Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 12 Sep 1996 09:23:51 +0000 Subject: [PATCH] cleanup based on HP-UX CC -k signal option --- ChangeLog | 11 ++++++++ configure.in | 5 ++-- lib/Makefile.in | 4 ++- src/acl.cc | 4 +-- src/client_side.cc | 4 +-- src/comm.cc | 19 ++++++++++--- src/dnsserver.cc | 3 ++- src/fqdncache.cc | 4 +-- src/main.cc | 67 +++++++++++++++++++++++++++++++++++++++++----- src/neighbors.cc | 4 +-- src/tools.cc | 28 ++++++++++++++++++- 11 files changed, 129 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf75c9f8bd..0f0975cb59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ +Changes to squid-1.1.alpha18: + - Fixed storeCheckPurgeMem() to both 'purge' *and* 'release' objects as needed. + - Fixed up RWStateCallbackAndFree() to prevent it from getting + called twice. + - Added 'deny_info' support for redirecting denied requests to + a specific URL (maex@space.net). + - Fixed protoUnregister() to not abort objects being swapped in. + - Changed debug log timestamp format. + - Fixed coredump-causing bugs in icpHandleIMSReply(). + - Fixed FMR bug in neighborsUdpAck() for UDP_HIT_OBJ replies. + - Fixed up InvokeHandlers() to clear handler before calling. Changes to squid-1.1.alpha17: diff --git a/configure.in b/configure.in index e02ee6784f..eb5062ef71 100644 --- a/configure.in +++ b/configure.in @@ -3,13 +3,13 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.32 1996/09/03 19:24:00 wessels Exp $ +dnl $Id: configure.in,v 1.33 1996/09/12 03:23:52 wessels Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.32 $)dnl +AC_REVISION($Revision: 1.33 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(aux) @@ -286,7 +286,6 @@ AC_CHECK_FUNCS(\ setrlimit \ setsid \ sigaction \ - socketpair \ srand48 \ strdup \ sysconf \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 6e1adbacc2..27824f667b 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -3,7 +3,7 @@ # # Darren Hardy, hardy@cs.colorado.edu, April 1994 # -# $Id: Makefile.in,v 1.12 1996/08/26 22:47:47 wessels Exp $ +# $Id: Makefile.in,v 1.13 1996/09/12 03:23:59 wessels Exp $ # prefix = @prefix@ srcdir = @srcdir@ @@ -18,6 +18,7 @@ RANLIB = @RANLIB@ AC_CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ XTRA_LIBS = @XTRA_LIBS@ +RM = @RM@ INCLUDE = -I../include -I$(srcdir)/../include UTILOBJS = rfc850.o \ @@ -37,6 +38,7 @@ CFLAGS = $(AC_CFLAGS) $(INCLUDE) all: $(LIBS) libmiscutil.a: $(UTILOBJS) + $(RM) -f $@ ar r $@ $(UTILOBJS) $(RANLIB) $@ diff --git a/src/acl.cc b/src/acl.cc index f0ff2ff862..ae015686cc 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.31 1996/09/11 22:41:10 wessels Exp $ + * $Id: acl.cc,v 1.32 1996/09/12 03:24:00 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -942,7 +942,7 @@ void aclDestroyAcls() AclListTail = &AclList; } -void aclDestroyAclList(list) +static void aclDestroyAclList(list) struct _acl_list *list; { struct _acl_list *next = NULL; diff --git a/src/client_side.cc b/src/client_side.cc index 238df753f0..8aa5c38152 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.21 1996/09/12 00:32:33 wessels Exp $ + * $Id: client_side.cc,v 1.22 1996/09/12 03:24:01 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -394,7 +394,7 @@ int icpProcessExpired(fd, icpState) } -int icpHandleIMSReply(fd, entry, data) +static int icpHandleIMSReply(fd, entry, data) int fd; StoreEntry *entry; void *data; diff --git a/src/comm.cc b/src/comm.cc index e9f2d48d59..bf828fa2aa 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.63 1996/09/12 00:31:34 wessels Exp $ + * $Id: comm.cc,v 1.64 1996/09/12 03:24:02 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -204,10 +204,14 @@ u_short comm_local_port(fd) return fde->local_port; } +#ifdef __STDC__ +static int commBind (int s, struct in_addr in_addr, u_short port) +#else /* K&R C */ static int commBind(s, in_addr, port) int s; struct in_addr in_addr; u_short port; +#endif { struct sockaddr_in S; @@ -226,11 +230,15 @@ static int commBind(s, in_addr, port) /* Create a socket. Default is blocking, stream (TCP) socket. IO_TYPE * is OR of flags specified in comm.h. */ +#ifdef __STDC__ +int comm_open(unsigned int io_type, struct in_addr addr, u_short port, char *note) +#else /* K&R C */ int comm_open(io_type, addr, port, note) unsigned int io_type; struct in_addr addr; u_short port; char *note; +#endif { int new_socket; FD_ENTRY *conn = NULL; @@ -264,7 +272,7 @@ int comm_open(io_type, addr, port, note) if (!(io_type & COMM_NOCLOEXEC)) commSetCloseOnExec(new_socket); - if (port > 0) { + if (port > (u_short) 0) { commSetNoLinger(new_socket); if (do_reuse) commSetReuseAddr(new_socket); @@ -523,12 +531,17 @@ int comm_cleanup_fd_entry(fd) /* Send a udp datagram to specified PORT at HOST. */ +#ifdef __STDC__ +int +comm_udp_send(int fd, char *host, u_short port, char *buf, int len) +#else /* K&R C */ int comm_udp_send(fd, host, port, buf, len) int fd; char *host; u_short port; char *buf; int len; +#endif { struct hostent *hp = NULL; static struct sockaddr_in to_addr; @@ -722,7 +735,7 @@ int comm_select(sec) return COMM_SHUTDOWN; if (shutdown_pending || reread_pending) debug(5, 2, "comm_select: Still waiting on %d FDs\n", nfds); - while (1) { + for (;;) { #if USE_ASYNC_IO /* Another CPU vs latency tradeoff for async IO */ poll_time.tv_sec = 0; diff --git a/src/dnsserver.cc b/src/dnsserver.cc index 8952dfc97d..33075a1227 100644 --- a/src/dnsserver.cc +++ b/src/dnsserver.cc @@ -1,6 +1,6 @@ /* - * $Id: dnsserver.cc,v 1.20 1996/09/11 22:41:12 wessels Exp $ + * $Id: dnsserver.cc,v 1.21 1996/09/12 03:24:02 wessels Exp $ * * DEBUG: section 0 DNS Resolver * AUTHOR: Harvest Derived @@ -424,4 +424,5 @@ int main(argc, argv) } } /* NOTREACHED */ + return 0; } diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 7a5d0a20c7..a07d317c5a 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.15 1996/09/04 22:03:23 wessels Exp $ + * $Id: fqdncache.cc,v 1.16 1996/09/12 03:24:03 wessels Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -559,7 +559,7 @@ static int fqdncache_dnsHandleRead(fd, dnsData) dnsData->ip_inbuf[0] = '\0'; f = dnsData->data; f->name_count = x->name_count; - for (n = 0; n < f->name_count; n++) + for (n = 0; n < (int) f->name_count; n++) f->names[n] = x->names[n]; f->error_message = x->error_message; f->status = x->status; diff --git a/src/main.cc b/src/main.cc index 5d4b0b1bbe..ccd60a5142 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,5 @@ /* - * $Id: main.cc,v 1.69 1996/08/30 22:39:30 wessels Exp $ + * $Id: main.cc,v 1.70 1996/09/12 03:24:06 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -118,6 +118,7 @@ int opt_foreground_rebuild = 0; int opt_zap_disk_store = 0; int opt_syslog_enable = 0; /* disabled by default */ int opt_no_ipcache = 0; /* use ipcache by default */ +static int opt_send_signal = -1;/* no signal to send */ int vhost_mode = 0; int unbuffered_logs = 1; /* debug and hierarhcy unbuffered by default */ int shutdown_pending = 0; /* set by SIGTERM handler (shut_down()) */ @@ -151,16 +152,19 @@ static void mainReinitialize _PARAMS((void)); static time_t mainMaintenance _PARAMS((void)); static void usage _PARAMS((void)); static void mainParseOptions _PARAMS((int, char **)); +static void sendSignal _PARAMS((void)); static void usage() { fprintf(stderr, "\ -Usage: %s [-hsvzCDFRUVY] [-f config-file] [-[au] port]\n\ +Usage: %s [-hsvzCDFRUVY] [-f config-file] [-[au] port] [-k signal]\n\ -a port Specify ASCII port number (default: %d).\n\ -f file Use given config-file instead of\n\ %s\n\ - -i Disable IP caching.\n\ -h Print help message.\n\ + -i Disable IP caching.\n\ + -k reconfigure|rotate|shutdown|kill|debug|check\n\ + Send signal to running copy and exit.\n\ -s Enable logging to syslog.\n\ -u port Specify ICP port number (default: %d), disable with 0.\n\ -v Print version.\n\ @@ -183,7 +187,7 @@ static void mainParseOptions(argc, argv) extern char *optarg; int c; - while ((c = getopt(argc, argv, "CDFRUVYa:bf:him:su:vz?")) != -1) { + while ((c = getopt(argc, argv, "CDFRUVYa:bf:hik:m:su:vz?")) != -1) { switch (c) { case 'C': opt_catch_signals = 0; @@ -222,6 +226,24 @@ static void mainParseOptions(argc, argv) case 'i': opt_no_ipcache = 1; break; + case 'k': + if (strlen(optarg) < 1) + usage(); + if (!strncmp(optarg, "reconfigure", strlen(optarg))) + opt_send_signal = SIGHUP; + else if (!strncmp(optarg, "rotate", strlen(optarg))) + opt_send_signal = SIGUSR1; + else if (!strncmp(optarg, "debug", strlen(optarg))) + opt_send_signal = SIGUSR2; + else if (!strncmp(optarg, "shutdown", strlen(optarg))) + opt_send_signal = SIGTERM; + else if (!strncmp(optarg, "kill", strlen(optarg))) + opt_send_signal = SIGKILL; + else if (!strncmp(optarg, "check", strlen(optarg))) + opt_send_signal = 0; /* SIGNULL */ + else + usage(); + break; case 'm': #if MALLOC_DBG malloc_debug_level = atoi(optarg); @@ -253,7 +275,7 @@ static void mainParseOptions(argc, argv) } } -void rotate_logs(sig) +static void rotate_logs(sig) int sig; { debug(21, 1, "rotate_logs: SIGUSR1 received.\n"); @@ -263,7 +285,7 @@ void rotate_logs(sig) #endif } -void reconfigure(sig) +static void reconfigure(sig) int sig; { debug(21, 1, "reconfigure: SIGHUP received\n"); @@ -315,7 +337,7 @@ void serverConnectionsOpen() theHttpConnection); if (!httpd_accel_mode || Config.Accel.withProxy) { - if ((port = Config.Port.icp) > 0) { + if ((port = Config.Port.icp) > (u_short) 0) { theInIcpConnection = comm_open(COMM_NONBLOCKING | COMM_DGRAM, Config.Addrs.udp_incoming, port, @@ -567,6 +589,12 @@ int main(argc, argv) mainParseOptions(argc, argv); + /* send signal to running copy and exit */ + if (opt_send_signal != -1) { + sendSignal(); + /* NOTREACHED */ + } + setMaxFD(); if (opt_catch_signals) @@ -644,3 +672,28 @@ int main(argc, argv) /* NOTREACHED */ return 0; } + +static void sendSignal() +{ + int pid; + debug_log = stderr; + if (ConfigFile == NULL) + ConfigFile = xstrdup(DefaultConfigFile); + parseConfigFile(ConfigFile); + pid = readPidFile(); + if (pid > 1) { + if (kill(pid, opt_send_signal) && + /* ignore permissions if just running check */ + !(opt_send_signal == 0 && errno == EPERM)) { + fprintf(stderr, "%s: ERROR: Could not send ", appname); + fprintf(stderr, "signal %d to process %d: %s\n", + opt_send_signal, pid, xstrerror()); + exit(1); + } + } else { + fprintf(stderr, "%s: ERROR: No running copy\n", appname); + exit(1); + } + /* signal successfully sent */ + exit(0); + } diff --git a/src/neighbors.cc b/src/neighbors.cc index 5a4d42bcdd..bf7b5e71e2 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,5 +1,5 @@ /* - * $Id: neighbors.cc,v 1.47 1996/09/12 00:31:12 wessels Exp $ + * $Id: neighbors.cc,v 1.48 1996/09/12 03:24:06 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -264,7 +264,7 @@ edge *getFirstEdge() return friends->edges_head; } -void neighborRemove(target) +static void neighborRemove(target) edge *target; { edge *e = NULL; diff --git a/src/tools.cc b/src/tools.cc index 05f4f61b65..782ad9e74a 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.53 1996/09/11 22:41:15 wessels Exp $ + * $Id: tools.cc,v 1.54 1996/09/12 03:24:08 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -477,6 +477,32 @@ void writePidFile() } +int readPidFile() +{ + FILE *pid_fp = NULL; + char *f = NULL; + int pid = -1; + + if ((f = Config.pidFilename) == NULL) { + fprintf(stderr, "%s: ERROR: No pid file name defined\n", appname); + exit(1); + } + pid_fp = fopen(f, "r"); + if (pid_fp != NULL) { + if (fscanf(pid_fp, "%d", &pid) != 1) + pid = 0; + fclose(pid_fp); + } else { + if (errno != ENOENT) { + fprintf(stderr, "%s: ERROR: Could not read pid file\n", appname); + fprintf(stderr, "\t%s: %s\n", f, xstrerror()); + exit(1); + } + } + return pid; +} + + void setMaxFD() { #if HAVE_SETRLIMIT -- 2.39.5