From a396d1f8227f977b5ff215ae51658b118bf230f0 Mon Sep 17 00:00:00 2001 From: Eldar Akchurin Date: Mon, 9 Feb 2015 19:44:32 -0800 Subject: [PATCH] Bug 4073: Cygwin compile errors Remove the definition of _SQUID_WINDOWS_ for Cygwin builds. The blend of win32 and Linux environments is sufficiently different to have major build issues. We have a precedent in kFreeBSD blend of BSD and Linux to consider Cygwin a blend and first-class OS. Also, temporarily disable the Win32-specific libraries and objects until they can be properly tested. Fix some small remaining compile errors after the above. Cygwin Windows build is sponsored by Diladele B.V. --- compat/osdetect.h | 3 +-- configure.ac | 7 +++---- src/comm.cc | 44 +++++++++++++++----------------------------- src/dns_internal.cc | 6 +----- src/tools.cc | 4 ++-- 5 files changed, 22 insertions(+), 42 deletions(-) diff --git a/compat/osdetect.h b/compat/osdetect.h index 25d44471dd..9f92b09064 100644 --- a/compat/osdetect.h +++ b/compat/osdetect.h @@ -64,9 +64,8 @@ #elif defined(__DragonFly__) #define _SQUID_DRAGONFLY_ 1 -#elif defined(__CYGWIN32__) || defined(__CYGWIN__) +#elif defined(__CYGWIN__) #define _SQUID_CYGWIN_ 1 -#define _SQUID_WINDOWS_ 1 #elif defined(__MINGW32__) || defined(__MINGW__) #define _SQUID_MINGW_ 1 diff --git a/configure.ac b/configure.ac index 15268461c8..eb11283629 100644 --- a/configure.ac +++ b/configure.ac @@ -206,8 +206,7 @@ else fi AC_SUBST(CGIEXT) -AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, - [test "x$squid_host_os" = "xmingw" -o "x$squid_host_os" = "xcygwin"]) +AM_CONDITIONAL(ENABLE_WIN32SPECIFIC,[test "x$squid_host_os" = "xmingw"]) AM_CONDITIONAL(ENABLE_WIN32_IPC,[test "x$squid_host_os" = "xmingw"]) case "$squid_host_os" in @@ -1131,10 +1130,10 @@ SQUID_YESNO([$enableval],[--disable-eui expects no arguments]) ]) if test "x${enable_eui:=yes}" = "xyes" ; then case "$squid_host_os" in - linux|solaris|freebsd|openbsd|netbsd) + linux|solaris|freebsd|openbsd|netbsd|cygwin) ${TRUE} ;; - cygwin|mingw) + mingw) EUILIB="-liphlpapi" ;; *) diff --git a/src/comm.cc b/src/comm.cc index 7f0b06d26d..68d9a200a9 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1082,44 +1082,30 @@ commSetTcpRcvbuf(int fd, int size) int commSetNonBlocking(int fd) { -#if !_SQUID_WINDOWS_ - int flags; - int dummy = 0; -#endif #if _SQUID_WINDOWS_ int nonblocking = TRUE; -#if _SQUID_CYGWIN_ - if (fd_table[fd].type != FD_PIPE) { -#endif - - if (ioctl(fd, FIONBIO, &nonblocking) < 0) { - debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror() << " " << fd_table[fd].type); - return Comm::COMM_ERROR; - } - -#if _SQUID_CYGWIN_ - } else { -#endif -#endif -#if !_SQUID_WINDOWS_ + if (ioctl(fd, FIONBIO, &nonblocking) < 0) { + debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror() << " " << fd_table[fd].type); + return Comm::COMM_ERROR; + } - if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { - debugs(50, 0, "FD " << fd << ": fcntl F_GETFL: " << xstrerror()); - return Comm::COMM_ERROR; - } +#else + int flags; + int dummy = 0; - if (fcntl(fd, F_SETFL, flags | SQUID_NONBLOCK) < 0) { - debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror()); - return Comm::COMM_ERROR; - } + if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { + debugs(50, 0, "FD " << fd << ": fcntl F_GETFL: " << xstrerror()); + return Comm::COMM_ERROR; + } -#endif -#if _SQUID_CYGWIN_ + if (fcntl(fd, F_SETFL, flags | SQUID_NONBLOCK) < 0) { + debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror()); + return Comm::COMM_ERROR; } #endif - fd_table[fd].flags.nonblocking = true; + fd_table[fd].flags.nonblocking = true; return 0; } diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 44b4932126..89aea4cf24 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -429,7 +429,7 @@ static bool idnsParseResolvConf(void) { bool result = false; -#if !_SQUID_WINDOWS_ || _SQUID_CYGWIN_ +#if !_SQUID_WINDOWS_ FILE *fp = fopen(_PATH_RESCONF, "r"); if (fp == NULL) { @@ -437,10 +437,6 @@ idnsParseResolvConf(void) return false; } -#if _SQUID_CYGWIN_ - setmode(fileno(fp), O_TEXT); -#endif - char buf[RESOLV_BUFSZ]; const char *t = NULL; while (fgets(buf, RESOLV_BUFSZ, fp)) { diff --git a/src/tools.cc b/src/tools.cc index 89341015b5..95634a81ca 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -866,7 +866,7 @@ setSystemLimits(void) } #endif /* HAVE_SETRLIMIT */ -#if HAVE_SETRLIMIT && defined(RLIMIT_DATA) +#if HAVE_SETRLIMIT && defined(RLIMIT_DATA) && !_SQUID_CYGWIN_ if (getrlimit(RLIMIT_DATA, &rl) < 0) { debugs(50, DBG_CRITICAL, "getrlimit: RLIMIT_DATA: " << xstrerror()); } else if (rl.rlim_max > rl.rlim_cur) { @@ -882,7 +882,7 @@ setSystemLimits(void) debugs(50, DBG_IMPORTANT, "NOTICE: Could not increase the number of filedescriptors"); } -#if HAVE_SETRLIMIT && defined(RLIMIT_VMEM) +#if HAVE_SETRLIMIT && defined(RLIMIT_VMEM) && !_SQUID_CYGWIN_ if (getrlimit(RLIMIT_VMEM, &rl) < 0) { debugs(50, DBG_CRITICAL, "getrlimit: RLIMIT_VMEM: " << xstrerror()); } else if (rl.rlim_max > rl.rlim_cur) { -- 2.47.2