/*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * 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.
#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;
}
+