From b05490a82e46e3abdd79058e06a089bd86bf32e9 Mon Sep 17 00:00:00 2001 From: hno <> Date: Sat, 21 Oct 2000 05:50:58 +0000 Subject: [PATCH] CYGWIN port by Robert Collins --- configure.in | 19 +++++++++++-------- lib/rfc1123.c | 5 +++-- lib/util.c | 5 +++-- src/Makefile.in | 4 ++-- src/carp.cc | 4 ++-- src/client_side.cc | 12 +++++++++++- src/comm.cc | 15 ++++++++++++++- src/disk.cc | 6 +++--- src/main.cc | 6 +++++- src/pinger.cc | 6 ++++-- 10 files changed, 58 insertions(+), 24 deletions(-) diff --git a/configure.in b/configure.in index 139ad9349c..04b1a0f78f 100644 --- a/configure.in +++ b/configure.in @@ -3,13 +3,13 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.204 2000/10/04 00:20:58 wessels Exp $ +dnl $Id: configure.in,v 1.205 2000/10/20 23:50:58 hno Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.204 $)dnl +AC_REVISION($Revision: 1.205 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(cfgaux) @@ -29,7 +29,7 @@ fi dnl use .exe suffix for executables on cygwin32 platform case "$host_os" in -cygwin32|os2) +cygwin|cygwin32|os2) exec_suffix=".exe" cgi_suffix=".exe" ;; @@ -929,11 +929,13 @@ AC_CACHE_CHECK(for ip->ip_hl, ac_cv_have_ip_hl, [ #include #include #include -#ifdef __linux__ +#if defined (__linux__) || defined (__CYGWIN__) #define ip_hl ihl #endif #ifndef __linux__ +#ifndef __CYGWIN__ #define iphdr ip +#endif #endif], [struct iphdr ip; ip.ip_hl= 0;], @@ -1346,13 +1348,13 @@ main() { FILE *fp; int i,j; #if defined(__CYGWIN32__) || defined (__CYGWIN__) - /* - * getrlimit and sysconf returns bogous values on cygwin32. + /* getrlimit and sysconf returns bogous values on cygwin32. * Number of fds is virtually unlimited in cygwin (sys/param.h) - * NOTE: __CYGWIN32__ is deprecated. + * __CYGWIN32__ is deprecated. */ i = NOFILE; -#elif HAVE_SETRLIMIT +#else +#if HAVE_SETRLIMIT struct rlimit rl; #if defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { @@ -1387,6 +1389,7 @@ main() { } } i++; +#endif /* IF !DEF CYGWIN */ fp = fopen("conftestval", "w"); fprintf (fp, "%d\n", i); exit(0); diff --git a/lib/rfc1123.c b/lib/rfc1123.c index a059573a5a..f63eb6bbb1 100644 --- a/lib/rfc1123.c +++ b/lib/rfc1123.c @@ -1,6 +1,6 @@ /* - * $Id: rfc1123.c,v 1.24 2000/03/27 21:56:21 wessels Exp $ + * $Id: rfc1123.c,v 1.25 2000/10/20 23:50:59 hno Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -187,6 +187,7 @@ parse_rfc1123(const char *str) #if defined (_TIMEZONE) #elif defined (_timezone) #elif defined(_SQUID_AIX_) +#elif defined(_SQUID_CYGWIN_) #else extern time_t timezone; #endif @@ -196,7 +197,7 @@ parse_rfc1123(const char *str) */ if (tm.tm_isdst > 0) dst = -3600; -#ifdef _timezone +#if defined ( _timezone) || defined(_SQUID_CYGWIN_) t -= (_timezone + dst); #else t -= (timezone + dst); diff --git a/lib/util.c b/lib/util.c index fff2460363..67fc4999ff 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1,6 +1,6 @@ /* - * $Id: util.c,v 1.72 2000/10/17 08:06:01 adrian Exp $ + * $Id: util.c,v 1.73 2000/10/20 23:50:59 hno Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -78,9 +78,10 @@ static char msg[128]; #if !defined(__CYGWIN__) extern int sys_nerr; #else -extern __declspec(dllimport) int sys_nerr; + #define sys_nerr _sys_nerr #endif + #if MEM_GEN_TRACE static FILE *tracefp = NULL; diff --git a/src/Makefile.in b/src/Makefile.in index a184133703..e227537531 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.194 2000/09/01 12:30:24 hno Exp $ +# $Id: Makefile.in,v 1.195 2000/10/20 23:50:59 hno Exp $ # # Uncomment and customize the following to suit your needs: # @@ -391,7 +391,7 @@ install: all install-mkdirs fi install-pinger: - @f=pinger; \ + @f=$(PINGER_EXE); \ if test -f $(libexecdir)/$$f; then \ echo $(MV) $(libexecdir)/$$f $(libexecdir)/-$$f; \ $(MV) $(libexecdir)/$$f $(libexecdir)/-$$f; \ diff --git a/src/carp.cc b/src/carp.cc index 38c92a9dc1..1771229eef 100644 --- a/src/carp.cc +++ b/src/carp.cc @@ -1,6 +1,6 @@ /* - * $Id: carp.cc,v 1.12 2000/08/01 22:31:16 wessels Exp $ + * $Id: carp.cc,v 1.13 2000/10/20 23:50:59 hno Exp $ * * DEBUG: section 39 Cache Array Routing Protocol * AUTHOR: Eric Stern @@ -86,7 +86,7 @@ carpInit(void) peer * carpSelectParent(request_t * request) { -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> ((sizeof(u_long)*8)-(n)))) +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (((sizeof(unsigned long)*8)-(n))))) const char *c; peer *p = NULL; peer *tp; diff --git a/src/client_side.cc b/src/client_side.cc index 89908049e2..807a8749fa 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.507 2000/10/20 23:47:46 hno Exp $ + * $Id: client_side.cc,v 1.508 2000/10/20 23:50:59 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1825,7 +1825,17 @@ clientKeepaliveNextRequest(clientHttpRequest * http) * Set the timeout BEFORE calling clientReadRequest(). */ commSetTimeout(conn->fd, Config.Timeout.pconn, requestTimeout, conn); + /* + * 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!. + */ +#ifdef _SQUID_CYGWIN_ + 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. */ diff --git a/src/comm.cc b/src/comm.cc index 96d0b1e800..3ff2e3cc72 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.310 2000/10/17 08:06:02 adrian Exp $ + * $Id: comm.cc,v 1.311 2000/10/20 23:51:00 hno Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -720,6 +720,16 @@ commSetNonBlocking(int fd) { int flags; int dummy = 0; +#ifdef _SQUID_CYGWIN_ + int nonblocking = TRUE; + if(fd_table[fd].type != FD_PIPE) { + if(ioctl(fd, FIONBIO, &nonblocking) < 0) { + debug(50, 0) ("commSetNonBlocking: FD %d: %s %D\n", fd, xstrerror(), fd_table[fd].type); + return COMM_ERROR; + } + } + else { +#endif if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debug(50, 0) ("FD %d: fcntl F_GETFL: %s\n", fd, xstrerror()); return COMM_ERROR; @@ -728,6 +738,9 @@ commSetNonBlocking(int fd) debug(50, 0) ("commSetNonBlocking: FD %d: %s\n", fd, xstrerror()); return COMM_ERROR; } +#ifdef _SQUID_CYGWIN_ + } +#endif fd_table[fd].flags.nonblocking = 1; return 0; } diff --git a/src/disk.cc b/src/disk.cc index 030f4a5063..6724383bd7 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,6 +1,6 @@ /* - * $Id: disk.cc,v 1.151 2000/10/17 08:06:03 adrian Exp $ + * $Id: disk.cc,v 1.152 2000/10/20 23:51:00 hno Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -38,7 +38,7 @@ static PF diskHandleRead; static PF diskHandleWrite; -#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined(_SQUID_CYGWIN_) static int diskWriteIsComplete(int fd) { @@ -92,7 +92,7 @@ file_close(int fd) read_callback(-1, F->read_data); } if (F->flags.write_daemon) { -#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_) /* * on some operating systems, you can not delete or rename * open files, so we won't allow delayed close. diff --git a/src/main.cc b/src/main.cc index be28e555ed..ab0454c15c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.318 2000/10/17 08:06:03 adrian Exp $ + * $Id: main.cc,v 1.319 2000/10/20 23:51:00 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -846,6 +846,10 @@ watch_child(char *argv[]) close(i); } #endif + + +/* RBCOLLINS - if cygwin stackdumps when squid is run without -N, check the cygwin1.dll version, it needs to be AT LEAST 1.1.3. execvp had a bit overflow error in a loop.. +*/ /* Connect stdio to /dev/null in daemon mode */ nullfd = open("/dev/null", O_RDWR); dup2(nullfd, 0); diff --git a/src/pinger.cc b/src/pinger.cc index 7c551d52cc..b06b389fc2 100644 --- a/src/pinger.cc +++ b/src/pinger.cc @@ -1,6 +1,6 @@ /* - * $Id: pinger.cc,v 1.44 2000/05/16 07:06:06 wessels Exp $ + * $Id: pinger.cc,v 1.45 2000/10/20 23:51:00 hno Exp $ * * DEBUG: section 42 ICMP Pinger program * AUTHOR: Duane Wessels @@ -43,11 +43,13 @@ #include #ifndef _SQUID_LINUX_ +#ifndef _SQUID_CYGWIN_ #define icmphdr icmp #define iphdr ip #endif +#endif -#ifdef _SQUID_LINUX_ +#if defined (_SQUID_LINUX_) || defined (_SQUID_CYGWIN_) #ifdef icmp_id #undef icmp_id #endif -- 2.47.3