]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added HTCP socket close functions
authorwessels <>
Tue, 31 Mar 1998 11:45:24 +0000 (11:45 +0000)
committerwessels <>
Tue, 31 Mar 1998 11:45:24 +0000 (11:45 +0000)
src/htcp.cc
src/main.cc
src/protos.h

index ded34928858354c09ee9db4a79ad1ae9eae37352..e8fc3f689029bdabb92c688c5f881cce48839f81 100644 (file)
@@ -532,3 +532,43 @@ htcpInit(void)
        htcpOutSocket = htcpInSocket;
     }
 }
+
+/*  
+ * htcpSocketShutdown only closes the 'in' socket if it is
+ * different than the 'out' socket.
+ */ 
+void
+htcpSocketShutdown(void)
+{   
+    if (htcpInSocket < 0)
+        return;
+    if (htcpInSocket != htcpOutSocket) { 
+        debug(12, 1) ("FD %d Closing HTCP socket\n", htcpInSocket);
+        comm_close(htcpInSocket);
+    }       
+    /*      
+     * Here we set 'htcpInSocket' to -1 even though the HTCP '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.
+     */     
+    htcpInSocket = -1;
+    /*      
+     * Normally we only write to the outgoing HTCP 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(htcpOutSocket > -1);
+    commSetSelect(htcpOutSocket, COMM_SELECT_READ, NULL, NULL, 0);
+}
+
+void    
+htcpSocketClose(void)
+{
+    htcpSocketShutdown();
+    if (htcpOutSocket > -1) {
+        debug(12, 1) ("FD %d Closing HTCP socket\n", htcpOutSocket);
+        comm_close(htcpOutSocket);
+    }   
+}   
index f190d86072f884b0e0c5a68ef88de244c3b9ffc0..0e158847a1dade4044b9f8257916285086d1604b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.240 1998/03/31 04:09:51 wessels Exp $
+ * $Id: main.cc,v 1.241 1998/03/31 04:45:24 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -352,6 +352,9 @@ serverConnectionsClose(void)
      */
     clientHttpConnectionsClose();
     icpConnectionShutdown();
+#if USE_HTCP
+    htcpSocketShutdown();
+#endif
     icmpClose();
 #ifdef SQUID_SNMP
     snmpConnectionShutdown();
@@ -366,6 +369,9 @@ mainReconfigure(void)
     /* Already called serverConnectionsClose and ipcacheShutdownServers() */
     serverConnectionsClose();
     icpConnectionClose();
+#if USE_HTCP
+    htcpSocketClose();
+#endif
 #ifdef SQUID_SNMP
     snmpConnectionClose();
 #endif
@@ -629,6 +635,9 @@ main(int argc, char **argv)
        case COMM_SHUTDOWN:
            /* delayed close so we can transmit while shutdown pending */
            icpConnectionClose();
+#if USE_HTCP
+           htcpSocketClose();
+#endif
 #ifdef SQUID_SNMP
            snmpConnectionClose();
 #endif
index 7a1ba448eb2587e31f58633490a24d52c2483200..f036dbba1dd14a2e3338cf8ec92509195b535b51 100644 (file)
@@ -450,7 +450,10 @@ extern FREE *memBufFreeFunc(MemBuf * mb);
 extern void memBufReport(MemBuf * mb);
 
 extern char *mime_get_header(const char *mime, const char *header);
+#if OLD_CODE
 extern char *mime_headers_end(const char *mime);
+#endif
+extern size_t headersEnd(const char *, size_t);
 extern int mk_mime_hdr(char *result, const char *type, int size, time_t ttl, time_t lmt);
 extern const char *mime_get_auth(const char *hdr, const char *auth_scheme, const char **auth_field);
 
@@ -854,6 +857,8 @@ extern void gb_flush(gb_t *);       /* internal, do not use this */
 #if USE_HTCP
 extern void htcpInit(void);
 extern void htcpQuery(StoreEntry * e, request_t * req, peer * p);
+void htcpSocketShutdown(void);
+void htcpSocketClose(void);
 #endif
 
 /* String */