From: Amos Jeffries Date: Mon, 8 Oct 2012 08:11:02 +0000 (-0600) Subject: Windows: drop unused WIN32_pipe() implementation X-Git-Tag: SQUID_3_4_0_1~593 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5def7931285e3ce2b1a66b5a2239dae8ec5d12d8;p=thirdparty%2Fsquid.git Windows: drop unused WIN32_pipe() implementation The WIN32_pipe() wrapper function is not necessary on MinGW where _pipe() is available, and is unused on other Windows builds where helper IPC layer has been written to use STREAM sockets instead of pipe() --- diff --git a/compat/os/mswin.h b/compat/os/mswin.h index c23c4d9e3d..4cc1b0d0aa 100644 --- a/compat/os/mswin.h +++ b/compat/os/mswin.h @@ -107,7 +107,6 @@ SQUIDCEXTERN int WIN32_truncate(const char *pathname, off_t length); #define mkdir(p,F) mkdir((p)) #endif #define pclose _pclose -#define pipe WIN32_pipe #define popen _popen #define putenv _putenv #define setmode _setmode @@ -652,6 +651,13 @@ int socket(int f, int t, int p) } #define socket(f,t,p) Squid::socket(f,t,p) +inline int +pipe(int pipefd[2]) +{ + return _pipe(pipefd,4096,_O_BINARY); +} +using Squid::pipe; + inline int WSAAsyncSelect(int s, HWND h, unsigned int w, long e) { diff --git a/src/win32.cc b/src/win32.cc index 4ee568e76b..1fe62cf779 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -48,68 +48,6 @@ SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex; void WIN32_ExceptionHandlerCleanup(void); static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = NULL; -int WIN32_pipe(int handles[2]) -{ - int new_socket; - fde *F = NULL; - - Ip::Address localhost; - Ip::Address handle0; - Ip::Address handle1; - struct addrinfo *AI = NULL; - - localhost.SetLocalhost(); - - /* INET6: back-compatible: localhost pipes default to IPv4 unless set otherwise. - * it is blocked by untested helpers on many admins configs - * if this proves to be wrong it can die easily. - */ - localhost.SetIPv4(); - - handles[0] = handles[1] = -1; - - ++statCounter.syscalls.sock.sockets; - - handle0 = localhost; - handle0.SetPort(0); - handle0.GetAddrInfo(AI); - - if ((new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0) - return -1; - - if (bind(new_socket, AI->ai_addr, AI->ai_addrlen) < 0 || - listen(new_socket, 1) < 0 || getsockname(new_socket, AI->ai_addr, &(AI->ai_addrlen) ) < 0 || - (handles[1] = socket(AI->ai_family, AI->ai_socktype, 0)) < 0) { - closesocket(new_socket); - return -1; - } - - handle0 = *AI; // retrieve the new details returned by connect() - - handle1.SetPort(handle1.GetPort()); - handle1.GetAddrInfo(AI); - - if (connect(handles[1], AI->ai_addr, AI->ai_addrlen) < 0 || - (handles[0] = accept(new_socket, AI->ai_addr, &(AI->ai_addrlen)) ) < 0) { - closesocket(handles[1]); - handles[1] = -1; - closesocket(new_socket); - return -1; - } - - closesocket(new_socket); - - F = &fd_table[handles[0]]; - F->local_addr = handle0; - - F = &fd_table[handles[1]]; - F->local_addr = localhost; - handle1.NtoA(F->ipaddr, MAX_IPSTRLEN); - F->remote_port = handle1.GetPort(); - - return 0; -} - int Win32__WSAFDIsSet(int fd, fd_set FAR * set) { @@ -162,4 +100,4 @@ void WIN32_ExceptionHandlerCleanup() SetUnhandledExceptionFilter(Win32_Old_ExceptionHandler); } -#endif /* SQUID_MSWIN_ */ +#endif /* SQUID_WINDOWS_ */ diff --git a/src/win32.h b/src/win32.h index 292fb891e0..d222c21882 100644 --- a/src/win32.h +++ b/src/win32.h @@ -48,8 +48,6 @@ #include #endif -int WIN32_pipe(int[2]); - void WIN32_ExceptionHandlerInit(void); int Win32__WSAFDIsSet(int fd, fd_set* set);