]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed up 'fooConnectionsClose()' functions. created icpConnectionsClose()
authorwessels <>
Wed, 7 Jan 1998 01:12:22 +0000 (01:12 +0000)
committerwessels <>
Wed, 7 Jan 1998 01:12:22 +0000 (01:12 +0000)
and clientHttpConnectionsClose().  For the UDP sockets, fixed a
bug which caused us to try closing the same FD twice.

src/client_side.cc
src/icp_v2.cc
src/main.cc
src/protos.h

index e347ecbc166cdf94ac613594ef6ba93bb58784c2..25bc2e889f25978a8089739588a10b09cb8532a2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.192 1998/01/06 05:15:39 wessels Exp $
+ * $Id: client_side.cc,v 1.193 1998/01/06 18:12:22 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1993,3 +1993,17 @@ clientHttpConnectionsOpen(void)
     if (NHttpSockets < 1)
        fatal("Cannot open HTTP Port");
 }
+
+void
+clientHttpConnectionsClose(void)
+{
+    int i;
+    for (i = 0; i < NHttpSockets; i++) {
+       if (HttpSockets[i] >= 0) {
+           debug(1, 1) ("FD %d Closing HTTP connection\n", HttpSockets[i]);
+           comm_close(HttpSockets[i]);
+           HttpSockets[i] = -1;
+       }
+    }
+    NHttpSockets = 0;
+}
index 426d3c784e9fa56dc684574f7487e27fbd208ffb..96a3911164dbed4be4ffcdb85c4fbff40c014452 100644 (file)
@@ -495,3 +495,28 @@ icpConnectionsOpen(void)
     else
        theOutICPAddr = xaddr.sin_addr;
 }
+
+void
+icpConnectionsClose(void)
+{
+    if (theInIcpConnection < 0)
+       return;
+    debug(1, 1) ("FD %d Closing ICP connection\n", theInIcpConnection);
+    if (theInIcpConnection != theOutIcpConnection)
+       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
+     * function from executing repeatedly.  When we are really ready to
+     * exit or restart, main will comm_close the 'out' descriptor.
+     */
+    theInIcpConnection = -1;
+    /*
+     * Normally we only write to the outgoing ICP socket, but
+     * we also have a read handler there to catch messages sent
+     * to that specific interface.  During shutdown, we must
+     * disable reading on the outgoing socket.
+     */
+    assert(theOutIcpConnection > -1);
+    commSetSelect(theOutIcpConnection, COMM_SELECT_READ, NULL, NULL, 0);
+}
index 3ce3c357a4b8e353eb826fabb79cf2221e6893cf..56a77c0f5fe6b9149be0871f58b85b0a1481c7be 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.203 1998/01/06 07:11:53 wessels Exp $
+ * $Id: main.cc,v 1.204 1998/01/06 18:12:23 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -337,47 +337,9 @@ serverConnectionsClose(void)
      * NOTE, this function will be called repeatedly while shutdown
      * is pending
      */
-    int i;
-    for (i = 0; i < NHttpSockets; i++) {
-       if (HttpSockets[i] >= 0) {
-           debug(1, 1) ("FD %d Closing HTTP connection\n", HttpSockets[i]);
-           comm_close(HttpSockets[i]);
-           HttpSockets[i] = -1;
-       }
-    }
-    NHttpSockets = 0;
-    if (theInIcpConnection > -1) {
-       /*
-        * NOTE, don't close outgoing ICP connection, we need to write
-        * to it during shutdown.
-        */
-       debug(1, 1) ("FD %d Closing ICP connection\n",
-           theInIcpConnection);
-       if (theInIcpConnection != theOutIcpConnection) {
-           comm_close(theInIcpConnection);
-           assert(theOutIcpConnection > -1);
-           /*
-            * Normally we only write to the outgoing ICP socket, but
-            * we also have a read handler there to catch messages sent
-            * to that specific interface.  During shutdown, we must
-            * disable reading on the outgoing socket.
-            */
-           commSetSelect(theOutIcpConnection,
-               COMM_SELECT_READ,
-               NULL,
-               NULL,
-               0);
-       } else {
-           commSetSelect(theInIcpConnection,
-               COMM_SELECT_READ,
-               NULL,
-               NULL,
-               0);
-       }
-       theInIcpConnection = -1;
-    }
-    if (icmp_sock > -1)
-       icmpClose();
+    clientHttpConnectionsClose();
+    icpConnectionsClose();
+    icmpClose();
 #ifdef SQUID_SNMP
     snmpConnectionClose();
 #endif
index abfefe63990e0849cd6d1e48557cceb9cf289fa9..bd7c84549dcc2b1ccb19738d68b41bdc7ad2eb5f 100644 (file)
@@ -77,6 +77,7 @@ extern char *clientConstructTraceEcho(clientHttpRequest *);
 extern void clientPurgeRequest(clientHttpRequest *);
 extern int checkNegativeHit(StoreEntry *);
 extern void clientHttpConnectionsOpen(void);
+extern void clientHttpConnectionsClose(void);
 extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, int);
 
 extern int commSetNonBlocking(int fd);
@@ -267,6 +268,7 @@ extern int icpCheckUdpHitObj(StoreEntry * e, request_t * r, icp_common_t * h, in
 extern void *icpCreateHitObjMessage(icp_opcode, int, const char *, int, int, StoreEntry *);
 #endif
 extern void icpConnectionsOpen(void);
+extern void icpConnectionsClose(void);
 
 extern void ipcache_nbgethostbyname(const char *name,
     IPH * handler,