--------------------- PatchSet 2681 Date: 2001/07/29 09:10:27 Author: serassio Branch: nt-2_3 Tag: (none) Log: Merge of Andrey's work - Round 2 Members: include/util.h:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 include/version.h:1.1.1.3.4.4.2.3->1.1.1.3.4.4.2.4 src/cachemgr.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/comm.c:1.1.1.3.4.1.2.3->1.1.1.3.4.1.2.4 src/dns_internal.c:1.1.1.1.4.6.2.2->1.1.1.1.4.6.2.3 src/errorpage.c:1.1.1.3.4.3.2.1->1.1.1.3.4.3.2.2 src/fd.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/http.c:1.1.1.3.4.3.2.1->1.1.1.3.4.3.2.2 src/protos.h:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 src/store_dir_ufs.c:1.1.1.1.4.1.2.7->1.1.1.1.4.1.2.8 Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,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/include/util.h 3 Jul 2001 21:58:03 -0000 1.1.1.3.4.1.2.2 +++ squid/include/util.h 29 Jul 2001 09:10:27 -0000 1.1.1.3.4.1.2.3 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.1.1.3.4.1.2.2 2001/07/03 21:58:03 serassio Exp $ + * $Id: util.h,v 1.1.1.3.4.1.2.3 2001/07/29 09:10:27 serassio Exp $ * * AUTHOR: Harvest Derived * @@ -124,4 +124,15 @@ double drand48(void); #endif +/* CygWin & Windows NT Port */ +/* win32lib.c */ +#ifdef _SQUID_MSWIN_ +extern int chroot (const char *); +extern int kill(pid_t, int); +extern void gettimeofday(struct timeval * ,void *); +int statfs(const char *, struct statfs *); +int mkdir(const char *, mode_t); +const char * wsastrerror(int); +#endif + #endif /* ndef _UTIL_H_ */ Index: squid/include/version.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/version.h,v retrieving revision 1.1.1.3.4.4.2.3 retrieving revision 1.1.1.3.4.4.2.4 diff -u -r1.1.1.3.4.4.2.3 -r1.1.1.3.4.4.2.4 --- squid/include/version.h 15 Jul 2001 08:49:37 -0000 1.1.1.3.4.4.2.3 +++ squid/include/version.h 29 Jul 2001 09:10:27 -0000 1.1.1.3.4.4.2.4 @@ -1,5 +1,5 @@ /* - * $Id: version.h,v 1.1.1.3.4.4.2.3 2001/07/15 08:49:37 serassio Exp $ + * $Id: version.h,v 1.1.1.3.4.4.2.4 2001/07/29 09:10:27 serassio Exp $ * * SQUID_VERSION - String for version id of this distribution */ @@ -8,5 +8,5 @@ #endif #ifndef SQUID_RELEASE_TIME -#define SQUID_RELEASE_TIME 995065220 +#define SQUID_RELEASE_TIME 996091670 #endif 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.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/cachemgr.c 6 Jan 2001 12:40:12 -0000 1.1.1.3.4.1.2.1 +++ squid/src/cachemgr.c 29 Jul 2001 09:10:27 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: cachemgr.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:12 hno Exp $ + * $Id: cachemgr.c,v 1.1.1.3.4.1.2.2 2001/07/29 09:10:27 serassio Exp $ * * DEBUG: section 0 CGI Cache Manager * AUTHOR: Duane Wessels @@ -601,7 +601,7 @@ error_html(buf); return 1; } - S.sin_port = htons(req->port); + S.sin_port = htons((u_short) req->port); if (connect(s, (struct sockaddr *) &S, sizeof(struct sockaddr_in)) < 0) { snprintf(buf, 1024, "connect: %s\n", xstrerror()); error_html(buf); @@ -705,14 +705,12 @@ char *s; char *t; char *q; -#ifndef _DEBUG if ((buf = read_post_request()) != NULL) (void) 0; else if ((buf = read_get_request()) != NULL) (void) 0; else return NULL; -#endif #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.3 retrieving revision 1.1.1.3.4.1.2.4 diff -u -r1.1.1.3.4.1.2.3 -r1.1.1.3.4.1.2.4 --- squid/src/comm.c 8 Jul 2001 10:32:00 -0000 1.1.1.3.4.1.2.3 +++ squid/src/comm.c 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.1.1.3.4.1.2.3 2001/07/08 10:32:00 serassio Exp $ + * $Id: comm.c,v 1.1.1.3.4.1.2.4 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -350,7 +350,7 @@ commResetFD(ConnectStateData * cs) { #ifdef _SQUID_MSWIN_ - int err; + int err; #endif int fd2; if (!cbdataValid(cs->data)) @@ -364,20 +364,20 @@ Counter.syscalls.sock.sockets++; if (fd2 < 0) { #ifdef _SQUID_MSWIN_ - err=WSAGetLastError(); + err=WSAGetLastError(); #endif - debug(5, 0) ("commResetFD: socket: %s\n", xstrerror()); + debug(5, 0) ("commResetFD: socket: %s\n", xstrerror()); #ifdef _SQUID_MSWIN_ - if (WSAEMFILE == errno) + if (WSAEMFILE == h_errno) #else - if (ENFILE == errno || EMFILE == errno) + if (ENFILE == errno || EMFILE == errno) #endif fdAdjustReserved(); return 0; } if (dup2(fd2, cs->fd) < 0) { #ifdef _SQUID_MSWIN_ - err=WSAGetLastError(); + err=WSAGetLastError(); #endif debug(5, 0) ("commResetFD: dup2: %s\n", xstrerror()); #ifdef _SQUID_MSWIN_ @@ -521,8 +521,10 @@ x = connect(sock, (struct sockaddr *) address, sizeof(*address)); if (x < 0) #ifdef _SQUID_MSWIN_ - err=WSAGetLastError(); - debug(5, 9) ("connect FD %d: %d\n", sock, err); + { + err=WSAGetLastError(); + debug(5, 9) ("connect FD %d: %s\n", sock, wsastrerror(err)); + } #else debug(5, 9) ("connect FD %d: %s\n", sock, xstrerror()); #endif @@ -598,10 +600,11 @@ Counter.syscalls.sock.accepts++; #ifdef _SQUID_MSWIN_ if ((sock = WSAAccept(fd, (struct sockaddr *) &P,(int*) &Slen,NULL,0)) ==INVALID_SOCKET ) { + if (ignoreErrno(h_errno)) { #else if ((sock = accept(fd, (struct sockaddr *) &P, &Slen)) < 0) { -#endif if (ignoreErrno(errno)) { +#endif debug(50, 5) ("comm_accept: FD %d: %s\n", fd, xstrerror()); return COMM_NOMESSAGE; #ifdef _SQUID_MSWIN_ @@ -752,11 +755,18 @@ #ifdef _SQUID_LINUX_ if (ECONNREFUSED != errno) #endif +#ifdef _SQUID_MSWIN_ + errno = WSAGetLastError(); +#endif debug(50, 1) ("comm_udp_sendto: FD %d, %s, port %d: %s\n", fd, inet_ntoa(to_addr->sin_addr), (int) htons(to_addr->sin_port), +#ifdef _SQUID_MSWIN_ + wsastrerror(errno)); +#else xstrerror()); +#endif return COMM_ERROR; } return x; @@ -857,11 +867,11 @@ L.l_linger = 0; if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0) #ifdef _SQUID_MSWIN_ - debug(50, 0) ("commSetNoLinger: FD %d: %d\n", fd, WSAGetLastError()); - sd_table[fd].flags.nolinger = 1; + debug(50, 0) ("commSetNoLinger: FD %d: %s\n", fd, wsastrerror(WSAGetLastError())); + sd_table[fd].flags.nolinger = 1; #else debug(50, 0) ("commSetNoLinger: FD %d: %s\n", fd, xstrerror()); - fd_table[fd].flags.nolinger = 1; + fd_table[fd].flags.nolinger = 1; #endif } @@ -889,7 +899,7 @@ #ifdef _SQUID_MSWIN_ int nonblocking = TRUE; if (ioctlsocket(fd, FIONBIO, (unsigned long*)&nonblocking) ==SOCKET_ERROR) { - debug(50, 0) ("commSetNonBlocking: FD %d: %d\n", fd, WSAGetLastError()); + debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, wsastrerror(WSAGetLastError())); return COMM_ERROR; } sd_table[fd].flags.nonblocking = 1; @@ -915,7 +925,7 @@ #ifdef _SQUID_MSWIN_ int nonblocking=0; if (ioctlsocket(fd, FIONBIO, (unsigned long*)&nonblocking) ==SOCKET_ERROR) { - debug(50, 0) ("commSetNonBlocking: FD %d: %d\n", fd, WSAGetLastError()); + debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, wsastrerror(WSAGetLastError())); return COMM_ERROR; } sd_table[fd].flags.nonblocking = 0; @@ -1003,23 +1013,23 @@ } else if (len < 0) { /* An error */ #ifdef _SQUID_MSWIN_ - if (sd_table[fd].flags.socket_eof) { - debug(50, 2) ("commHandleWrite: FD %d: write failure: %d.\n", - fd, WSAGetLastError()); + if (sd_table[fd].flags.socket_eof) { + debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n", + fd, wsastrerror(WSAGetLastError())); #else - if (fd_table[fd].flags.socket_eof) { + if (fd_table[fd].flags.socket_eof) { debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n", fd, xstrerror()); #endif CommWriteStateCallbackAndFree(fd, COMM_ERROR); #ifdef _SQUID_MSWIN_ } else if (ignoreErrno(errno)) { - debug(50, 2) ("commHandleWrite: FD %d: write failure: %d.\n", - fd, WSAGetLastError()); - commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state, 0); + debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n", + fd, wsastrerror(WSAGetLastError())); + commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state, 0); } else { - debug(50, 2) ("commHandleWrite: FD %d: write failure: %d.\n", - fd, WSAGetLastError()); + debug(50, 2) ("commHandleWrite: FD %d: write failure: %s.\n", + fd, wsastrerror(WSAGetLastError())); CommWriteStateCallbackAndFree(fd, COMM_ERROR); } #else @@ -1043,7 +1053,7 @@ if (state->offset < state->size) { /* Not done, reinstall the write handler and write some more */ #ifdef _SQUID_MSWIN_ - commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state,0); + commSetSelectS(fd,COMM_SELECT_WRITE, commHandleWrite,state,0); #else commSetSelect(fd, COMM_SELECT_WRITE, @@ -1115,14 +1125,13 @@ int WSAignoreErrno(int err) { - err=WSAGetLastError(); + err=WSAGetLastError(); + errno = err; switch (err) { case WSAEINPROGRESS: case WSAEWOULDBLOCK: case WSAEALREADY: case WSATRY_AGAIN: -// case WSAETIMEDOUT: -// case WSAECONNRESET: return 1; default: return 0; Index: squid/src/dns_internal.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/dns_internal.c,v retrieving revision 1.1.1.1.4.6.2.2 retrieving revision 1.1.1.1.4.6.2.3 diff -u -r1.1.1.1.4.6.2.2 -r1.1.1.1.4.6.2.3 --- squid/src/dns_internal.c 14 Jun 2001 20:36:15 -0000 1.1.1.1.4.6.2.2 +++ squid/src/dns_internal.c 29 Jul 2001 09:10:28 -0000 1.1.1.1.4.6.2.3 @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.c,v 1.1.1.1.4.6.2.2 2001/06/14 20:36:15 serassio Exp $ + * $Id: dns_internal.c,v 1.1.1.1.4.6.2.3 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -388,7 +388,11 @@ q->sz); if (x < 0) { debug(50, 1) ("idnsSendQuery: FD %d: sendto: %s\n", +#ifdef _SQUID_MSWIN_ + DnsSocket, wsastrerror(errno)); +#else DnsSocket, xstrerror()); +#endif } else { fd_bytes(DnsSocket, x, FD_WRITE); commSetSelect(DnsSocket, COMM_SELECT_READ, idnsRead, NULL, 0); @@ -504,7 +508,11 @@ if (errno != ECONNREFUSED && errno != EHOSTUNREACH) #endif debug(50, 1) ("idnsRead: FD %d recvfrom: %s\n", +#ifdef _SQUID_MSWIN_ + fd, wsastrerror(WSAGetLastError())); +#else fd, xstrerror()); +#endif break; } fd_bytes(DnsSocket, len, FD_READ); Index: squid/src/errorpage.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/errorpage.c,v retrieving revision 1.1.1.3.4.3.2.1 retrieving revision 1.1.1.3.4.3.2.2 diff -u -r1.1.1.3.4.3.2.1 -r1.1.1.3.4.3.2.2 --- squid/src/errorpage.c 6 Jan 2001 12:40:13 -0000 1.1.1.3.4.3.2.1 +++ squid/src/errorpage.c 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.3.2.2 @@ -1,6 +1,6 @@ /* - * $Id: errorpage.c,v 1.1.1.3.4.3.2.1 2001/01/06 12:40:13 hno Exp $ + * $Id: errorpage.c,v 1.1.1.3.4.3.2.2 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -440,7 +440,11 @@ break; case 'E': if (err->xerrno) +#ifdef _SQUID_MSWIN_ + memBufPrintf(&mb, "%s", wsastrerror(err->xerrno)); +#else memBufPrintf(&mb, "(%d) %s", err->xerrno, strerror(err->xerrno)); +#endif else memBufPrintf(&mb, "[No Error]"); break; Index: squid/src/fd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fd.c,v retrieving revision 1.1.1.3.4.1.2.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/fd.c 6 Jan 2001 12:40:13 -0000 1.1.1.3.4.1.2.1 +++ squid/src/fd.c 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: fd.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:13 hno Exp $ + * $Id: fd.c,v 1.1.1.3.4.1.2.2 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -178,9 +178,9 @@ } debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc); F->flags.open = 0; -#ifdef _SQUID_MSWIN_ - F->fbuf = NULL; -#endif +//#ifdef _SQUID_MSWIN_ +// F->fbuf = NULL; +//#endif fdUpdateBiggest(fd, 0); Number_FD--; commUpdateReadBits(fd, NULL); Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.1.1.3.4.3.2.1 retrieving revision 1.1.1.3.4.3.2.2 diff -u -r1.1.1.3.4.3.2.1 -r1.1.1.3.4.3.2.2 --- squid/src/http.c 6 Jan 2001 12:40:14 -0000 1.1.1.3.4.3.2.1 +++ squid/src/http.c 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.3.2.2 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.1.1.3.4.3.2.1 2001/01/06 12:40:14 hno Exp $ + * $Id: http.c,v 1.1.1.3.4.3.2.2 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -481,6 +481,7 @@ Counter.syscalls.sock.reads++; #ifdef _SQUID_MSWIN_ len = recv(fd, buf, read_sz); + errno = WSAGetLastError(); #else len = read(fd, buf, read_sz); #endif @@ -510,7 +511,11 @@ } if (len < 0) { debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n", +#ifdef _SQUID_MSWIN_ fd, xstrerror()); +#else + fd, wsastrerror(errno)); +#endif if (ignoreErrno(errno)) { commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); } else if (entry->mem_obj->inmem_hi == 0) { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,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/protos.h 15 Jul 2001 16:58:38 -0000 1.1.1.3.4.1.2.5 +++ squid/src/protos.h 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.4.1.2.5 2001/07/15 16:58:38 serassio Exp $ + * $Id: protos.h,v 1.1.1.3.4.1.2.6 2001/07/29 09:10:28 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1235,13 +1235,5 @@ extern void WIN32_Exit(int); extern void WIN32_InstallService(void); extern void WIN32_RemoveService(void); -/* win32lib.c */ -#ifdef _SQUID_MSWIN_ -extern int chroot (const char *); -extern int kill(pid_t, int); -extern void gettimeofday(struct timeval * ,void *); -int statfs(const char *, struct statfs *); -int mkdir(const char *, mode_t); -#endif #endif 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.7 retrieving revision 1.1.1.1.4.1.2.8 diff -u -r1.1.1.1.4.1.2.7 -r1.1.1.1.4.1.2.8 --- squid/src/store_dir_ufs.c 28 Jul 2001 10:18:13 -0000 1.1.1.1.4.1.2.7 +++ squid/src/store_dir_ufs.c 29 Jul 2001 09:10:28 -0000 1.1.1.1.4.1.2.8 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.7 2001/07/28 10:18:13 serassio Exp $ + * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.8 2001/07/29 09:10:28 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -313,9 +313,11 @@ rb->sd->path, rb->counts.scancount); debug(20, 9) ("file_in: fd=%d %08X\n", fd, sfileno); Counter.syscalls.disk.reads++; - if (read(fd, hdr_buf, DISK_PAGE_SIZE) < 0) { #ifdef _SQUID_MSWIN_ - fd_table[fd].fbuf=NULL; + if (fread(hdr_buf, 1, DISK_PAGE_SIZE, fd_table[fd].fbuf) == 0 + && ferror(fd_table[fd].fbuf)) { +#else + if (read(fd, hdr_buf, DISK_PAGE_SIZE) < 0) { #endif debug(20, 1) ("storeRebuildFromDirectory: read(FD %d): %s\n", fd, xstrerror()); @@ -883,7 +885,11 @@ state->outbuf_offset += ss; /* buffered write */ if (state->outbuf_offset + ss > CLEAN_BUF_SZ) { +#ifdef _SQUID_MSWIN_ + if (fwrite(state->outbuf, 1, state->outbuf_offset, fd_table[state->fd].fbuf) < state->outbuf_offset) { +#else if (write(state->fd, state->outbuf, state->outbuf_offset) < 0) { +#endif debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", state->new, xstrerror()); debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n");