/*
- * $Id: client_side.cc,v 1.156 1997/11/21 17:51:46 wessels Exp $
+ * $Id: client_side.cc,v 1.157 1997/11/23 06:50:27 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
fail_ratio = 0.8; /* reset to something less than 1.0 */
}
#endif
+
+void
+clientHttpConnectionsOpen(void)
+{
+ ushortlist *u;
+ int fd;
+debug(0,0)("clientHttpConnectionsOpen\n");
+ for (u = Config.Port.http; u; u = u->next) {
+debug(0,0)("clientHttpConnectionsOpen: port=%d\n", (int) u->i);
+ enter_suid();
+ fd = comm_open(SOCK_STREAM,
+ 0,
+ Config.Addrs.tcp_incoming,
+ u->i,
+ COMM_NONBLOCKING,
+ "HTTP Socket");
+ leave_suid();
+ if (fd < 0)
+ continue;
+ comm_listen(fd);
+ commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
+ commSetDefer(fd, httpAcceptDefer, NULL);
+ debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
+ (int) u->i, fd);
+ HttpSockets[NHttpSockets++] = fd;
+ }
+ if (NHttpSockets < 1)
+ fatal("Cannot open HTTP Port");
+}
inet_ntoa(from.sin_addr),
ntohs(from.sin_port));
}
+
+void
+icpConnectionsOpen(void)
+{
+ u_short port;
+ struct in_addr addr;
+ struct sockaddr_in xaddr;
+ int x;
+ int len;
+ wordlist *s;
+ if (Config2.Accel.on && !Config.onoff.accel_with_proxy)
+ return;
+ if ((port = Config.Port.icp) <= 0)
+ return;
+ enter_suid();
+ theInIcpConnection = comm_open(SOCK_DGRAM,
+ 0,
+ Config.Addrs.udp_incoming,
+ port,
+ COMM_NONBLOCKING,
+ "ICP Port");
+ leave_suid();
+ if (theInIcpConnection < 0)
+ fatal("Cannot open ICP Port");
+ fd_note(theInIcpConnection, "ICP socket");
+ commSetSelect(theInIcpConnection,
+ COMM_SELECT_READ,
+ icpHandleUdp,
+ NULL, 0);
+ for (s = Config.mcast_group_list; s; s = s->next)
+ ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
+ debug(1, 1) ("Accepting ICP connections on port %d, FD %d.\n",
+ (int) port, theInIcpConnection);
+ if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
+ enter_suid();
+ theOutIcpConnection = comm_open(SOCK_DGRAM,
+ 0,
+ addr,
+ port,
+ COMM_NONBLOCKING,
+ "ICP Port");
+ leave_suid();
+ if (theOutIcpConnection < 0)
+ fatal("Cannot open Outgoing ICP Port");
+ commSetSelect(theOutIcpConnection,
+ COMM_SELECT_READ,
+ icpHandleUdp,
+ NULL, 0);
+ debug(1, 1) ("Accepting ICP connections on port %d, FD %d.\n",
+ (int) port, theInIcpConnection);
+ fd_note(theOutIcpConnection, "Outgoing ICP socket");
+ fd_note(theInIcpConnection, "Incoming ICP socket");
+ } else {
+ theOutIcpConnection = theInIcpConnection;
+ }
+ memset(&theOutICPAddr, '\0', sizeof(struct in_addr));
+ len = sizeof(struct sockaddr_in);
+ memset(&xaddr, '\0', len);
+ x = getsockname(theOutIcpConnection,
+ (struct sockaddr *) &xaddr, &len);
+ if (x < 0)
+ debug(50, 1) ("theOutIcpConnection FD %d: getsockname: %s\n",
+ theOutIcpConnection, xstrerror());
+ else
+ theOutICPAddr = xaddr.sin_addr;
+}
/*
- * $Id: main.cc,v 1.195 1997/11/21 05:55:53 wessels Exp $
+ * $Id: main.cc,v 1.196 1997/11/23 06:50:26 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
{
fprintf(stderr,
"Usage: %s [-svzCDFRUVY] [-f config-file] [-[au] port] [-k signal]\n"
- " -a port Specify ASCII port number (default: %d).\n"
+ " -a port Specify HTTP port number (default: %d).\n"
" -d Write debugging to stderr also.\n"
" -f file Use given config-file instead of\n"
" %s\n"
static void
serverConnectionsOpen(void)
{
- struct in_addr addr;
- struct sockaddr_in xaddr;
- u_short port;
- ushortlist *u;
- int len;
- int x;
- int fd;
- wordlist *s;
- for (u = Config.Port.http; u; u = u->next) {
- enter_suid();
- fd = comm_open(SOCK_STREAM,
- 0,
- Config.Addrs.tcp_incoming,
- u->i,
- COMM_NONBLOCKING,
- "HTTP Socket");
- leave_suid();
- if (fd < 0)
- continue;
- comm_listen(fd);
- commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
- commSetDefer(fd, httpAcceptDefer, NULL);
- debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
- (int) u->i, fd);
- HttpSockets[NHttpSockets++] = fd;
- }
- if (NHttpSockets < 1)
- fatal("Cannot open HTTP Port");
- if (!Config2.Accel.on || Config.onoff.accel_with_proxy) {
- if ((port = Config.Port.icp) > (u_short) 0) {
- enter_suid();
- theInIcpConnection = comm_open(SOCK_DGRAM,
- 0,
- Config.Addrs.udp_incoming,
- port,
- COMM_NONBLOCKING,
- "ICP Port");
- leave_suid();
- if (theInIcpConnection < 0)
- fatal("Cannot open ICP Port");
- fd_note(theInIcpConnection, "ICP socket");
- commSetSelect(theInIcpConnection,
- COMM_SELECT_READ,
- icpHandleUdp,
- NULL, 0);
- for (s = Config.mcast_group_list; s; s = s->next)
- ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
- debug(1, 1) ("Accepting ICP connections on port %d, FD %d.\n",
- (int) port, theInIcpConnection);
-
- if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
- enter_suid();
- theOutIcpConnection = comm_open(SOCK_DGRAM,
- 0,
- addr,
- port,
- COMM_NONBLOCKING,
- "ICP Port");
- leave_suid();
- if (theOutIcpConnection < 0)
- fatal("Cannot open Outgoing ICP Port");
- commSetSelect(theOutIcpConnection,
- COMM_SELECT_READ,
- icpHandleUdp,
- NULL, 0);
- debug(1, 1) ("Accepting ICP connections on port %d, FD %d.\n",
- (int) port, theInIcpConnection);
- fd_note(theOutIcpConnection, "Outgoing ICP socket");
- fd_note(theInIcpConnection, "Incoming ICP socket");
- } else {
- theOutIcpConnection = theInIcpConnection;
- }
- memset(&theOutICPAddr, '\0', sizeof(struct in_addr));
- len = sizeof(struct sockaddr_in);
- memset(&xaddr, '\0', len);
- x = getsockname(theOutIcpConnection,
- (struct sockaddr *) &xaddr, &len);
- if (x < 0)
- debug(50, 1) ("theOutIcpConnection FD %d: getsockname: %s\n",
- theOutIcpConnection, xstrerror());
- else
- theOutICPAddr = xaddr.sin_addr;
- }
- }
+ clientHttpConnectionsOpen();
+ icpConnectionsOpen();
#ifdef SQUID_SNMP
snmpConnectionOpen();
#endif
-
clientdbInit();
icmpOpen();
netdbInit();
}
if (icmp_sock > -1)
icmpClose();
+#ifdef SQUID_SNMP
+ snmpConnectionClose();
+#endif
}
static void
{
debug(1, 0) ("Restarting Squid Cache (version %s)...\n", version_string);
/* Already called serverConnectionsClose and ipcacheShutdownServers() */
+ serverConnectionsClose();
+ if (theOutIcpConnection > 0) {
+ comm_close(theOutIcpConnection);
+ theOutIcpConnection = -1;
+ }
+ dnsShutdownServers();
+ redirectShutdownServers();
storeDirCloseSwapLogs();
parseConfigFile(ConfigFile);
_db_init(Config.Log.log, Config.debugOptions);
/* main loop */
for (;;) {
- if (rotate_pending) {
+ if (reconfigure_pending) {
+ mainReconfigure();
+ reconfigure_pending = 0; /* reset */
+ } else if (rotate_pending) {
icmpClose();
_db_rotate_log(); /* cache.log */
storeWriteCleanLogs(1);
}
if (shutdown_pending) {
normal_shutdown();
+#if 0
} else if (reconfigure_pending) {
mainReconfigure();
reconfigure_pending = 0; /* reset */
+#endif
} else {
fatal_dump("MAIN: SHUTDOWN from comm_select, but nothing pending.");
}