--------------------- PatchSet 5964 Date: 2003/10/08 20:32:18 Author: serassio Branch: nt-2_5 Tag: (none) Log: Latest socket changes are not compatible with NT 4.0, this fix allow Squid run on it with a whorse stability Members: src/ipc.c:1.7.10.12->1.7.10.13 src/win32.c:1.5.14.17->1.5.14.18 Index: squid/src/ipc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipc.c,v retrieving revision 1.7.10.12 retrieving revision 1.7.10.13 diff -u -r1.7.10.12 -r1.7.10.13 --- squid/src/ipc.c 18 Aug 2003 15:35:29 -0000 1.7.10.12 +++ squid/src/ipc.c 8 Oct 2003 20:32:18 -0000 1.7.10.13 @@ -1,6 +1,6 @@ /* - * $Id: ipc.c,v 1.7.10.12 2003/08/18 15:35:29 serassio Exp $ + * $Id: ipc.c,v 1.7.10.13 2003/10/08 20:32:18 serassio Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -99,6 +99,7 @@ unsigned long thread; struct ipc_params params; int opt; + int optlen = sizeof(opt); #endif pid_t pid; struct sockaddr_in CS; @@ -132,8 +133,11 @@ if (ppid) *ppid = -1; - opt = 0; - setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, sizeof(opt)); + if (WIN32_OS_version !=_WIN_OS_WINNT) { + getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, &optlen); + opt = opt & ~(SO_SYNCHRONOUS_NONALERT | SO_SYNCHRONOUS_ALERT); + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, sizeof(opt)); + } #endif if (type == IPC_TCP_SOCKET) { crfd = cwfd = comm_open(SOCK_STREAM, @@ -192,8 +196,11 @@ debug(54, 3) ("ipcCreate: cwfd FD %d\n", cwfd); #ifdef _SQUID_MSWIN_ - opt = SO_SYNCHRONOUS_NONALERT; - setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, sizeof(opt)); + if (WIN32_OS_version !=_WIN_OS_WINNT) { + getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, &optlen); + opt = opt | SO_SYNCHRONOUS_NONALERT; + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, optlen); + } #endif if (crfd < 0) { Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.5.14.17 retrieving revision 1.5.14.18 diff -u -r1.5.14.17 -r1.5.14.18 --- squid/src/win32.c 17 Aug 2003 12:31:21 -0000 1.5.14.17 +++ squid/src/win32.c 8 Oct 2003 20:32:18 -0000 1.5.14.18 @@ -797,6 +797,8 @@ int iVersionRequested; WSADATA wsaData; int err, opt; + int optlen = sizeof(opt); + if (s_iInitCount > 0) { s_iInitCount++; @@ -817,14 +819,20 @@ WSACleanup(); return (s_iInitCount); } - - opt = SO_SYNCHRONOUS_NONALERT; - if (setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, sizeof(opt))) { - s_iInitCount = -3; - WSACleanup(); - return (s_iInitCount); + if (WIN32_OS_version !=_WIN_OS_WINNT) { + if (getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&opt, &optlen)) { + s_iInitCount = -3; + WSACleanup(); + return (s_iInitCount); + } else { + opt = opt | SO_SYNCHRONOUS_NONALERT; + if (setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, optlen)) { + s_iInitCount = -3; + WSACleanup(); + return (s_iInitCount); + } + } } - WIN32_Socks_initialized = 1; s_iInitCount++; return (s_iInitCount);