/*
- * $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
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;
+}
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);
+}
/*
- * $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
* 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
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);
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,