--------------------- PatchSet 1172 Date: 2005/01/07 09:30:28 Author: serassio Branch: nt Tag: (none) Log: Ran astyle Members: src/unlinkd.cc:1.7.2.4->1.7.2.5 src/win32.cc:1.4.2.12->1.4.2.13 Index: squid3/src/unlinkd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/unlinkd.cc,v retrieving revision 1.7.2.4 retrieving revision 1.7.2.5 diff -u -r1.7.2.4 -r1.7.2.5 --- squid3/src/unlinkd.cc 1 Jan 2005 18:59:13 -0000 1.7.2.4 +++ squid3/src/unlinkd.cc 7 Jan 2005 09:30:28 -0000 1.7.2.5 @@ -1,6 +1,6 @@ /* - * $Id: unlinkd.cc,v 1.7.2.4 2005/01/01 18:59:13 serassio Exp $ + * $Id: unlinkd.cc,v 1.7.2.5 2005/01/07 09:30:28 serassio Exp $ * * DEBUG: section 2 Unlink Daemon * AUTHOR: Duane Wessels @@ -52,6 +52,7 @@ setbuf(stdout, NULL); close(2); #ifndef _SQUID_MSWIN_ + open("/dev/null", O_RDWR); #endif @@ -208,19 +209,19 @@ } #else - if (unlinkd_wfd < 0) - return; +if (unlinkd_wfd < 0) + return; - debug(2, 1) ("Closing unlinkd pipe on FD %d\n", unlinkd_wfd); +debug(2, 1) ("Closing unlinkd pipe on FD %d\n", unlinkd_wfd); - file_close(unlinkd_wfd); +file_close(unlinkd_wfd); - if (unlinkd_wfd != unlinkd_rfd) - file_close(unlinkd_rfd); +if (unlinkd_wfd != unlinkd_rfd) + file_close(unlinkd_rfd); - unlinkd_wfd = -1; +unlinkd_wfd = -1; - unlinkd_rfd = -1; +unlinkd_rfd = -1; #endif } @@ -265,12 +266,19 @@ #endif slp.tv_sec = 0; + slp.tv_usec = 250000; + select(0, NULL, NULL, NULL, &slp); + fd_note(unlinkd_wfd, "squid -> unlinkd"); + fd_note(unlinkd_rfd, "unlinkd -> squid"); + commSetTimeout(unlinkd_rfd, -1, NULL, NULL); + commSetTimeout(unlinkd_wfd, -1, NULL, NULL); + /* * unlinkd_rfd should already be non-blocking because of * ipcCreate. We change unlinkd_wfd to blocking mode because @@ -279,8 +287,10 @@ * do this only for the IPC_FIFO case. */ assert(fd_table[unlinkd_rfd].flags.nonblocking); + if (FD_PIPE == fd_table[unlinkd_wfd].type) commUnsetNonBlocking(unlinkd_wfd); + debug(2, 1) ("Unlinkd pipe opened on FD %d\n", unlinkd_wfd); #ifdef _SQUID_MSWIN_ Index: squid3/src/win32.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/win32.cc,v retrieving revision 1.4.2.12 retrieving revision 1.4.2.13 diff -u -r1.4.2.12 -r1.4.2.13 --- squid3/src/win32.cc 1 Jan 2005 20:53:10 -0000 1.4.2.12 +++ squid3/src/win32.cc 7 Jan 2005 09:30:28 -0000 1.4.2.13 @@ -1,6 +1,6 @@ /* - * $Id: win32.cc,v 1.4.2.12 2005/01/01 20:53:10 serassio Exp $ + * $Id: win32.cc,v 1.4.2.13 2005/01/07 09:30:28 serassio Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -895,6 +895,7 @@ opt_no_daemon = 1; #endif + SquidMain(argc, argv); } @@ -913,7 +914,7 @@ { int new_socket; fde *F = NULL; - + struct sockaddr_in serv_addr; int len = sizeof(serv_addr); u_short handle1_port; @@ -921,31 +922,35 @@ handles[0] = handles[1] = -1; statCounter.syscalls.sock.sockets++; + if ((new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) return -1; memset((void *) &serv_addr, 0, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(0); + serv_addr.sin_addr = local_addr; if (bind(new_socket, (SOCKADDR *) & serv_addr, len) < 0 || - listen(new_socket, 1) < 0 || getsockname(new_socket, (SOCKADDR *) & serv_addr, &len) < 0 || - (handles[1] = socket(PF_INET, SOCK_STREAM, 0)) < 0) - { - closesocket(new_socket); - return -1; + listen(new_socket, 1) < 0 || getsockname(new_socket, (SOCKADDR *) & serv_addr, &len) < 0 || + (handles[1] = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + closesocket(new_socket); + return -1; } handle1_port = ntohs(serv_addr.sin_port); + if (connect(handles[1], (SOCKADDR *) & serv_addr, len) < 0 || - (handles[0] = accept(new_socket, (SOCKADDR *) & serv_addr, &len)) < 0) - { - closesocket(handles[1]); - handles[1] = -1; - closesocket(new_socket); - return -1; + (handles[0] = accept(new_socket, (SOCKADDR *) & serv_addr, &len)) < 0) { + closesocket(handles[1]); + handles[1] = -1; + closesocket(new_socket); + return -1; } + closesocket(new_socket); F = &fd_table[handles[0]]; @@ -1039,15 +1044,16 @@ 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); + 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); + s_iInitCount = -3; + WSACleanup(); + return (s_iInitCount); } } } @@ -1066,11 +1072,14 @@ } -int Win32__WSAFDIsSet(int fd, fd_set* set) +int Win32__WSAFDIsSet(int fd, fd_set* set + ) { fde *F = &fd_table[fd]; SOCKET s = F->win32.handle; - return ::__WSAFDIsSet(s, (fd_set FAR *)(set)); + + return ::__WSAFDIsSet(s, (fd_set FAR *)(set + )); } #endif /* End native Windows NT EXPERIMENTAL PORT */