--------------------- PatchSet 2588 Date: 2001/07/08 10:31:59 Author: serassio Branch: nt-2_3 Tag: (none) Log: New Win32 bug fixes Members: WIN32-ChangeLog.txt:1.1.2.3->1.1.2.4 lib/readdir.c:1.1->1.1.78.1 lib/rfc1123.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 lib/win32lib.c:1.1.2.1->1.1.2.2 src/client_side.c:1.1.1.3.4.6.2.2->1.1.1.3.4.6.2.3 src/comm.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 src/store_dir.c:1.1.1.3.4.2.2.6->1.1.1.3.4.2.2.7 src/store_dir_ufs.c:1.1.1.1.4.1.2.4->1.1.1.1.4.1.2.5 src/useragent.c:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 win/miscutil/miscutil.dsp:1.1.2.2->1.1.2.3 win/miscutil/miscutil.mak:1.1.2.2->1.1.2.3 Index: squid/WIN32-ChangeLog.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/WIN32-ChangeLog.txt,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid/WIN32-ChangeLog.txt 25 Mar 2001 17:49:42 -0000 1.1.2.3 +++ squid/WIN32-ChangeLog.txt 8 Jul 2001 10:31:59 -0000 1.1.2.4 @@ -27,3 +27,15 @@ 04 Mar 2001 - Merged with 03/03/2001 main Head tarball (Guido Serassio) 12 Mar 2001 - Enabled -f switch to set Windows NT Registry with an alternate config-file and fixed the config-file not found error when running as a service (Guido Serassio) +16 Jun 2001 - Fixed a bug in the native Windows NT Authenticator when authentication is made + against a NT domain (Guido Serassio) + - Fixed a bug in free disk space determination - (Guido Serassio) + - Fixed various memory leaks (Backported patches) - (Guido Serassio) +17 Jun 2001 - Backported WIN32 code from 2.5 DEVEL. Now is possible to run multiple instances of + Squid service and a full traditional command line mode is available for + debugging purpose (Guido serassio) +18 Jun 2001 - Fixed a multi cache dir bug - (Guido Serassio) +29 Jun 2001 - Fixed a bug in Useragent Log - (Guido Serassio) +02 Jul 2001 - Partially fixed FD problems and 100% CPU load problems - (Guido Serassio) +07 Jul 2001 - Fixed a "non caching" bug - (Guido Serassio) + --- /dev/null Wed Feb 14 00:52:54 2007 +++ squid/lib/readdir.c Wed Feb 14 00:53:48 2007 @@ -0,0 +1,81 @@ + +#include +#include +#include +#define strdup _strdup +#include "readdir.h" + +/********************************************************************** + * Implement dirent-style opendir/readdir/closedir on Window 95/NT + * + * Functions defined are opendir(), readdir() and closedir() with the + * same prototypes as the normal dirent.h implementation. + * + * Does not implement telldir(), seekdir(), rewinddir() or scandir(). + * The dirent struct is compatible with Unix, except that d_ino is + * always 1 and d_off is made up as we go along. + * + * The DIR typedef is not compatible with Unix. + **********************************************************************/ + +DIR * opendir(const char *dir) +{ + DIR *dp; + char *filespec; + long handle; + int index; + + filespec = malloc(strlen(dir) + 2 + 1); + strcpy(filespec, dir); + index = strlen(filespec) - 1; + if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\')) + filespec[index] = '\0'; + strcat(filespec, "/*"); + + dp = (DIR *)malloc(sizeof(DIR)); + dp->offset = 0; + dp->finished = 0; + dp->dir = strdup(dir); + + if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) { + if (errno == ENOENT) + dp->finished = 1; + else + return NULL; + } + + dp->handle = handle; + free(filespec); + + return dp; +} + +struct dirent * readdir(DIR *dp) +{ + if (!dp || dp->finished) return NULL; + + if (dp->offset != 0) { + if (_findnext(dp->handle, &(dp->fileinfo)) < 0) { + dp->finished = 1; + return NULL; + } + } + dp->offset++; + + strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME); + dp->dent.d_ino = 1; + dp->dent.d_reclen = strlen(dp->dent.d_name); + dp->dent.d_off = dp->offset; + + return &(dp->dent); +} + +int closedir(DIR *dp) +{ + if (!dp) return 0; + _findclose(dp->handle); + if (dp->dir) free(dp->dir); + if (dp) free(dp); + + return 0; +} Index: squid/lib/rfc1123.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/rfc1123.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/lib/rfc1123.c 18 Jun 2001 20:46:54 -0000 1.1.1.3.4.1.2.2 +++ squid/lib/rfc1123.c 8 Jul 2001 10:31:59 -0000 1.1.1.3.4.1.2.3 @@ -1,21 +1,21 @@ /* - * $Id: rfc1123.c,v 1.1.1.3.4.1.2.2 2001/06/18 20:46:54 serassio Exp $ + * $Id: rfc1123.c,v 1.1.1.3.4.1.2.3 2001/07/08 10:31:59 serassio Exp $ * * DEBUG: * AUTHOR: Harvest Derived * - * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ + * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * - * Squid is the result of efforts by numerous individuals from the - * Internet community. Development is led by Duane Wessels of the - * National Laboratory for Applied Network Research and funded by the - * National Science Foundation. Squid is Copyrighted (C) 1998 by - * the Regents of the University of California. Please see the - * COPYRIGHT file for full details. Squid incorporates software - * developed and/or copyrighted by other sources. Please see the - * CREDITS file for full details. + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,6 +135,7 @@ s = strchr(str, ','); if (NULL == s) return NULL; + s++; while (*s == ' ') s++; /* backup if month is only one digit */ @@ -165,12 +166,13 @@ { /* Thu, 10 Jan 1993 01:29:59 GMT */ const char *s; - struct tm tm; + static struct tm tm; assert(NULL != str); memset(&tm, '\0', sizeof(struct tm)); s = strchr(str, ','); if (NULL == s) return NULL; + s++; while (*s == ' ') s++; /* backup if month is only one digit */ @@ -257,6 +259,8 @@ #if defined (_TIMEZONE) #elif defined (_timezone) #elif defined(_SQUID_AIX_) +#elif defined(_SQUID_CYGWIN_) +#elif defined(_SQUID_MSWIN_) #else extern time_t timezone; #endif @@ -266,7 +270,7 @@ */ if (tm->tm_isdst > 0) dst = -3600; -#ifdef _timezone +#if defined ( _timezone) || defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) t -= (_timezone + dst); #else t -= (timezone + dst); Index: squid/lib/win32lib.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/win32lib.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/lib/win32lib.c 14 Jun 2001 20:36:15 -0000 1.1.2.1 +++ squid/lib/win32lib.c 8 Jul 2001 10:31:59 -0000 1.1.2.2 @@ -1,5 +1,5 @@ /* - * $Id: win32lib.c,v 1.1.2.1 2001/06/14 20:36:15 serassio Exp $ + * $Id: win32lib.c,v 1.1.2.2 2001/07/08 10:31:59 serassio Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -29,13 +29,8 @@ #include #include #include -#undef free -#undef malloc #include -#include -#include #include -#include #define OPTERRCOLON (1) #define OPTERRNF (2) @@ -271,81 +266,4 @@ #endif /* TESTGETOPT */ - - -/********************************************************************** - * Implement dirent-style opendir/readdir/closedir on Window 95/NT - * - * Functions defined are opendir(), readdir() and closedir() with the - * same prototypes as the normal dirent.h implementation. - * - * Does not implement telldir(), seekdir(), rewinddir() or scandir(). - * The dirent struct is compatible with Unix, except that d_ino is - * always 1 and d_off is made up as we go along. - * - * The DIR typedef is not compatible with Unix. - **********************************************************************/ - -DIR * opendir(const char *dir) -{ - DIR *dp; - char *filespec; - long handle; - int index; - - filespec = (char *) malloc(strlen(dir) + 2 + 1); - strcpy(filespec, dir); - index = strlen(filespec) - 1; - if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\')) - filespec[index] = '\0'; - strcat(filespec, "/*"); - - dp = (DIR *)malloc(sizeof(DIR)); - dp->offset = 0; - dp->finished = 0; - dp->dir = _strdup(dir); - - if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) { - if (errno == ENOENT) - dp->finished = 1; - else - return NULL; - } - - dp->handle = handle; - free(filespec); - - return dp; -} - -struct dirent * readdir(DIR *dp) -{ - if (!dp || dp->finished) return NULL; - - if (dp->offset != 0) { - if (_findnext(dp->handle, &(dp->fileinfo)) < 0) { - dp->finished = 1; - return NULL; - } - } - dp->offset++; - - strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME); - dp->dent.d_ino = 1; - dp->dent.d_reclen = strlen(dp->dent.d_name); - dp->dent.d_off = dp->offset; - - return &(dp->dent); -} - -int closedir(DIR *dp) -{ - if (!dp) return 0; - _findclose(dp->handle); - if (dp->dir) free(dp->dir); - if (dp) free(dp); - - return 0; -} - #endif Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.4.6.2.2 retrieving revision 1.1.1.3.4.6.2.3 diff -u -r1.1.1.3.4.6.2.2 -r1.1.1.3.4.6.2.3 --- squid/src/client_side.c 3 Jun 2001 19:41:48 -0000 1.1.1.3.4.6.2.2 +++ squid/src/client_side.c 8 Jul 2001 10:31:59 -0000 1.1.1.3.4.6.2.3 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.6.2.2 2001/06/03 19:41:48 serassio Exp $ + * $Id: client_side.c,v 1.1.1.3.4.6.2.3 2001/07/08 10:31:59 serassio Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1770,7 +1770,18 @@ * Set the timeout BEFORE calling clientReadRequest(). */ commSetTimeout(conn->fd, Config.Timeout.pconn, requestTimeout, conn); +// clientReadRequest(conn->fd, conn); /* Read next request */ + /* + * CYGWIN has a problem and is blocking on read() requests when there + * is no data present. + * This hack may hit performance a little, but it's better than + * blocking!. + */ +#if defined (_SQUID_CYGWIN_) || defined (_SQUID_MSWIN_) + commSetSelect(conn->fd, COMM_SELECT_READ, clientReadRequest, conn, 0); +#else clientReadRequest(conn->fd, conn); /* Read next request */ +#endif /* * Note, the FD may be closed at this point. */ Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.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/comm.c 3 Jun 2001 19:41:48 -0000 1.1.1.3.4.1.2.2 +++ squid/src/comm.c 8 Jul 2001 10:32:00 -0000 1.1.1.3.4.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.1.1.3.4.1.2.2 2001/06/03 19:41:48 serassio Exp $ + * $Id: comm.c,v 1.1.1.3.4.1.2.3 2001/07/08 10:32:00 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -887,7 +887,7 @@ int flags; int dummy = 0; #ifdef _SQUID_MSWIN_ - int nonblocking=1; + int nonblocking = TRUE; if (ioctlsocket(fd, FIONBIO, (unsigned long*)&nonblocking) ==SOCKET_ERROR) { debug(50, 0) ("commSetNonBlocking: FD %d: %d\n", fd, WSAGetLastError()); return COMM_ERROR; Index: squid/src/store_dir.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_dir.c,v retrieving revision 1.1.1.3.4.2.2.6 retrieving revision 1.1.1.3.4.2.2.7 diff -u -r1.1.1.3.4.2.2.6 -r1.1.1.3.4.2.2.7 --- squid/src/store_dir.c 30 Jun 2001 18:42:07 -0000 1.1.1.3.4.2.2.6 +++ squid/src/store_dir.c 8 Jul 2001 10:32:00 -0000 1.1.1.3.4.2.2.7 @@ -1,6 +1,6 @@ /* - * $Id: store_dir.c,v 1.1.1.3.4.2.2.6 2001/06/30 18:42:07 serassio Exp $ + * $Id: store_dir.c,v 1.1.1.3.4.2.2.7 2001/07/08 10:32:00 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -295,7 +295,7 @@ int dirn = (fn >> SWAP_DIR_SHIFT) % Config.cacheSwap.n_configured; SwapDir *sd = &Config.cacheSwap.swapDirs[dirn]; int blks = (size + sd->fs.blksize - 1) / sd->fs.blksize; - int k = (blks * sd->fs.blksize >> 10) * sign; + int k = ((blks * sd->fs.blksize) >> 10) * sign; Config.cacheSwap.swapDirs[dirn].cur_size += k; store_swap_size += k; if (sign > 0) Index: squid/src/store_dir_ufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/store_dir_ufs.c,v retrieving revision 1.1.1.1.4.1.2.4 retrieving revision 1.1.1.1.4.1.2.5 diff -u -r1.1.1.1.4.1.2.4 -r1.1.1.1.4.1.2.5 --- squid/src/store_dir_ufs.c 18 Jun 2001 19:30:40 -0000 1.1.1.1.4.1.2.4 +++ squid/src/store_dir_ufs.c 8 Jul 2001 10:32:00 -0000 1.1.1.1.4.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.4 2001/06/18 19:30:40 serassio Exp $ + * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.5 2001/07/08 10:32:00 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -319,7 +319,7 @@ Counter.syscalls.disk.reads++; if (read(fd, hdr_buf, DISK_PAGE_SIZE) < 0) { #ifdef _SQUID_MSWIN_ - fd_table[fd].fbuf=NULL; + fd_table[fd].fbuf=NULL; #endif debug(20, 1) ("storeRebuildFromDirectory: read(FD %d): %s\n", fd, xstrerror()); @@ -791,7 +791,11 @@ } sd->u.ufs.swaplog_fd = fd; /* open a read-only stream of the old log */ +#ifdef _SQUID_MSWIN_ + fp = fopen(swaplog_path, "rb"); +#else fp = fopen(swaplog_path, "r"); +#endif if (fp == NULL) { debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); fatal("Failed to open swap log for reading"); @@ -910,7 +914,7 @@ if (state->fd < 0) return; #ifdef _SQUID_MSWIN_ - fbuf=fd_table[state->fd].fbuf; + fbuf=fd_table[state->fd].fbuf; fwrite(state->outbuf, 1, state->outbuf_offset, fbuf); if (ferror(fbuf) || feof(fbuf)){ #else Index: squid/src/useragent.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/useragent.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/useragent.c 30 Jun 2001 18:42:07 -0000 1.1.1.3.4.1.2.5 +++ squid/src/useragent.c 8 Jul 2001 10:32:00 -0000 1.1.1.3.4.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: useragent.c,v 1.1.1.3.4.1.2.5 2001/06/30 18:42:07 serassio Exp $ + * $Id: useragent.c,v 1.1.1.3.4.1.2.6 2001/07/08 10:32:00 serassio Exp $ * * DEBUG: section 40 User-Agent logging * AUTHOR: Joe Ramey @@ -60,7 +60,7 @@ } if (log_fd < 0 || cache_useragent_log == NULL) debug(40, 1) ("User-Agent logging is disabled.\n"); -#if defined(_SQUID_CYGWIN_)||defined(_SQUID_MSWIN_) +#if defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) else setmode(fileno(cache_useragent_log), O_TEXT); #endif Index: squid/win/miscutil/miscutil.dsp =================================================================== RCS file: /cvsroot/squid-sf//squid/win/miscutil/Attic/miscutil.dsp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/win/miscutil/miscutil.dsp 30 Jun 2001 18:42:07 -0000 1.1.2.2 +++ squid/win/miscutil/miscutil.dsp 8 Jul 2001 10:32:00 -0000 1.1.2.3 @@ -127,6 +127,10 @@ # End Source File # Begin Source File +SOURCE=..\..\lib\readdir.c +# End Source File +# Begin Source File + SOURCE=..\..\lib\rfc1035.c # End Source File # Begin Source File Index: squid/win/miscutil/miscutil.mak =================================================================== RCS file: /cvsroot/squid-sf//squid/win/miscutil/Attic/miscutil.mak,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/win/miscutil/miscutil.mak 30 Jun 2001 18:42:07 -0000 1.1.2.2 +++ squid/win/miscutil/miscutil.mak 8 Jul 2001 10:32:00 -0000 1.1.2.3 @@ -61,6 +61,7 @@ -@erase "$(INTDIR)\iso3307.obj" -@erase "$(INTDIR)\md5.obj" -@erase "$(INTDIR)\radix.obj" + -@erase "$(INTDIR)\readdir.obj" -@erase "$(INTDIR)\rfc1035.obj" -@erase "$(INTDIR)\rfc1123.obj" -@erase "$(INTDIR)\rfc1738.obj" @@ -107,6 +108,7 @@ "$(INTDIR)\util.obj" \ "$(INTDIR)\uudecode.obj" \ "$(INTDIR)\win32lib.obj" \ + "$(INTDIR)\readdir.obj" \ "..\libregex\Release\libregex.lib" "$(OUTDIR)\miscutil.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) @@ -147,6 +149,7 @@ -@erase "$(INTDIR)\iso3307.obj" -@erase "$(INTDIR)\md5.obj" -@erase "$(INTDIR)\radix.obj" + -@erase "$(INTDIR)\readdir.obj" -@erase "$(INTDIR)\rfc1035.obj" -@erase "$(INTDIR)\rfc1123.obj" -@erase "$(INTDIR)\rfc1738.obj" @@ -194,6 +197,7 @@ "$(INTDIR)\util.obj" \ "$(INTDIR)\uudecode.obj" \ "$(INTDIR)\win32lib.obj" \ + "$(INTDIR)\readdir.obj" \ "..\libregex\Debug\libregex.lib" "$(OUTDIR)\miscutil.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) @@ -304,6 +308,12 @@ $(CPP) $(CPP_PROJ) $(SOURCE) +SOURCE=..\..\lib\readdir.c + +"$(INTDIR)\readdir.obj" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + SOURCE=..\..\lib\rfc1035.c "$(INTDIR)\rfc1035.obj" : $(SOURCE) "$(INTDIR)" @@ -373,25 +383,25 @@ !IF "$(CFG)" == "miscutil - Win32 Release" "libregex - Win32 Release" : - cd "\work\squidnt23\win\libregex" - $(MAKE) /$(MAKEFLAGS) /F .\libregex.mak CFG="libregex - Win32 Release" + cd "\work\nt-2.3\win\libregex" + $(MAKE) /$(MAKEFLAGS) /F ".\libregex.mak" CFG="libregex - Win32 Release" cd "..\miscutil" "libregex - Win32 ReleaseCLEAN" : - cd "\work\squidnt23\win\libregex" - $(MAKE) /$(MAKEFLAGS) /F .\libregex.mak CFG="libregex - Win32 Release" RECURSE=1 CLEAN + cd "\work\nt-2.3\win\libregex" + $(MAKE) /$(MAKEFLAGS) /F ".\libregex.mak" CFG="libregex - Win32 Release" RECURSE=1 CLEAN cd "..\miscutil" !ELSEIF "$(CFG)" == "miscutil - Win32 Debug" "libregex - Win32 Debug" : - cd "\work\squidnt23\win\libregex" - $(MAKE) /$(MAKEFLAGS) /F .\libregex.mak CFG="libregex - Win32 Debug" + cd "\work\nt-2.3\win\libregex" + $(MAKE) /$(MAKEFLAGS) /F ".\libregex.mak" CFG="libregex - Win32 Debug" cd "..\miscutil" "libregex - Win32 DebugCLEAN" : - cd "\work\squidnt23\win\libregex" - $(MAKE) /$(MAKEFLAGS) /F .\libregex.mak CFG="libregex - Win32 Debug" RECURSE=1 CLEAN + cd "\work\nt-2.3\win\libregex" + $(MAKE) /$(MAKEFLAGS) /F ".\libregex.mak" CFG="libregex - Win32 Debug" RECURSE=1 CLEAN cd "..\miscutil" !ENDIF