From: wessels <> Date: Sat, 7 Feb 1998 06:58:03 +0000 (+0000) Subject: Fix closing in/out UDP sockets for both ICP and SNMP X-Git-Tag: SQUID_3_0_PRE1~4140 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17e6c0a10c9705e03112f5a0ce55344630acc939;p=thirdparty%2Fsquid.git Fix closing in/out UDP sockets for both ICP and SNMP --- diff --git a/src/icp_v2.cc b/src/icp_v2.cc index d6dbee2bd2..47f3051487 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -359,7 +359,7 @@ icpConnectionsOpen(void) NULL, 0); for (s = Config.mcast_group_list; s; s = s->next) ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); - debug(1, 1) ("Accepting ICP messages on port %d, FD %d.\n", + debug(12, 1) ("Accepting ICP messages on port %d, FD %d.\n", (int) port, theInIcpConnection); if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) { enter_suid(); @@ -376,7 +376,7 @@ icpConnectionsOpen(void) COMM_SELECT_READ, icpHandleUdp, NULL, 0); - debug(1, 1) ("Outgoing ICP messages on port %d, FD %d.\n", + debug(12, 1) ("Outgoing ICP messages on port %d, FD %d.\n", (int) port, theOutIcpConnection); fd_note(theOutIcpConnection, "Outgoing ICP socket"); fd_note(theInIcpConnection, "Incoming ICP socket"); @@ -395,14 +395,19 @@ icpConnectionsOpen(void) theOutICPAddr = xaddr.sin_addr; } +/* + * icpConnectionShutdown only closes the 'in' socket if it is + * different than the 'out' socket. + */ void -icpConnectionsClose(void) +icpConnectionShutdown(void) { if (theInIcpConnection < 0) return; - debug(1, 1) ("FD %d Closing ICP connection\n", theInIcpConnection); - if (theInIcpConnection != theOutIcpConnection) + if (theInIcpConnection != theOutIcpConnection) { + debug(12, 1) ("FD %d Closing ICP connection\n", theInIcpConnection); comm_close(theInIcpConnection); + } /* * Here we set 'theInIcpConnection' to -1 even though the ICP 'in' * and 'out' sockets might be just one FD. This prevents this @@ -419,3 +424,13 @@ icpConnectionsClose(void) assert(theOutIcpConnection > -1); commSetSelect(theOutIcpConnection, COMM_SELECT_READ, NULL, NULL, 0); } + +void +icpConnectionClose(void) +{ + icpConnectionShutdown(); + if (theOutIcpConnection > -1) { + debug(12, 1) ("FD %d Closing ICP connection\n", theOutIcpConnection); + comm_close(theOutIcpConnection); + } +} diff --git a/src/main.cc b/src/main.cc index 7d50aa3150..6ccd5042fb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.214 1998/02/06 17:30:53 wessels Exp $ + * $Id: main.cc,v 1.215 1998/02/06 23:58:04 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -339,10 +339,10 @@ serverConnectionsClose(void) * is pending */ clientHttpConnectionsClose(); - icpConnectionsClose(); + icpConnectionShutdown(); icmpClose(); #ifdef SQUID_SNMP - snmpConnectionClose(); + snmpConnectionShutdown(); #endif } @@ -352,16 +352,14 @@ mainReconfigure(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; - } + icpConnectionClose(); +#ifdef SQUID_SNMP + snmpConnectionClose(); +#endif dnsShutdownServers(); asnCleanup(); redirectShutdownServers(); -#if 0 storeDirCloseSwapLogs(); -#endif errorFree(); parseConfigFile(ConfigFile); _db_init(Config.Log.log, Config.debugOptions); @@ -601,10 +599,8 @@ main(int argc, char **argv) break; case COMM_SHUTDOWN: /* delayed close so we can transmit while shutdown pending */ - if (theOutIcpConnection > 0) { - comm_close(theOutIcpConnection); - theOutIcpConnection = -1; - } + icpConnectionClose(); + snmpConnectionClose(); if (shutdown_pending) { normal_shutdown(); #if 0 diff --git a/src/protos.h b/src/protos.h index 6d1039dc26..9eda3bae9c 100644 --- a/src/protos.h +++ b/src/protos.h @@ -244,6 +244,7 @@ extern DEFER httpAcceptDefer; extern PF snmpHandleUdp; extern void snmpInit(void); extern void snmpConnectionOpen(void); +extern void snmpConnectionShutdown(void); extern void snmpConnectionClose(void); extern int create_view(char **); extern int create_user(char **); @@ -257,7 +258,8 @@ extern PF icpUdpReply; extern void icpHandleIcpV3(int, struct sockaddr_in, char *, int); extern int icpCheckUdpHit(StoreEntry *, request_t * request); extern void icpConnectionsOpen(void); -extern void icpConnectionsClose(void); +extern void icpConnectionShutdown(void); +extern void icpConnectionClose(void); extern void ipcache_nbgethostbyname(const char *name, IPH * handler,