From: hno <> Date: Fri, 5 Apr 2002 06:59:25 +0000 (+0000) Subject: UNIX domain IPC sockets support X-Git-Tag: SQUID_3_0_PRE1~1129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ccc0d40ac1f945a3eedf215dbf8423e7da1a10d;p=thirdparty%2Fsquid.git UNIX domain IPC sockets support Centralised the IPC type selection to defines.h by the defines IPC_STREAM and IPC_DGRAM. --- diff --git a/configure.in b/configure.in index 1c794bd22d..ad2d38c2d9 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.259 2002/04/01 13:06:28 hno Exp $ +dnl $Id: configure.in,v 1.260 2002/04/04 23:59:25 hno Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.6-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.259 $)dnl +AC_REVISION($Revision: 1.260 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1612,6 +1612,7 @@ AC_CHECK_FUNCS(\ setsid \ sigaction \ snprintf \ + socketpair \ srand48 \ srandom \ statfs \ diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index b45faa261f..ff57cad432 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -1,5 +1,5 @@ /* - * $Id: auth_basic.cc,v 1.14 2001/10/24 05:26:12 hno Exp $ + * $Id: auth_basic.cc,v 1.15 2002/04/04 23:59:26 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -543,7 +543,7 @@ authBasicInit(authScheme * scheme) basicauthenticators = helperCreate("basicauthenticator"); basicauthenticators->cmdline = basicConfig->authenticate; basicauthenticators->n_to_start = basicConfig->authenticateChildren; - basicauthenticators->ipc_type = IPC_TCP_SOCKET; + basicauthenticators->ipc_type = IPC_STREAM; helperOpenServers(basicauthenticators); if (!init) { cachemgrRegister("basicauthenticator", diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index dc2d12ca33..d9a73af734 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.11 2002/01/13 01:08:44 robertc Exp $ + * $Id: auth_digest.cc,v 1.12 2002/04/04 23:59:27 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -881,7 +881,7 @@ authDigestInit(authScheme * scheme) digestauthenticators = helperCreate("digestauthenticator"); digestauthenticators->cmdline = digestConfig->authenticate; digestauthenticators->n_to_start = digestConfig->authenticateChildren; - digestauthenticators->ipc_type = IPC_TCP_SOCKET; + digestauthenticators->ipc_type = IPC_STREAM; helperOpenServers(digestauthenticators); if (!init) { cachemgrRegister("digestauthenticator", "User Authenticator Stats", diff --git a/src/auth/ntlm/auth_ntlm.cc b/src/auth/ntlm/auth_ntlm.cc index 1b92464138..3b64922a7b 100644 --- a/src/auth/ntlm/auth_ntlm.cc +++ b/src/auth/ntlm/auth_ntlm.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_ntlm.cc,v 1.18 2002/02/18 23:32:53 hno Exp $ + * $Id: auth_ntlm.cc,v 1.19 2002/04/04 23:59:27 hno Exp $ * * DEBUG: section 29 NTLM Authenticator * AUTHOR: Robert Collins @@ -242,7 +242,7 @@ authNTLMInit(authScheme * scheme) assert(proxy_auth_cache); ntlmauthenticators->cmdline = ntlmConfig->authenticate; ntlmauthenticators->n_to_start = ntlmConfig->authenticateChildren; - ntlmauthenticators->ipc_type = IPC_TCP_SOCKET; + ntlmauthenticators->ipc_type = IPC_STREAM; ntlmauthenticators->datapool = ntlm_helper_state_pool; ntlmauthenticators->IsAvailable = authenticateNTLMHelperServerAvailable; ntlmauthenticators->OnEmptyQueue = authenticateNTLMHelperServerOnEmpty; diff --git a/src/defines.h b/src/defines.h index 8eadc43a36..76699c2f17 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.99 2002/02/26 15:48:14 adrian Exp $ + * $Id: defines.h,v 1.100 2002/04/04 23:59:25 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -193,6 +193,16 @@ #define IPC_TCP_SOCKET 1 #define IPC_UDP_SOCKET 2 #define IPC_FIFO 3 +#define IPC_UNIX_STREAM 4 +#define IPC_UNIX_DGRAM 5 + +#if HAVE_SOCKETPAIR && defined (AF_UNIX) +#define IPC_STREAM IPC_UNIX_STREAM +#define IPC_DGRAM IPC_UNIX_DGRAM +#else +#define IPC_STREAM IPC_TCP_SOCKET +#define IPC_DGRAM IPC_UDP_SOCKET +#endif #define STORE_META_KEY STORE_META_KEY_MD5 diff --git a/src/dns.cc b/src/dns.cc index 03524999f3..600bfdcda5 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,6 +1,6 @@ /* - * $Id: dns.cc,v 1.86 2001/03/13 23:22:42 wessels Exp $ + * $Id: dns.cc,v 1.87 2002/04/04 23:59:25 hno Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -54,7 +54,7 @@ dnsInit(void) if (dnsservers == NULL) dnsservers = helperCreate("dnsserver"); dnsservers->n_to_start = Config.dnsChildren; - dnsservers->ipc_type = IPC_TCP_SOCKET; + dnsservers->ipc_type = IPC_STREAM; assert(dnsservers->cmdline == NULL); wordlistAdd(&dnsservers->cmdline, Config.Program.dnsserver); if (Config.onoff.res_defnames) diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index a5ff2178e9..ca69be98db 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.60 2002/04/01 21:53:21 hno Exp $ + * $Id: store_dir_diskd.cc,v 1.61 2002/04/04 23:59:28 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -410,12 +410,7 @@ storeDiskdDirInit(SwapDir * sd) args[2] = skey2; args[3] = skey3; args[4] = NULL; -#if HAVE_POLL && defined(_SQUID_OSF_) - /* pipes and poll() don't get along on DUNIX -DW */ - x = ipcCreate(IPC_TCP_SOCKET, -#else - x = ipcCreate(IPC_FIFO, -#endif + x = ipcCreate(IPC_STREAM, Config.Program.diskd, args, "diskd", diff --git a/src/icmp.cc b/src/icmp.cc index 040d3ed95a..3e7a69cd3e 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -1,6 +1,6 @@ /* - * $Id: icmp.cc,v 1.74 2002/03/31 14:50:21 hno Exp $ + * $Id: icmp.cc,v 1.75 2002/04/04 23:59:25 hno Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -196,7 +196,7 @@ icmpOpen(void) int wfd; args[0] = "(pinger)"; args[1] = NULL; - x = ipcCreate(IPC_UDP_SOCKET, + x = ipcCreate(IPC_DGRAM, Config.Program.pinger, args, "Pinger Socket", @@ -206,6 +206,7 @@ icmpOpen(void) return; assert(rfd == wfd); icmp_sock = rfd; + fd_note(icmp_sock, "pinger"); commSetSelect(icmp_sock, COMM_SELECT_READ, icmpRecv, NULL, 0); commSetTimeout(icmp_sock, -1, NULL, NULL); debug(29, 1) ("Pinger socket opened on FD %d\n", icmp_sock); diff --git a/src/ipc.cc b/src/ipc.cc index 756685260f..947b2822a3 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -1,6 +1,6 @@ /* - * $Id: ipc.cc,v 1.27 2001/12/24 15:33:43 adrian Exp $ + * $Id: ipc.cc,v 1.28 2002/04/04 23:59:25 hno Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -123,6 +123,29 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name fd_open(cwfd = p2c[1], FD_PIPE, "IPC FIFO Child Write"); fd_open(crfd = c2p[0], FD_PIPE, "IPC FIFO Child Read"); fd_open(pwfd = c2p[1], FD_PIPE, "IPC FIFO Parent Write"); +#if HAVE_SOCKETPAIR && defined(AF_UNIX) + } else if (type == IPC_UNIX_STREAM) { + int fds[2]; + int buflen = 32768; + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { + debug(50, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); + return -1; + } + setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, (void *) &buflen, sizeof(buflen)); + setsockopt(fds[0], SOL_SOCKET, SO_RCVBUF, (void *) &buflen, sizeof(buflen)); + setsockopt(fds[1], SOL_SOCKET, SO_SNDBUF, (void *) &buflen, sizeof(buflen)); + setsockopt(fds[1], SOL_SOCKET, SO_RCVBUF, (void *) &buflen, sizeof(buflen)); + fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX STREAM Parent"); + fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX STREAM Parent"); + } else if (type == IPC_UNIX_DGRAM) { + int fds[2]; + if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) < 0) { + debug(50, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); + return -1; + } + fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX DGRAM Parent"); + fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX DGRAM Parent"); +#endif } else { assert(IPC_NONE); } diff --git a/src/redirect.cc b/src/redirect.cc index 60f11c50ed..c1364a5fdb 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.88 2001/03/03 10:39:33 hno Exp $ + * $Id: redirect.cc,v 1.89 2002/04/04 23:59:25 hno Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -158,7 +158,7 @@ redirectInit(void) redirectors = helperCreate("redirector"); redirectors->cmdline = Config.Program.redirect; redirectors->n_to_start = Config.redirectChildren; - redirectors->ipc_type = IPC_TCP_SOCKET; + redirectors->ipc_type = IPC_STREAM; helperOpenServers(redirectors); if (!init) { cachemgrRegister("redirector", diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 7d897759ea..880d72a67c 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,6 +1,6 @@ /* - * $Id: unlinkd.cc,v 1.45 2001/12/24 15:33:44 adrian Exp $ + * $Id: unlinkd.cc,v 1.46 2002/04/04 23:59:26 hno Exp $ * * DEBUG: section 12 Unlink Daemon * AUTHOR: Duane Wessels @@ -165,8 +165,9 @@ unlinkdInit(void) args[1] = NULL; #if USE_POLL && defined(_SQUID_OSF_) /* pipes and poll() don't get along on DUNIX -DW */ - x = ipcCreate(IPC_TCP_SOCKET, + x = ipcCreate(IPC_STREAM, #else + /* We currently need to use FIFO.. see below */ x = ipcCreate(IPC_FIFO, #endif Config.Program.unlinkd,