--------------------- PatchSet 5448 Date: 2002/10/27 11:11:45 Author: serassio Branch: nt-2_5 Tag: (none) Log: Backport of WIN32 changes from nt branch Members: configure.in:1.42.2.5.4.28->1.42.2.5.4.29 port/win32/libmiscutil/libmiscutil.dsp:1.1.2.2->1.1.2.3 src/disk.c:1.8.22.4->1.8.22.5 src/pinger.c:1.4.74.4->1.4.74.5 src/win32.c:1.5.14.13->1.5.14.14 src/repl/Makefile.am:1.2.32.1->1.2.32.1.4.1 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.42.2.5.4.28 retrieving revision 1.42.2.5.4.29 diff -u -r1.42.2.5.4.28 -r1.42.2.5.4.29 --- squid/configure.in 22 Oct 2002 15:16:04 -0000 1.42.2.5.4.28 +++ squid/configure.in 27 Oct 2002 11:12:51 -0000 1.42.2.5.4.29 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.42.2.5.4.28 2002/10/22 15:16:04 serassio Exp $ +dnl $Id: configure.in,v 1.42.2.5.4.29 2002/10/27 11:12:51 serassio Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.5.STABLE1-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.42.2.5.4.28 $)dnl +AC_REVISION($Revision: 1.42.2.5.4.29 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -44,10 +44,25 @@ fi AC_SUBST(CGIEXT) +dnl Check if we are "Cross compiling" for MinGW target on Cygwin +case "$host_os" in +cygwin|cygwin32) + if echo "$CC" | grep -q mno-cygwin; then + echo "Using $CC on $host" + host_os=mingw32 + host=i686-pc-mingw32 + echo "Changed host_os type to $host_os" + echo "Changed host type to $host" + fi + ;; +*) + ;; +esac + dnl this should be expanded to a list of platform sensible support requirements. dnl (adding an option like --enable-cygwin-support doesn't make sense :]) - R Collins 2001 case "$host_os" in -cygwin|cygwin32) +mingw|mingw32|cygwin|cygwin32) AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, true) ;; *) @@ -55,6 +70,24 @@ ;; esac +case "$host_os" in +mingw|mingw32) + AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, true) + AC_PATH_PROG(WIN32_PSAPI, psapi.dll, none) + CFLAGS="$CFLAGS -mthreads" + if test "$ac_cv_path_WIN32_PSAPI" = "none"; then + echo "PSAPI.DLL is recommended to run Squid on Windows NT Platform" + echo "Please see PSAPI.DLL section on doc/win32-relnotes.html." + else + AC_DEFINE(HAVE_WIN32_PSAPI) + LIBS="$LIBS -lpsapi" + fi + ;; +*) + AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, false) + ;; +esac + if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi @@ -797,6 +830,26 @@ fi ]) +dnl Select Default hosts file location +AC_ARG_ENABLE(default-hostsfile, +[ --enable-default-hostsfile=path + Select default location for hosts file. + See hosts_file directive in squid.conf for details], +[ + if test "$enableval" != "none" ; then + if test -f $enableval; then + OPT_DEFAULT_HOSTS=$enableval + else + echo "Warning Unable to find $enableval" + sleep 5 + fi + else + OPT_DEFAULT_HOSTS="none" + fi + echo "Default hosts file set to: $enableval" +],[OPT_DEFAULT_HOSTS="/etc/hosts"]) +AC_SUBST(OPT_DEFAULT_HOSTS) + dnl Enable WIN32 Service compile mode AC_ARG_ENABLE(win32-service, [ --enable-win32-service Compile Squid as a WIN32 Service @@ -1119,6 +1172,13 @@ AC_HEADER_DIRENT AC_HEADER_STDC +case "$host_os" in +mingw|mingw32) + ac_cv_header_crypt_h='yes' + ac_cv_header_getopt_h='yes' + ;; +esac + AC_CHECK_HEADERS( \ arpa/inet.h \ arpa/nameser.h \ @@ -1258,21 +1318,29 @@ AC_DEFINE(HAVE_EXT_MALLINFO) fi -AC_CACHE_CHECK(for struct rusage,ac_cv_have_struct_rusage, [ - AC_TRY_COMPILE([ +case "$host_os" in + mingw|mingw32) + AC_DEFINE(HAVE_STRUCT_RUSAGE) + echo "Using own rusage." + ;; + *) + AC_CACHE_CHECK(for struct rusage,ac_cv_have_struct_rusage, [ + AC_TRY_COMPILE([ #if HAVE_SYS_TIME_H #include #endif #if HAVE_SYS_RESOURCE_H #include #endif], - [struct rusage R;], - ac_cv_have_struct_rusage="yes", + [struct rusage R;], + ac_cv_have_struct_rusage="yes", ac_cv_have_struct_rusage="no") ]) -if test $ac_cv_have_struct_rusage = "yes" ; then - AC_DEFINE(HAVE_STRUCT_RUSAGE) -fi + if test $ac_cv_have_struct_rusage = "yes" ; then + AC_DEFINE(HAVE_STRUCT_RUSAGE) + fi + ;; +esac AC_CACHE_CHECK(for ip->ip_hl, ac_cv_have_ip_hl, [ AC_TRY_COMPILE([#include @@ -1404,6 +1472,17 @@ dnl Check for needed libraries AC_CHECK_LIB(nsl, main) AC_CHECK_LIB(socket, main) +AC_CHECK_LIB(ws2_32, WSAGetLastError) +case "$host_os" in + mingw|mingw32) + echo "Using WIN32 Winsock 2 library." + LIBS="$LIBS -lws2_32" + echo "Using own getopt." + AC_LIBOBJ(getopt) + ;; + *) + ;; +esac dnl Ripped from the Samba sources AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [ @@ -1462,7 +1541,14 @@ ;; esac fi -AC_CHECK_LIB(m, main) +case "$host_os" in +mingw|mingw32) + echo "Use MSVCRT for math functions." + ;; + *) + AC_CHECK_LIB(m, main) + ;; +esac dnl Check for libcrypt dnl Some of our helpers use crypt(3) which may be in libc, or in @@ -1618,6 +1704,16 @@ esac fi +dnl Override some functions detect on MinGW becasue are emulated in source code +case "$host_os" in +mingw|mingw32) + ac_cv_func_crypt='yes' + ac_cv_func_getrusage='yes' + ac_cv_func_select='yes' + ac_cv_func_statfs='yes' + ;; +esac + dnl Check for library functions AC_CHECK_FUNCS(\ bcopy \ @@ -1903,6 +1999,12 @@ SQUID_MAXFD=`cat conftestval`, SQUID_MAXFD=256, SQUID_MAXFD=256) +dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs +case "$host_os" in +mingw|mingw32) + SQUID_MAXFD="2048" + ;; +esac AC_MSG_RESULT($SQUID_MAXFD) AC_DEFINE_UNQUOTED(SQUID_MAXFD, $SQUID_MAXFD) if test "$SQUID_MAXFD" -lt 512 ; then @@ -2058,12 +2160,19 @@ AC_MSG_RESULT("yes") else AC_MSG_RESULT("no") - echo "Will use our own inet_ntoa()." + case "$host_os" in + mingw|mingw32) + echo "Using Win32 resolver instead." + ;; + *) + echo "Will use our own inet_ntoa()." LIBOBJS="$LIBOBJS inet_ntoa.o" # echo "WARNING: This looks bad, and probably prevents Squid from working." # echo " If you're on IRIX and using GCC 2.8, you probably need" # echo " to use the IRIX C compiler instead." # sleep 10 + ;; + esac fi if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then Index: squid/port/win32/libmiscutil/libmiscutil.dsp =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/libmiscutil/Attic/libmiscutil.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/port/win32/libmiscutil/libmiscutil.dsp 27 Mar 2002 21:01:12 -0000 1.1.2.2 +++ squid/port/win32/libmiscutil/libmiscutil.dsp 27 Oct 2002 11:11:45 -0000 1.1.2.3 @@ -101,6 +101,10 @@ # End Source File # Begin Source File +SOURCE=..\..\..\lib\getopt.c +# End Source File +# Begin Source File + SOURCE=..\..\..\lib\hash.c # End Source File # Begin Source File Index: squid/src/disk.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/disk.c,v retrieving revision 1.8.22.4 retrieving revision 1.8.22.5 diff -u -r1.8.22.4 -r1.8.22.5 --- squid/src/disk.c 9 Aug 2002 16:56:45 -0000 1.8.22.4 +++ squid/src/disk.c 27 Oct 2002 11:14:57 -0000 1.8.22.5 @@ -1,6 +1,6 @@ /* - * $Id: disk.c,v 1.8.22.4 2002/08/09 16:56:45 serassio Exp $ + * $Id: disk.c,v 1.8.22.5 2002/10/27 11:14:57 serassio Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -95,7 +95,7 @@ read_callback(-1, F->read_data); } if (F->flags.write_daemon) { -#if defined(_SQUID_MSWIN_) || defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_) +#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. Index: squid/src/pinger.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/pinger.c,v retrieving revision 1.4.74.4 retrieving revision 1.4.74.5 diff -u -r1.4.74.4 -r1.4.74.5 --- squid/src/pinger.c 29 Sep 2002 16:10:52 -0000 1.4.74.4 +++ squid/src/pinger.c 27 Oct 2002 11:14:57 -0000 1.4.74.5 @@ -1,6 +1,6 @@ /* - * $Id: pinger.c,v 1.4.74.4 2002/09/29 16:10:52 serassio Exp $ + * $Id: pinger.c,v 1.4.74.5 2002/10/27 11:14:57 serassio Exp $ * * DEBUG: section 42 ICMP Pinger program * AUTHOR: Duane Wessels @@ -66,8 +66,6 @@ static SOCKET socket_to_squid = -1; #define socket_from_squid socket_to_squid -typedef unsigned char u_int8_t; - #else /* _SQUID_CYGWIN_ */ #include @@ -193,6 +191,8 @@ static void pingerLog(struct icmphdr *, struct in_addr, int, int); static int ipHops(int ttl); static void pingerSendtoSquid(pingerReplyData * preply); +static void pingerOpen(void); +static void pingerClose(void); void pingerOpen(void) @@ -481,6 +481,7 @@ int len = sizeof(pingerReplyData) - MAX_PKT_SZ + preply->psize; if (send(socket_to_squid, (char *) preply, len, 0) < 0) { debug(50, 0) ("pinger: send: %s\n", xstrerror()); + pingerClose(); exit(1); } } @@ -511,13 +512,9 @@ * cevans - do this first. It grabs a raw socket. After this we can * drop privs */ - pingerOpen(); setgid(getgid()); setuid(getuid()); -#ifdef _SQUID_MSWIN_ - atexit(pingerClose); -#endif if ((t = getenv("SQUID_DEBUG"))) debug_args = xstrdup(t); @@ -532,20 +529,21 @@ FD_SET(icmp_sock, &R); x = select(icmp_sock + 1, &R, NULL, NULL, &tv); getCurrentTime(); - if (x < 0) + if (x < 0) { + pingerClose(); exit(1); + } if (FD_ISSET(socket_from_squid, &R)) if (pingerReadRequest() < 0) { debug(42, 0) ("Pinger exiting.\n"); + pingerClose(); exit(1); } if (FD_ISSET(icmp_sock, &R)) pingerRecv(); if (PINGER_TIMEOUT + last_check_time < squid_curtime) { if (send(socket_to_squid, (char *) &tv, 0, 0) < 0) { -#ifdef _SQUID_MSWIN_ - debug(42, 0) ("Pinger exiting.\n"); -#endif + pingerClose(); exit(1); } last_check_time = squid_curtime; Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.5.14.13 retrieving revision 1.5.14.14 diff -u -r1.5.14.13 -r1.5.14.14 --- squid/src/win32.c 27 Oct 2002 10:46:15 -0000 1.5.14.13 +++ squid/src/win32.c 27 Oct 2002 11:14:57 -0000 1.5.14.14 @@ -759,8 +759,8 @@ FILETIME ftCreate, ftExit, ftKernel, ftUser; if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser)) { - LONGLONG tUser64 = (*(LONGLONG *)&ftUser / 10); - LONGLONG tKernel64 = (*(LONGLONG *)&ftKernel / 10); + int64_t tUser64 = (*(int64_t *)&ftUser / 10); + int64_t tKernel64 = (*(int64_t *)&ftKernel / 10); usage->ru_utime.tv_sec =(long)(tUser64 / 1000000); usage->ru_stime.tv_sec =(long)(tKernel64 / 1000000); usage->ru_utime.tv_usec =(long)(tUser64 % 1000000); Index: squid/src/repl/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/repl/Makefile.am,v retrieving revision 1.2.32.1 retrieving revision 1.2.32.1.4.1 diff -u -r1.2.32.1 -r1.2.32.1.4.1 --- squid/src/repl/Makefile.am 27 Dec 2001 02:28:54 -0000 1.2.32.1 +++ squid/src/repl/Makefile.am 27 Oct 2002 11:14:57 -0000 1.2.32.1.4.1 @@ -16,8 +16,11 @@ liblru_a_SOURCES = lru/store_repl_lru.c libheap_a_SOURCES = heap/store_heap_replacement.h heap/store_heap_replacement.c heap/store_repl_heap.c -INCLUDES = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \ - -I$(top_srcdir)/src/ +if ENABLE_WIN32SPECIFIC +INCLUDES = -I. -I$(top_srcdir)/port/win32/include -I$(top_srcdir)/include -I$(top_srcdir)/src +else +INCLUDES = -I. -I$(top_srcdir)/include -I$(top_srcdir)/src +endif ##all: ## @test -z "$(SUBDIRS)" || for dir in $(SUBDIRS); do \