--------------------- PatchSet 1129 Date: 2001/01/06 18:49:42 Author: hno Branch: nt-2_4 Tag: (none) Log: Ported changes from nt-2_3 Members: src/comm.c:1.4.22.1->1.4.22.2 src/ipc.c:1.3->1.3.16.1 src/main.c:1.5.2.2->1.5.2.2.2.1 src/neighbors.c:1.5.2.1->1.5.2.1.2.1 src/pconn.c:1.4->1.4.14.1 src/protos.h:1.4.4.2->1.4.4.2.2.1 src/pump.c:1.4->1.4.22.1 src/squid.h:1.3.4.1->1.3.4.1.2.1 Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.4.22.1 retrieving revision 1.4.22.2 diff -u -r1.4.22.1 -r1.4.22.2 --- squid/src/comm.c 6 Jan 2001 18:11:25 -0000 1.4.22.1 +++ squid/src/comm.c 6 Jan 2001 18:53:23 -0000 1.4.22.2 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.4.22.1 2001/01/06 18:11:25 hno Exp $ + * $Id: comm.c,v 1.4.22.2 2001/01/06 18:53:23 hno Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -32,7 +32,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ -#define COMM_C #include "squid.h" #ifdef HAVE_NETINET_TCP_H @@ -1211,4 +1210,3 @@ } } } -#undef COMM_C Index: squid/src/ipc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipc.c,v retrieving revision 1.3 retrieving revision 1.3.16.1 diff -u -r1.3 -r1.3.16.1 --- squid/src/ipc.c 23 Oct 2000 15:04:21 -0000 1.3 +++ squid/src/ipc.c 6 Jan 2001 18:49:42 -0000 1.3.16.1 @@ -1,6 +1,6 @@ /* - * $Id: ipc.c,v 1.3 2000/10/23 15:04:21 hno Exp $ + * $Id: ipc.c,v 1.3.16.1 2001/01/06 18:49:42 hno Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ #include "squid.h" +#ifndef _SQUID_MSWIN_ static const char *hello_string = "hi there\n"; #define HELLO_BUF_SZ 32 static char hello_buf[HELLO_BUF_SZ]; @@ -84,26 +85,42 @@ *wfd = -1; if (type == IPC_TCP_SOCKET) { crfd = cwfd = comm_open(SOCK_STREAM, +#ifdef _SQUID_MSWIN_ + IPPROTO_TCP, +#else 0, +#endif local_addr, 0, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_STREAM, +#ifdef _SQUID_MSWIN_ + IPPROTO_TCP, /* protocol */ +#else 0, /* protocol */ +#endif local_addr, 0, /* port */ 0, /* blocking */ name); } else if (type == IPC_UDP_SOCKET) { crfd = cwfd = comm_open(SOCK_DGRAM, +#ifdef _SQUID_MSWIN_ + IPPROTO_UDP, +#else 0, +#endif local_addr, 0, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_DGRAM, +#ifdef _SQUID_MSWIN_ + IPPROTO_UDP, +#else 0, +#endif local_addr, 0, 0, @@ -280,3 +297,4 @@ _exit(1); return 0; } +#endif Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.2.2.1 diff -u -r1.5.2.2 -r1.5.2.2.2.1 --- squid/src/main.c 6 Jan 2001 13:32:44 -0000 1.5.2.2 +++ squid/src/main.c 6 Jan 2001 18:49:42 -0000 1.5.2.2.2.1 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.5.2.2 2001/01/06 13:32:44 hno Exp $ + * $Id: main.c,v 1.5.2.2.2.1 2001/01/06 18:49:42 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -63,7 +63,9 @@ static void mainParseOptions(int, char **); static void sendSignal(void); static void serverConnectionsOpen(void); +#ifndef _SQUID_MSWIN_ static void watch_child(char **); +#endif static void setEffectiveUser(void); #if MEM_GEN_TRACE extern void log_trace_done(); @@ -75,6 +77,22 @@ static const char *squid_start_script = "squid_start"; +#ifdef _SQUID_MSWIN_ +#include +#include +extern void Win32SockCleanup(void); +static BOOL opt_install_service = FALSE; +static BOOL opt_remove_service = FALSE; +static BOOL eventrunning = FALSE; +void InstallService(void); +void RemoveService(void); +static SERVICE_STATUS svcStatus; +static SERVICE_STATUS_HANDLE svcHandle; +#ifndef _DEBUG +#define SERVICE +#endif +#endif + #if TEST_ACCESS #include "test_access.c" #endif @@ -89,17 +107,27 @@ " -f file Use given config-file instead of\n" " %s\n" " -h Print help message.\n" +#ifdef SERVICE + " -i Installs the " SQUID_SERVICE_NAME " service.\n" +#endif " -k reconfigure|rotate|shutdown|interrupt|kill|debug|check|parse\n" " Parse configuration file, then send signal to \n" " running copy (except -k parse) and exit.\n" +#ifdef SERVICE + " -r Removes the " SQUID_SERVICE_NAME " service.\n" +#endif +#ifndef _SQUID_MSWIN_ " -s Enable logging to syslog.\n" +#endif " -u port Specify ICP port number (default: %d), disable with 0.\n" " -v Print version.\n" " -z Create swap directories\n" " -C Do not catch fatal signals.\n" " -D Disable initial DNS tests.\n" " -F Don't serve any requests until store is rebuilt.\n" +#ifndef _SQUID_MSWIN_ " -N No daemon mode.\n" +#endif " -R Do not set REUSEADDR on port.\n" " -S Double-check swap during rebuild.\n" " -V Virtual host httpd-accelerator.\n" @@ -112,10 +140,23 @@ static void mainParseOptions(int argc, char *argv[]) { + +#ifdef _SQUID_MSWIN_ + char *optarg; + char c; + int i = 1; + + while (i < argc) { + optarg = argv[i], c = optarg[1], optarg = argv[++i]; + if (i < argc && strchr(optarg, '-') == NULL) + i++; +#else extern char *optarg; int c; while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) { +#endif + switch (c) { case 'C': opt_catch_signals = 0; @@ -126,9 +167,11 @@ case 'F': opt_foreground_rebuild = 1; break; +#ifndef _SQUID_MSWIN_ case 'N': opt_no_daemon = 1; break; +#endif case 'R': opt_reuseaddr = 0; break; @@ -158,6 +201,12 @@ case 'h': usage(); break; +#ifdef SERVICE + case 'i': + opt_install_service = TRUE; + opt_remove_service = FALSE; + break; +#endif case 'k': if ((int) strlen(optarg) < 1) usage(); @@ -205,9 +254,17 @@ fatal("Need to configure --enable-xmalloc-debug-trace to use -m option"); #endif } +#ifdef SERVICE + case 'r': + opt_install_service = FALSE; + opt_remove_service = TRUE; + break; +#endif +#ifndef _SQUID_MSWIN_ case 's': opt_syslog_enable = 1; break; +#endif case 'u': icpPortNumOverride = atoi(optarg); if (icpPortNumOverride < 0) @@ -233,9 +290,11 @@ rotate_logs(int sig) { do_rotate = 1; +#ifndef _SQUID_MSWIN_ #if !HAVE_SIGACTION signal(sig, rotate_logs); #endif +#endif } #if ALARM_UPDATES_TIME @@ -256,9 +315,11 @@ reconfigure(int sig) { do_reconfigure = 1; +#ifndef _SQUID_MSWIN_ #if !HAVE_SIGACTION signal(sig, reconfigure); #endif +#endif } void @@ -271,10 +332,12 @@ kill(getppid(), sig); } #endif +#ifndef _SQUID_MSWIN_ #if SA_RESETHAND == 0 signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); #endif +#endif } static void @@ -405,6 +468,7 @@ static void setEffectiveUser(void) { +#ifndef _SQUID_MSWIN_ leave_suid(); /* Run as non privilegied user */ #ifdef _SQUID_OS2_ return; @@ -416,6 +480,7 @@ debug(0, 0) ("'cache_effective_user' option in the config file.\n"); fatal("Don't run Squid as root, set 'cache_effective_user'!"); } +#endif } static void @@ -450,9 +515,13 @@ mainInitialize(void) { /* chroot if configured to run inside chroot */ +#ifndef _SQUID_MSWIN_ if (Config.chroot_dir && chroot(Config.chroot_dir)) { fatal("failed to chroot"); } + Squid_MaxFD = SQUID_MAXFD; +#endif + debug_log = stderr; if (opt_catch_signals) { squid_signal(SIGSEGV, death, SA_NODEFER | SA_RESETHAND); squid_signal(SIGBUS, death, SA_NODEFER | SA_RESETHAND); @@ -466,9 +535,10 @@ Config.Sockaddr.http->s.sin_port = htons(httpPortNumOverride); if (icpPortNumOverride != 1) Config.Port.icp = (u_short) icpPortNumOverride; - +#ifndef _DEBUG _db_init(Config.Log.log, Config.debugOptions); fd_open(fileno(debug_log), FD_LOG, Config.Log.log); +#endif #if MEM_GEN_TRACE log_trace_init("/tmp/squid.alloc"); #endif @@ -565,18 +635,109 @@ configured_once = 1; } +#ifdef SERVICE +VOID WINAPI +svcHandler(DWORD Opcode) +{ + DWORD status; + + switch (Opcode) { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + // Do whatever it takes to stop here. + svcStatus.dwWin32ExitCode = 0; + svcStatus.dwCurrentState = SERVICE_STOP_PENDING; + svcStatus.dwCheckPoint = 0; + svcStatus.dwWaitHint = 10000; + shut_down(SIGTERM); + if (!SetServiceStatus(svcHandle, &svcStatus)) { + status = GetLastError(); + debug(1, 1) (" SetServiceStatus error %ld\n", status); + } + debug(1, 1) ("Leaving Squid service \n"); + return; + case SERVICE_CONTROL_INTERROGATE: + // Fall through to send current status. + if (!SetServiceStatus(svcHandle, &svcStatus)) { + status = GetLastError(); + debug(1, 1) (" SetServiceStatus error %ld\n", status); + } + break; + case SQUID_SERVICE_CONTROL_ROTATE: + rotate_logs(SIGUSR1); + break; + case SQUID_SERVICE_CONTROL_RECONFIGURE: + reconfigure(SIGHUP); + break; + case SQUID_SERVICE_CONTROL_DEBUG: + sigusr2_handle(SIGUSR2); + break; + case SQUID_SERVICE_CONTROL_INTERRUPT: + // Do whatever it takes to stop here. + svcStatus.dwWin32ExitCode = 0; + svcStatus.dwCurrentState = SERVICE_STOP_PENDING; + svcStatus.dwCheckPoint = 0; + svcStatus.dwWaitHint = 10000; + shut_down(SIGINT); + if (!SetServiceStatus(svcHandle, &svcStatus)) { + status = GetLastError(); + debug(1, 1) (" SetServiceStatus error %ld\n", status); + } + debug(1, 1) ("Leaving Squid service \n"); + break; + + default: + debug(1, 1) ("Unrecognized opcode %ld\n", Opcode); + } + return; +} + +void WINAPI +SquidMain(DWORD argc, char **argv) +#else int main(int argc, char **argv) +#endif { int errcount = 0; int n; /* # of GC'd objects */ time_t loop_delay; mode_t oldmask; - +#ifdef _DEBUG debug_log = stderr; +#endif +#ifdef SERVICE + TCHAR path[512]; + if (argc == 1) { + svcHandle = RegisterServiceCtrlHandler(SQUID_SERVICE_NAME, svcHandler); + if (svcHandle == 0) + return; + } + GetModuleFileName(NULL, path, 512); + _strset(path + strlen(path) - 9, 0); + if (SetCurrentDirectory(path) == 0) + return; + strcat(path, "\\"); + strcat(path, DefaultConfigFile); + xfree(ConfigFile); + ConfigFile = xstrdup(path); + if (argc == 1) { + svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + svcStatus.dwCurrentState = SERVICE_START_PENDING; + svcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + svcStatus.dwWin32ExitCode = 0; + svcStatus.dwServiceSpecificExitCode = 0; + svcStatus.dwCheckPoint = 0; + svcStatus.dwWaitHint = 10000; + SetServiceStatus(svcHandle, &svcStatus); + } +#endif +#ifndef _SQUID_MSWIN_ if (FD_SETSIZE < Squid_MaxFD) Squid_MaxFD = FD_SETSIZE; - +#else + Squid_MaxFD = 20 * SQUID_MAXFD; +#endif /* call mallopt() before anything else */ #if HAVE_MALLOPT #ifdef M_GRAIN @@ -599,9 +760,11 @@ * set. Unfortunately, there is no way to get the current * umask value without setting it. */ +#ifndef _SQUID_MSWIN_ oldmask = umask(S_IRWXO); if (oldmask) umask(oldmask); +#endif memset(&local_addr, '\0', sizeof(struct in_addr)); safe_inet_addr(localhost, &local_addr); @@ -615,8 +778,25 @@ squid_start = current_time; failure_notify = fatal_dump; +#ifdef SERVICE + if (argc == 1) { + svcStatus.dwCheckPoint++; + SetServiceStatus(svcHandle, &svcStatus); + } +#endif + mainParseOptions(argc, argv); +#ifdef SERVICE + if (opt_install_service) { + InstallService(); + return; + } + if (opt_remove_service) { + RemoveService(); + return; + } +#endif /* parse configuration file * note: in "normal" case this used to be called from mainInitialize() */ { @@ -631,14 +811,23 @@ #endif eventInit(); /* eventInit() is required for config parsing */ storeFsInit(); /* required for config parsing */ +#ifdef _SQUID_MSWIN_ + Win32SockInit(); +#endif parse_err = parseConfigFile(ConfigFile); if (opt_parse_cfg_only) +#ifdef SERVICE + return; +#else return parse_err; +#endif } +#ifndef _SQUID_MSWIN_ if (-1 == opt_send_signal) if (checkRunningPid()) exit(1); +#endif #if TEST_ACCESS comm_init(); @@ -651,22 +840,31 @@ /* send signal to running copy and exit */ if (opt_send_signal != -1) { /* chroot if configured to run inside chroot */ +#ifndef _SQUID_MSWIN_ if (Config.chroot_dir && chroot(Config.chroot_dir)) { fatal("failed to chroot"); } +#endif sendSignal(); /* NOTREACHED */ } if (opt_create_swap_dirs) { +#ifndef _SQUID_MSWIN_ /* chroot if configured to run inside chroot */ if (Config.chroot_dir && chroot(Config.chroot_dir)) { fatal("failed to chroot"); } setEffectiveUser(); +#endif debug(0, 0) ("Creating Swap Directories\n"); storeCreateSwapDirectories(); +#ifndef SERVICE return 0; +#else + return; +#endif } +#ifndef _SQUID_MSWIN_ if (!opt_no_daemon) watch_child(argv); setMaxFD(); @@ -674,19 +872,46 @@ if (opt_catch_signals) for (n = Squid_MaxFD; n > 2; n--) close(n); +#endif /* init comm module */ comm_init(); comm_select_init(); +#ifndef SERVICE + if (opt_no_daemon) { /* we have to init fdstat here. */ fd_open(0, FD_LOG, "stdin"); fd_open(1, FD_LOG, "stdout"); fd_open(2, FD_LOG, "stderr"); } +#else + svcStatus.dwCheckPoint++; + SetServiceStatus(svcHandle, &svcStatus); +#endif +#ifdef _SQUID_MSWIN_ +#ifdef _DEBUG + for (n = 0; n < MAX_DEBUG_SECTIONS; n++) + debugLevels[n] = 1; +#endif +#endif + mainInitialize(); +#ifdef SERVICE + svcStatus.dwCheckPoint++; + svcStatus.dwCurrentState = SERVICE_RUNNING; + SetServiceStatus(svcHandle, &svcStatus); +// ReportEvent(RegisterEventSource(NULL,NULL),EVENTLOG_INFORMATION_TYPE,0,1,NULL,1,0,"SquidNT 2.2 started successfully",NULL); +#endif +#ifdef _SQUID_MSWIN_ +#ifdef _DEBUG + for (n = 0; n < MAX_DEBUG_SECTIONS; n++) + debugLevels[n] = 1; +#endif +#endif + /* main loop */ for (;;) { if (do_reconfigure) { @@ -704,6 +929,10 @@ do_shutdown = 0; shutting_down = 1; serverConnectionsClose(); +#ifdef SERVICE + svcStatus.dwCheckPoint++; + SetServiceStatus(svcHandle, &svcStatus); +#endif #if USE_DNSSERVERS dnsShutdown(); #else @@ -713,7 +942,18 @@ authenticateShutdown(); eventAdd("SquidShutdown", SquidShutdown, NULL, (double) (wait + 1), 1); } +#ifdef _DEBUG + for (n = 0; n < MAX_DEBUG_SECTIONS; n++) + debugLevels[n] = 1; +#endif eventRun(); + +#ifdef _DEBUG + for (n = 0; n < MAX_DEBUG_SECTIONS; n++) + debugLevels[n] = 3; + debugLevels[5] = 5; +#endif + if ((loop_delay = eventNextTime()) < 0) loop_delay = 0; #if HAVE_POLL @@ -741,16 +981,29 @@ } } /* NOTREACHED */ +#ifndef SERVICE return 0; +#else + return; +#endif } static void sendSignal(void) { + pid_t pid; +#ifdef _SQUID_MSWIN_ + SERVICE_STATUS ssStatus; + DWORD fdwAccess, fdwControl; + SC_HANDLE schService; + SC_HANDLE schSCManager; +#endif + debug_log = stderr; pid = readPidFile(); if (pid > 1) { +#ifndef _SQUID_MSWIN_ if (kill(pid, opt_send_signal) && /* ignore permissions if just running check */ !(opt_send_signal == 0 && errno == EPERM)) { @@ -759,6 +1012,80 @@ opt_send_signal, (int) pid, xstrerror()); exit(1); } +#else + schSCManager = OpenSCManager( + NULL, // machine (NULL == local) + NULL, // database (NULL == default) + SC_MANAGER_ALL_ACCESS // access required + ); + if (!schSCManager) { + debug(1, 1) ("OpenSCManager failed"); + exit(1); + } + // The required service object access depends on the control. + switch (opt_send_signal) { + case 0: // SIGNULL + + fdwAccess = SERVICE_INTERROGATE; + fdwControl = SERVICE_CONTROL_INTERROGATE; + break; + case SIGUSR1: + fdwAccess = SERVICE_USER_DEFINED_CONTROL; + fdwControl = SQUID_SERVICE_CONTROL_ROTATE; + break; + case SIGUSR2: + fdwAccess = SERVICE_USER_DEFINED_CONTROL; + fdwControl = SQUID_SERVICE_CONTROL_DEBUG; + break; + case SIGHUP: + fdwAccess = SERVICE_USER_DEFINED_CONTROL; + fdwControl = SQUID_SERVICE_CONTROL_RECONFIGURE; + break; + case SIGTERM: + fdwAccess = SERVICE_STOP; + fdwControl = SERVICE_CONTROL_STOP; + break; + case SIGINT: + case SIGKILL: + fdwAccess = SERVICE_USER_DEFINED_CONTROL; + fdwControl = SQUID_SERVICE_CONTROL_INTERRUPT; + break; + default: + exit(1); + } + // Open a handle to the service. + schService = OpenService( + schSCManager, // SCManager database + SQUID_SERVICE_NAME, // name of service + fdwAccess); // specify access + + if (schService == NULL) { + fprintf(stderr, "%s: ERROR: Could not open Service %s\n", appname, SQUID_SERVICE_NAME); + exit(1); + } else { + // Send a control value to the service. + if (!ControlService( + schService, // handle of service + fdwControl, // control value to send + &ssStatus)) // address of status info + { + fprintf(stderr, "%s: ERROR: Could not Control Service %s\n", appname, SQUID_SERVICE_NAME); + exit(1); + } else { + // Print the service status. + printf("\nStatus of %s Service:\n", SQUID_SERVICE_NAME); + printf(" Service Type: 0x%x\n", ssStatus.dwServiceType); + printf(" Current State: 0x%x\n", ssStatus.dwCurrentState); + printf(" Controls Accepted: 0x%x\n", ssStatus.dwControlsAccepted); + printf(" Exit Code: %d\n", ssStatus.dwWin32ExitCode); + printf(" Service Specific Exit Code: %d\n", ssStatus.dwServiceSpecificExitCode); + printf(" Check Point: %d\n", ssStatus.dwCheckPoint); + printf(" Wait Hint: %d\n", ssStatus.dwWaitHint); + } + CloseServiceHandle(schService); + } + CloseServiceHandle(schSCManager); +#endif } else { fprintf(stderr, "%s: ERROR: No running copy\n", appname); exit(1); @@ -804,6 +1131,7 @@ } } +#ifndef _SQUID_MSWIN_ static int checkRunningPid(void) { @@ -914,10 +1242,18 @@ } /* NOTREACHED */ } +#endif static void SquidShutdown(void *unused) { +#ifdef SERVICE + const char a[2][20] = + {"squid", "stopped"}; + + svcStatus.dwCheckPoint++; + SetServiceStatus(svcHandle, &svcStatus); +#endif debug(1, 1) ("Shutting down...\n"); if (Config.pidFilename && strcmp(Config.pidFilename, "none")) { enter_suid(); @@ -987,5 +1323,30 @@ version_string); if (debug_log) fclose(debug_log); +#ifdef _SQUID_MSWIN_ + Win32SockCleanup(); +#endif +#ifdef SERVICE + svcStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(svcHandle, &svcStatus); + ReportEvent(RegisterEventSource(NULL, NULL), EVENTLOG_INFORMATION_TYPE, 0, 1, NULL, 1, 0, (const char **) a, NULL); +#endif exit(0); } + +#ifdef SERVICE +#include +VOID +main(int argc, char **argv) +{ + SERVICE_TABLE_ENTRY DispatchTable[] = + { + {SQUID_SERVICE_NAME, SquidMain}, + {NULL, NULL} + }; + if (argc > 1) + SquidMain(argc, argv); + else if (!StartServiceCtrlDispatcher(DispatchTable)) + _cprintf(" StartServiceCtrlDispatcher error = %d\n", GetLastError()); +} +#endif Index: squid/src/neighbors.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/neighbors.c,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.1.2.1 diff -u -r1.5.2.1 -r1.5.2.1.2.1 --- squid/src/neighbors.c 12 Dec 2000 23:25:14 -0000 1.5.2.1 +++ squid/src/neighbors.c 6 Jan 2001 18:49:42 -0000 1.5.2.1.2.1 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.c,v 1.5.2.1 2000/12/12 23:25:14 adri Exp $ + * $Id: neighbors.c,v 1.5.2.1.2.1 2001/01/06 18:49:42 hno Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -1061,8 +1061,13 @@ return; /* probe already running */ if (squid_curtime - p->stats.last_connect_probe < Config.Timeout.connect) return; /* don't probe to often */ +#ifdef _SQUID_MSWIN_ + fd = comm_open(SOCK_STREAM, IPPROTO_TCP, Config.Addrs.tcp_outgoing, + 0, COMM_NONBLOCKING, p->host); +#else fd = comm_open(SOCK_STREAM, 0, Config.Addrs.tcp_outgoing, 0, COMM_NONBLOCKING, p->host); +#endif if (fd < 0) return; p->test_fd = fd; Index: squid/src/pconn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/pconn.c,v retrieving revision 1.4 retrieving revision 1.4.14.1 diff -u -r1.4 -r1.4.14.1 --- squid/src/pconn.c 3 Nov 2000 08:39:20 -0000 1.4 +++ squid/src/pconn.c 6 Jan 2001 18:49:42 -0000 1.4.14.1 @@ -1,6 +1,6 @@ /* - * $Id: pconn.c,v 1.4 2000/11/03 08:39:20 hno Exp $ + * $Id: pconn.c,v 1.4.14.1 2001/01/06 18:49:42 hno Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -125,7 +125,11 @@ int n; assert(table != NULL); statCounter.syscalls.sock.reads++; +#ifdef _SQUID_MSWIN_ + n = recv(fd, buf, 256); +#else n = read(fd, buf, 256); +#endif debug(48, 3) ("pconnRead: %d bytes from FD %d, %s\n", n, fd, hashKeyStr(&p->hash)); pconnRemoveFD(p, fd); Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.2.2.1 diff -u -r1.4.4.2 -r1.4.4.2.2.1 --- squid/src/protos.h 6 Jan 2001 13:32:44 -0000 1.4.4.2 +++ squid/src/protos.h 6 Jan 2001 18:49:42 -0000 1.4.4.2.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.4.4.2 2001/01/06 13:32:44 hno Exp $ + * $Id: protos.h,v 1.4.4.2.2.1 2001/01/06 18:49:42 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -147,6 +147,9 @@ extern void commCallCloseHandlers(int fd); extern int commSetTimeout(int fd, int, PF *, void *); extern void commSetDefer(int fd, DEFER * func, void *); +#ifdef _SQUID_MSWIN_ +extern int WSAignoreErrno(int); +#endif extern int ignoreErrno(int); extern void commCloseAllSockets(void); @@ -160,6 +163,10 @@ #else extern int comm_select(int); #endif +#ifdef _SQUID_MSWIN_ +extern void commUpdateReadBitsS(int, PF *); +extern void commUpdateWriteBitsS(int, PF *); +#endif extern void commUpdateReadBits(int, PF *); extern void commUpdateWriteBits(int, PF *); extern void comm_quick_poll_required(); Index: squid/src/pump.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/pump.c,v retrieving revision 1.4 retrieving revision 1.4.22.1 diff -u -r1.4 -r1.4.22.1 --- squid/src/pump.c 3 Nov 2000 08:39:20 -0000 1.4 +++ squid/src/pump.c 6 Jan 2001 18:49:43 -0000 1.4.22.1 @@ -1,6 +1,6 @@ /* - * $Id: pump.c,v 1.4 2000/11/03 08:39:20 hno Exp $ + * $Id: pump.c,v 1.4.22.1 2001/01/06 18:49:43 hno Exp $ * * DEBUG: section 61 PUMP handler * AUTHOR: Kostas Anagnostakis @@ -228,7 +228,11 @@ int len = 0; errno = 0; statCounter.syscalls.sock.reads++; +#ifdef _SQUID_MSWIN_ + len = recv(fd, buf, bytes_to_read); +#else len = read(fd, buf, bytes_to_read); +#endif fd_bytes(fd, len, FD_READ); debug(61, 5) ("pumpReadFromClient: FD %d: len %d.\n", fd, len); if (len > 0) { Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.1.2.1 diff -u -r1.3.4.1 -r1.3.4.1.2.1 --- squid/src/squid.h 6 Jan 2001 13:32:44 -0000 1.3.4.1 +++ squid/src/squid.h 6 Jan 2001 18:53:23 -0000 1.3.4.1.2.1 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.3.4.1 2001/01/06 13:32:44 hno Exp $ + * $Id: squid.h,v 1.3.4.1.2.1 2001/01/06 18:53:23 hno Exp $ * * AUTHOR: Duane Wessels * @@ -199,7 +199,9 @@ #include #define NAMLEN(dirent) strlen((dirent)->d_name) #else /* HAVE_DIRENT_H */ +#ifndef _SQUID_MSWIN_ #define dirent direct +#endif #define NAMLEN(dirent) (dirent)->d_namlen #if HAVE_SYS_NDIR_H #include @@ -330,8 +332,10 @@ #else #define leakAdd(p) p #define leakTouch(p) p +#ifndef _SQUID_MSWIN_ #define leakFree(p) p #endif +#endif #if defined(_SQUID_NEXT_) && !defined(S_ISDIR) #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) @@ -431,4 +435,13 @@ #define INDEXSD(i) (&Config.cacheSwap.swapDirs[(i)]) +#ifdef _SQUID_MSWIN_ +#define SQUID_SERVICE_CONTROL_ROTATE 128 +#define SQUID_SERVICE_CONTROL_RECONFIGURE 129 +#define SQUID_SERVICE_CONTROL_DEBUG 130 +#define SQUID_SERVICE_CONTROL_INTERRUPT 131 +#define SQUID_SERVICE_NAME "SquidNT2.3Stable4 beta" +#include "psapi.h" +#endif + #endif /* SQUID_H */