/*
- * DEBUG: section 54 Interprocess Communication
- * AUTHOR: Duane Wessels
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 54 Interprocess Communication */
+
#include "squid.h"
#include "comm/Connection.h"
#include "fd.h"
#include "tools.h"
static const char *hello_string = "hi there\n";
+#ifndef HELLO_BUF_SZ
#define HELLO_BUF_SZ 32
+#endif
static char hello_buf[HELLO_BUF_SZ];
static int
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_STREAM,
- 0, /* protocol */
+ 0, /* protocol */
local_addr,
- 0, /* blocking */
+ 0, /* blocking */
name);
IPC_CHECK_FAIL(crfd, "child read", "TCP " << local_addr);
IPC_CHECK_FAIL(prfd, "parent read", "TCP " << local_addr);
debugs(54, 3, "ipcCreate: cwfd FD " << cwfd);
if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) {
- Ip::Address::InitAddrInfo(AI);
+ Ip::Address::InitAddr(AI);
if (getsockname(pwfd, AI->ai_addr, &AI->ai_addrlen) < 0) {
- Ip::Address::FreeAddrInfo(AI);
+ Ip::Address::FreeAddr(AI);
debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << PaS);
- Ip::Address::FreeAddrInfo(AI);
+ Ip::Address::FreeAddr(AI);
- Ip::Address::InitAddrInfo(AI);
+ Ip::Address::InitAddr(AI);
if (getsockname(crfd, AI->ai_addr, &AI->ai_addrlen) < 0) {
- Ip::Address::FreeAddrInfo(AI);
+ Ip::Address::FreeAddr(AI);
debugs(54, DBG_CRITICAL, "ipcCreate: getsockname: " << xstrerror());
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
ChS = *AI;
- Ip::Address::FreeAddrInfo(AI);
+ Ip::Address::FreeAddr(AI);
debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << ChS );
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- if (pid > 0) { /* parent */
+ if (pid > 0) { /* parent */
/* close shared socket with child */
comm_close(crfd);
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- memset(hello_buf, '\0', HELLO_BUF_SZ);
-
if (type == IPC_UDP_SOCKET)
- x = comm_udp_recv(prfd, hello_buf, HELLO_BUF_SZ - 1, 0);
+ x = comm_udp_recv(prfd, hello_buf, sizeof(hello_buf)-1, 0);
else
- x = read(prfd, hello_buf, HELLO_BUF_SZ - 1);
+ x = read(prfd, hello_buf, sizeof(hello_buf)-1);
+ if (x >= 0)
+ hello_buf[x+1] = '\0';
if (x < 0) {
debugs(54, DBG_CRITICAL, "ipcCreate: PARENT: hello read test failed");
/* child */
TheProcessKind = pkHelper;
- no_suid(); /* give up extra priviliges */
+ no_suid(); /* give up extra priviliges */
/* close shared socket with parent */
close(prfd);
return 0;
}
+