From: wessels <> Date: Tue, 31 Mar 1998 11:45:24 +0000 (+0000) Subject: Added HTCP socket close functions X-Git-Tag: SQUID_3_0_PRE1~3685 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72549e05e95efe58c7547f19e3fa0bcb557ffd1e;p=thirdparty%2Fsquid.git Added HTCP socket close functions --- diff --git a/src/htcp.cc b/src/htcp.cc index ded3492885..e8fc3f6890 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -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); + } +} diff --git a/src/main.cc b/src/main.cc index f190d86072..0e158847a1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 diff --git a/src/protos.h b/src/protos.h index 7a1ba448eb..f036dbba1d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 */