--------------------- PatchSet 2682 Date: 2001/07/29 16:06:05 Author: serassio Branch: nt-2_3 Tag: Z-nt-2_3-tolsty_merge_nt-2_3 Log: Merge of Andrey's work - Round 3 Members: src/cachemgr.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 src/comm.c:1.1.1.3.4.1.2.4->1.1.1.3.4.1.2.5 src/globals.h:1.1.1.3.4.2.2.3->1.1.1.3.4.2.2.4 src/main.c:1.1.1.3.4.2.2.8->1.1.1.3.4.2.2.9 src/tools.c:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 Index: squid/src/cachemgr.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/cachemgr.c,v retrieving revision 1.1.1.3.4.1.2.2 retrieving revision 1.1.1.3.4.1.2.3 diff -u -r1.1.1.3.4.1.2.2 -r1.1.1.3.4.1.2.3 --- squid/src/cachemgr.c 29 Jul 2001 09:10:27 -0000 1.1.1.3.4.1.2.2 +++ squid/src/cachemgr.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: cachemgr.c,v 1.1.1.3.4.1.2.2 2001/07/29 09:10:27 serassio Exp $ + * $Id: cachemgr.c,v 1.1.1.3.4.1.2.3 2001/07/29 16:06:05 serassio Exp $ * * DEBUG: section 0 CGI Cache Manager * AUTHOR: Duane Wessels @@ -159,7 +159,6 @@ } s_iInitCount++; return (s_iInitCount); - } @@ -445,11 +444,11 @@ read_reply(int s, cachemgr_request * req) { char buf[4 * 1024]; - #ifdef _SQUID_MSWIN_ - int reply; - FILE*fp=tmpfile(); +#ifdef _SQUID_MSWIN_ + int reply; + FILE *fp = tmpfile(); #else - FILE *fp = fdopen(s, "r"); + FILE *fp = fdopen(s, "r"); #endif /* interpretation states */ enum { @@ -467,10 +466,10 @@ perror("fdopen"); return 1; } - #ifdef _SQUID_MSWIN_ - while ((reply=recv(s,buf,sizeof(buf),0))>0) - fwrite(buf,1,reply,fp); - rewind(fp); +#ifdef _SQUID_MSWIN_ + while ((reply=recv(s,buf,sizeof(buf),0))>0) + fwrite(buf,1,reply,fp); + rewind(fp); #endif if (parse_menu) action = "menu"; @@ -565,7 +564,7 @@ int s; int l; #ifdef _SQUID_MSWIN_ - int answer; + int answer; #endif static char buf[2 * 1024]; if (req == NULL) { @@ -616,7 +615,7 @@ req->action, make_auth_header(req)); #ifdef _SQUID_MSWIN_ - send(s, buf, l,0); + send(s, buf, l,0); #else write(s, buf, l); #endif @@ -636,15 +635,15 @@ char *s; cachemgr_request *req; #ifdef _SQUID_MSWIN_ - int answer; + int answer; #endif safe_inet_addr("255.255.255.255", &no_addr); now = time(NULL); #ifdef _SQUID_MSWIN_ - Win32SockInit(); - if ((s = strrchr(argv[0], '\\'))) + Win32SockInit(); + if ((s = strrchr(argv[0], '\\'))) #else - if ((s = strrchr(argv[0], '/'))) + if ((s = strrchr(argv[0], '/'))) #endif progname = xstrdup(s + 1); else @@ -653,8 +652,8 @@ script_name = xstrdup(s); #ifdef _SQUID_MSWIN_ req = read_request(NULL); - answer=process_request(req); - Win32SockCleanup(); + answer=process_request(req); + Win32SockCleanup(); return answer; #else req = read_request(); @@ -705,12 +704,12 @@ char *s; char *t; char *q; - if ((buf = read_post_request()) != NULL) - (void) 0; - else if ((buf = read_get_request()) != NULL) - (void) 0; - else - return NULL; + if ((buf = read_post_request()) != NULL) + (void) 0; + else if ((buf = read_get_request()) != NULL) + (void) 0; + else + return NULL; #ifdef _SQUID_MSWIN_ if (strlen(buf) == 0 || strlen(buf) == 4000) #else Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.1.1.3.4.1.2.4 retrieving revision 1.1.1.3.4.1.2.5 diff -u -r1.1.1.3.4.1.2.4 -r1.1.1.3.4.1.2.5 --- squid/src/comm.c 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.1.2.4 +++ squid/src/comm.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.1.1.3.4.1.2.4 2001/07/29 09:10:28 serassio Exp $ + * $Id: comm.c,v 1.1.1.3.4.1.2.5 2001/07/29 16:06:05 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -98,14 +98,14 @@ CommWriteStateCallbackAndFree(int fd, int code) { #ifdef _SQUID_MSWIN_ - CommWriteStateData *CommWriteState = sd_table[fd].rwstate; + CommWriteStateData *CommWriteState = sd_table[fd].rwstate; #else CommWriteStateData *CommWriteState = fd_table[fd].rwstate; #endif CWCB *callback = NULL; void *data; #ifdef _SQUID_MSWIN_ - sd_table[fd].rwstate = NULL; + sd_table[fd].rwstate = NULL; #else fd_table[fd].rwstate = NULL; #endif @@ -186,7 +186,7 @@ int new_socket; #ifdef _SQUID_MSWIN_ sde *F = NULL; - int err; + int err; #else fde *F = NULL; #endif @@ -198,7 +198,7 @@ /* Increase the number of reserved fd's if calls to socket() * are failing because the open file table is full. This * limits the number of simultaneous clients */ - err=WSAGetLastError(); + err=WSAGetLastError(); switch (err) { case WSAEMFILE: #else @@ -222,7 +222,7 @@ debug(5, 5) ("comm_open: FD %d is a new socket\n", new_socket); fd_open(new_socket, FD_SOCKET, note); #ifdef _SQUID_MSWIN_ - F = &sd_table[new_socket]; + F = &sd_table[new_socket]; #else F = &fd_table[new_socket]; #endif @@ -231,6 +231,9 @@ if ((flags & COMM_REUSEADDR)) commSetReuseAddr(new_socket); if (port > (u_short) 0) { +#ifdef _SQUID_MSWIN_ + if ( sock_type != SOCK_DGRAM && proto != IPPROTO_UDP ) +#endif commSetNoLinger(new_socket); if (opt_reuseaddr) commSetReuseAddr(new_socket); @@ -356,8 +359,8 @@ if (!cbdataValid(cs->data)) return 0; #ifdef _SQUID_MSWIN_ - closesocket(cs->fd); - return 0; + closesocket(cs->fd); + return 0; #endif Counter.syscalls.sock.sockets++; fd2 = socket(AF_INET, SOCK_STREAM, 0); @@ -373,7 +376,7 @@ if (ENFILE == errno || EMFILE == errno) #endif fdAdjustReserved(); - return 0; + return 0; } if (dup2(fd2, cs->fd) < 0) { #ifdef _SQUID_MSWIN_ @@ -390,10 +393,10 @@ } #ifdef _SQUID_MSWIN_ closesocket(fd2); - sd_table[cs->fd].flags.called_connect = 0; + sd_table[cs->fd].flags.called_connect = 0; #else close(fd2); - fd_table[cs->fd].flags.called_connect = 0; + fd_table[cs->fd].flags.called_connect = 0; #endif /* * yuck, this has assumptions about comm_open() arguments for @@ -562,7 +565,7 @@ #ifdef _SQUID_MSWIN_ if (err == 0 || err == WSAEISCONN) status = COMM_OK; - else if (ignoreErrno(err)) + else if (WSASetLastError(err), ignoreErrno(err)) #else if (errno == 0 || errno == EISCONN) status = COMM_OK; Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/globals.h,v retrieving revision 1.1.1.3.4.2.2.3 retrieving revision 1.1.1.3.4.2.2.4 diff -u -r1.1.1.3.4.2.2.3 -r1.1.1.3.4.2.2.4 --- squid/src/globals.h 14 Jun 2001 20:36:16 -0000 1.1.1.3.4.2.2.3 +++ squid/src/globals.h 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.2.2.4 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.1.1.3.4.2.2.3 2001/06/14 20:36:16 serassio Exp $ + * $Id: globals.h,v 1.1.1.3.4.2.2.4 2001/07/29 16:06:05 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -162,4 +162,7 @@ extern char *WIN32_OS_string; extern char *WIN32_Service_name; /* NULL */ extern unsigned int WIN32_run_mode; /* _WIN_SQUID_RUN_MODE_INTERACTIVE */ +#if defined(_SQUID_MSWIN_) && defined(_DEBUG) +extern int do_debug; /* 0 */ +#endif #endif Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.1.1.3.4.2.2.8 retrieving revision 1.1.1.3.4.2.2.9 diff -u -r1.1.1.3.4.2.2.8 -r1.1.1.3.4.2.2.9 --- squid/src/main.c 10 Jul 2001 19:42:14 -0000 1.1.1.3.4.2.2.8 +++ squid/src/main.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.2.2.9 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.1.1.3.4.2.2.8 2001/07/10 19:42:14 serassio Exp $ + * $Id: main.c,v 1.1.1.3.4.2.2.9 2001/07/29 16:06:05 serassio Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -348,7 +348,9 @@ wccpConnectionOpen(); #endif clientdbInit(); +#ifndef _SQUID_MSWIN_ icmpOpen(); +#endif netdbInit(); asnInit(); peerSelectInit(); @@ -411,6 +413,9 @@ #if !USE_DNSSERVERS idnsInit(); #endif +#ifdef _SQUID_MSWIN_ + icmpOpen(); +#endif redirectInit(); authenticateInit(); #if USE_WCCP @@ -434,11 +439,27 @@ mainRotate(void) { icmpClose(); +#ifdef _SQUID_MSWIN_ + unlinkdClose(); + redirectShutdown(); + authenticateShutdown(); +#if USE_DNSSERVERS + dnsShutdown(); +#endif +#endif _db_rotate_log(); /* cache.log */ storeDirWriteCleanLogs(1); storeLogRotate(); /* store.log */ accessLogRotate(); /* access.log */ useragentRotateLog(); /* useragent.log */ +#ifdef _SQUID_MSWIN_ +#if USE_DNSSERVERS + dnsInit(); +#endif + authenticateInit(); + redirectInit(); + unlinkdInit(); +#endif icmpOpen(); } @@ -504,7 +525,7 @@ setEffectiveUser(); assert(Config.Sockaddr.http); if (httpPortNumOverride != 1) - Config.Sockaddr.http->s.sin_port = htons(httpPortNumOverride); + Config.Sockaddr.http->s.sin_port = htons((u_short) httpPortNumOverride); if (icpPortNumOverride != 1) Config.Port.icp = (u_short) icpPortNumOverride; @@ -550,6 +571,9 @@ malloc_debug(0, malloc_debug_level); #endif +#ifdef _SQUID_MSWIN_ + icmpOpen(); +#endif if (!configured_once) { #if USE_ASYNC_IO aioInit(); @@ -786,6 +810,11 @@ if (do_reconfigure) { mainReconfigure(); do_reconfigure = 0; +#if defined(_SQUID_MSWIN_) && defined(_DEBUG) + } else if (do_debug) { + do_debug = 0; + DebugBreak(); +#endif } else if (do_rotate) { mainRotate(); do_rotate = 0; Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.1.1.3.4.1.2.5 retrieving revision 1.1.1.3.4.1.2.6 diff -u -r1.1.1.3.4.1.2.5 -r1.1.1.3.4.1.2.6 --- squid/src/tools.c 14 Jun 2001 21:34:24 -0000 1.1.1.3.4.1.2.5 +++ squid/src/tools.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.1.1.3.4.1.2.5 2001/06/14 21:34:24 serassio Exp $ + * $Id: tools.c,v 1.1.1.3.4.1.2.6 2001/07/29 16:06:05 serassio Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -342,6 +342,10 @@ void sigusr2_handle(int sig) { +#if defined(_SQUID_MSWIN_) && defined(_DEBUG) + do_debug = 1; +#endif +#if (defined(_SQUID_MSWIN_) && !defined(_DEBUG)) || !defined(_SQUID_MSWIN_) static int state = 0; /* no debug() here; bad things happen if the signal is delivered during _db_print() */ if (state == 0) { @@ -359,6 +363,7 @@ #endif state = 0; } +#endif #if !HAVE_SIGACTION signal(sig, sigusr2_handle); /* reinstall */ #endif