From: Amos Jeffries Date: Wed, 8 Aug 2012 08:16:36 +0000 (-0600) Subject: merged from trunk X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmswin;p=thirdparty%2Fsquid.git merged from trunk --- 158c0d2cc61f0f2a9c302983f2d6418673310263 diff --cc compat/os/mswin.h index 5dfe7d201d,ad685ea554..d7be49db53 --- a/compat/os/mswin.h +++ b/compat/os/mswin.h @@@ -109,15 -89,16 +109,15 @@@ typedef unsigned long ino_t #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define fileno _fileno #define fstat _fstati64 -#endif +#endif /* _MSC_VER */ - #if 0 + #if !defined(_SQUID_MINGW_) // MinGW defines these properly + SQUIDCEXTERN int WIN32_ftruncate(int fd, off_t size); #define ftruncate WIN32_ftruncate - #if !_SQUID_MINGW_ - extern int WIN32_ftruncate(int fd, off_t size); + SQUIDCEXTERN int WIN32_truncate(const char *pathname, off_t length); + #define truncate WIN32_truncate #endif - #endif /* 0 */ #define getcwd _getcwd #define getpid _getpid -#define getrusage WIN32_getrusage #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ #define lseek _lseeki64 #define memccpy _memccpy @@@ -872,46 -764,5 +872,49 @@@ SQUIDCEXTERN DWORD WIN32_IpAddrChangeMo #define PRINTF_FORMAT_ARG3 #endif +#if !HAVE_SYSLOG +/* syslog compatibility layer derives from git */ +#define LOG_PID 0x01 +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 +#define LOG_DAEMON (3<<3) + +void openlog(const char *ident, int logopt, int facility); +void syslog(int priority, const char *fmt, ...); +#endif + +#if _SQUID_MINGW_ +/* broken mingw header... */ + +/* MinGW missing bits from sys/wait.h */ +/* A status looks like: + * <2 bytes info> <2 bytes code> + * + * == 0, child has exited, info is the exit value + * == 1..7e, child has exited, info is the signal number. + * == 7f, child has stopped, info was the signal number. + * == 80, there was a core dump. + */ +#define WIFEXITED(w) (((w) & 0xff) == 0) +#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) +#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) +#define WEXITSTATUS(w) (((w) >> 8) & 0xff) +#define WTERMSIG(w) ((w) & 0x7f) +#define WSTOPSIG WEXITSTATUS + + +#endif + +/* prototypes */ +void WIN32_maperror(unsigned long WIN32_oserrno); ++ ++#include "compat/strsep.h" ++ #endif /* _SQUID_WINDOWS_ */ #endif /* SQUID_OS_MSWIN_H */ diff --cc compat/xalloc.cc index a9ab10c8bd,3f3a9ae13d..601ce946c7 --- a/compat/xalloc.cc +++ b/compat/xalloc.cc @@@ -78,7 -78,7 +78,7 @@@ xcalloc(size_t n, size_t sz if (p == NULL) { if (failure_notify) { static char msg[128]; - snprintf(msg, 128, "xcalloc: Unable to allocate %"PRIuSIZE" blocks of %"PRIuSIZE" bytes!\n", n, sz); - snprintf(msg, 128, "xcalloc: Unable to allocate %lu blocks of %lu bytes!\n", (unsigned long)n, (unsigned long)sz); ++ snprintf(msg, 128, "xcalloc: Unable to allocate %" PRIuSIZE " blocks of %" PRIuSIZE " bytes!\n", n, sz); failure_notify(msg); } else { perror("xcalloc"); diff --cc configure.ac index b96ee231c5,c81d8d9314..4a860fa95c --- a/configure.ac +++ b/configure.ac @@@ -1170,9 -1144,7 +1172,10 @@@ if test "x${enable_eui:=yes}" = "xyes" #endif ]]) fi + AC_SUBST(EUILIB) + +SQUID_CHECK_RECV_ARG_TYPE + AC_MSG_NOTICE([EUI (MAC address) controls enabled: $enable_eui]) SQUID_DEFINE_BOOL(USE_SQUID_EUI,$enable_eui, [Define this to include code which lets you use ethernet addresses. This code uses API initially defined in 4.4-BSD.]) diff --cc src/DiskIO/DiskThreads/aiops_win32.cc index 43b3402c55,6b9eb6a966..d6681f78f8 --- a/src/DiskIO/DiskThreads/aiops_win32.cc +++ b/src/DiskIO/DiskThreads/aiops_win32.cc @@@ -35,7 -35,8 +35,7 @@@ */ #include "squid-old.h" - #include "CommIO.h" -#include "squid_windows.h" + #include "DiskIO/DiskThreads/CommIO.h" #include "DiskThreads.h" #include "SquidTime.h" #include "Store.h" diff --cc src/comm.cc index f7a4d71b74,32adceb352..a99bc9985e --- a/src/comm.cc +++ b/src/comm.cc @@@ -386,8 -384,8 +385,8 @@@ comm_local_port(int fd temp.InitAddrInfo(addr); - if (getsockname(fd, addr->ai_addr, &(addr->ai_addrlen)) ) { + if (Squid::getsockname(fd, addr->ai_addr, &(addr->ai_addrlen)) ) { - debugs(50, 1, "comm_local_port: Failed to retrieve TCP/UDP port number for socket: FD " << fd << ": " << xstrerror()); + debugs(50, DBG_IMPORTANT, "comm_local_port: Failed to retrieve TCP/UDP port number for socket: FD " << fd << ": " << xstrerror()); temp.FreeAddrInfo(addr); return 0; } diff --cc src/debug.cc index b30e637e26,2f0186cd74..5411ff7a0c --- a/src/debug.cc +++ b/src/debug.cc @@@ -484,10 -484,10 +484,10 @@@ _db_rotate_log(void */ /* Rotate numbers 0 through N up one */ for (int i = Debug::rotateNumber; i > 1;) { - i--; + --i; snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1); snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i); -#if _SQUID_MSWIN_ +#if _SQUID_WINDOWS_ remove (to); #endif diff --cc src/fde.cc index c3e5f2d612,05cc7d524e..f662f0b94a --- a/src/fde.cc +++ b/src/fde.cc @@@ -54,9 -54,9 +54,9 @@@ fde::dumpStats (StoreEntry &dumpEntry, if (!flags.open) return; -#if _SQUID_MSWIN_ +#if _SQUID_WINDOWS_ - storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7"PRId64"%c %7"PRId64"%c %-21s %s\n", + storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7" PRId64 "%c %7" PRId64 "%c %-21s %s\n", fdNumber, win32.handle, #else diff --cc src/fs/coss/store_dir_coss.cc index 793c8abc69,b4bd61e732..c7f6323174 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@@ -966,8 -966,8 +966,8 @@@ voi CossSwapDir::statfs(StoreEntry & sentry) const { storeAppendPrintf(&sentry, "\n"); - storeAppendPrintf(&sentry, "Maximum Size: %"PRIu64" KB\n", (maxSize() >> 10)); - storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", maxSize() >> 10); - storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", currentSize() / 1024.0); ++ storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", (maxSize() >> 10)); + storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", (currentSize() / 1024.0)); storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n", Math::doublePercent(currentSize(), maxSize()) ); storeAppendPrintf(&sentry, "Number of object collisions: %d\n", (int) numcollisions); @@@ -1059,7 -1059,7 +1059,7 @@@ CossSwapDir::swappedOut(const StoreEntr void CossSwapDir::dump(StoreEntry &entry)const { - storeAppendPrintf(&entry, " %"PRIu64, (max_size >> 20)); - storeAppendPrintf(&entry, " %" PRIu64, maxSize() >> 20); ++ storeAppendPrintf(&entry, " %" PRIu64, (max_size >> 20)); dumpOptions(&entry); } diff --cc src/icmp/IcmpSquid.cc index 3af7efcb2c,4ff85a9ff6..14b33b2a73 --- a/src/icmp/IcmpSquid.cc +++ b/src/icmp/IcmpSquid.cc @@@ -279,9 -279,9 +279,9 @@@ IcmpSquid::Close(void if (icmp_sock < 0) return; - debugs(37, 1, HERE << "Closing Pinger socket on FD " << icmp_sock); + debugs(37, DBG_IMPORTANT, HERE << "Closing Pinger socket on FD " << icmp_sock); -#if _SQUID_MSWIN_ +#if _SQUID_WINDOWS_ send(icmp_sock, (const void *) "$shutdown\n", 10, 0); diff --cc src/ipc_win32.cc index 8b95407c59,60223f7390..7e787c3803 --- a/src/ipc_win32.cc +++ b/src/ipc_win32.cc @@@ -277,11 -276,11 +277,11 @@@ ipcCreate(int type, const char *prog, c return ipcCloseAllFD(prfd, pwfd, -1, -1); } - x = send(pwfd, (const void *)ok_string, strlen(ok_string), 0); + x = Squid::send(pwfd, ok_string, strlen(ok_string), 0); if (x < 0) { - debugs(54, 0, "ipcCreate: PARENT: OK write test failed"); - debugs(54, 0, "--> read: " << xstrerror()); + debugs(54, DBG_CRITICAL, "ipcCreate: PARENT: OK write test failed"); + debugs(54, DBG_CRITICAL, "--> read: " << xstrerror()); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } @@@ -351,11 -350,11 +351,11 @@@ ipcSend(int cwfd, const char *buf, int { int x; - x = send(cwfd, (const void *)buf, len, 0); + x = Squid::send(cwfd, buf, len, 0); if (x < 0) { - debugs(54, 0, "sendto FD " << cwfd << ": " << xstrerror()); - debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); + debugs(54, DBG_CRITICAL, "sendto FD " << cwfd << ": " << xstrerror()); + debugs(54, DBG_CRITICAL, "ipcCreate: CHILD: hello write test failed"); } return x; @@@ -425,11 -424,11 +425,11 @@@ ipc_thread_1(void *in_params goto cleanup; } - x = send(cwfd, (const void *)hello_string, strlen(hello_string) + 1, 0); + x = Squid::send(cwfd, hello_string, strlen(hello_string) + 1, 0); if (x < 0) { - debugs(54, 0, "sendto FD " << cwfd << ": " << xstrerror()); - debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); + debugs(54, DBG_CRITICAL, "sendto FD " << cwfd << ": " << xstrerror()); + debugs(54, DBG_CRITICAL, "ipcCreate: CHILD: hello write test failed"); goto cleanup; } diff --cc src/main.cc index d982530f05,7d307591e8..3a71fc3891 --- a/src/main.cc +++ b/src/main.cc @@@ -976,25 -978,25 +971,25 @@@ mainInitialize(void #if _SQUID_WINDOWS_ if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { - debugs(1, 0, "Running as " << WIN32_Service_name << " Windows System Service on " << WIN32_OS_string); - debugs(1, 0, "Service command line is: " << WIN32_Service_Command_Line); + debugs(1, DBG_CRITICAL, "Running as " << WIN32_Service_name << " Windows System Service on " << WIN32_OS_string); + debugs(1, DBG_CRITICAL, "Service command line is: " << WIN32_Service_Command_Line); } else - debugs(1, 0, "Running on " << WIN32_OS_string); + debugs(1, DBG_CRITICAL, "Running on " << WIN32_OS_string); #endif - debugs(1, 1, "Process ID " << getpid()); + debugs(1, DBG_IMPORTANT, "Process ID " << getpid()); - debugs(1, 1, "Process Roles:" << ProcessRoles()); + debugs(1, DBG_IMPORTANT, "Process Roles:" << ProcessRoles()); setSystemLimits(); - debugs(1, 1, "With " << Squid_MaxFD << " file descriptors available"); + debugs(1, DBG_IMPORTANT, "With " << Squid_MaxFD << " file descriptors available"); -#if _SQUID_MSWIN_ +#if _SQUID_WINDOWS_ - debugs(1, 1, "With " << _getmaxstdio() << " CRT stdio descriptors available"); + debugs(1, DBG_IMPORTANT, "With " << _getmaxstdio() << " CRT stdio descriptors available"); if (WIN32_Socks_initialized) - debugs(1, 1, "Windows sockets initialized"); + debugs(1, DBG_IMPORTANT, "Windows sockets initialized"); if (WIN32_OS_version > _WIN_OS_WINNT) { WIN32_IpAddrChangeMonitorInit(); diff --cc src/snmp_core.cc index 81116cc60b,6316a2c491..25613b52e7 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@@ -35,8 -35,7 +35,8 @@@ #include "comm.h" #include "comm/Connection.h" #include "comm/Loops.h" + #include "comm/UdpOpenDialer.h" +#include "compat/strsep.h" - #include "ipc/StartListening.h" #include "ip/Address.h" #include "ip/tools.h" #include "snmp_core.h" diff --cc src/tools.cc index cad86adf52,eaf5fc16c8..555281ff42 --- a/src/tools.cc +++ b/src/tools.cc @@@ -34,8 -34,8 +34,9 @@@ #include "squid-old.h" #include "base/Subscription.h" +#include "compat/initgroups.h" #include "fde.h" + #include "htcp.h" #include "ICP.h" #include "ip/Intercept.h" #include "ip/QosConfig.h" diff --cc src/unlinkd.cc index 8576dd7c20,62e7ad80a1..18c2a909e4 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@@ -258,9 -259,9 +259,9 @@@ unlinkdInit(void if (FD_PIPE == fd_table[unlinkd_wfd].type) commUnsetNonBlocking(unlinkd_wfd); - debugs(2, 1, "Unlinkd pipe opened on FD " << unlinkd_wfd); + debugs(2, DBG_IMPORTANT, "Unlinkd pipe opened on FD " << unlinkd_wfd); -#if _SQUID_MSWIN_ +#if _SQUID_WINDOWS_ debugs(2, 4, "Unlinkd handle: 0x" << std::hex << hIpc << std::dec << ", PID: " << pid); diff --cc src/win32.cc index 23159036d9,69136407fe..51f19e131d --- a/src/win32.cc +++ b/src/win32.cc @@@ -48,10 -49,118 +48,8 @@@ SQUIDCEXTERN LPCRITICAL_SECTION dbg_mut void WIN32_ExceptionHandlerCleanup(void); static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = NULL; -- -int WIN32_pipe(int handles[2]) -{ - int new_socket; - fde *F = NULL; -- - int Win32__WSAFDIsSet(int fd, fd_set FAR * set - ) - Ip::Address localhost; - Ip::Address handle0; - Ip::Address handle1; - struct addrinfo *AI = NULL; - - localhost.SetLocalhost(); - - /* INET6: back-compatible: localhost pipes default to IPv4 unless set otherwise. - * it is blocked by untested helpers on many admins configs - * if this proves to be wrong it can die easily. - */ - localhost.SetIPv4(); - - handles[0] = handles[1] = -1; - - ++statCounter.syscalls.sock.sockets; - - handle0 = localhost; - handle0.SetPort(0); - handle0.GetAddrInfo(AI); - - if ((new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0) - return -1; - - if (bind(new_socket, AI->ai_addr, AI->ai_addrlen) < 0 || - listen(new_socket, 1) < 0 || getsockname(new_socket, AI->ai_addr, &(AI->ai_addrlen) ) < 0 || - (handles[1] = socket(AI->ai_family, AI->ai_socktype, 0)) < 0) { - closesocket(new_socket); - return -1; - } - - handle0 = *AI; // retrieve the new details returned by connect() - - handle1.SetPort(handle1.GetPort()); - handle1.GetAddrInfo(AI); - - if (connect(handles[1], AI->ai_addr, AI->ai_addrlen) < 0 || - (handles[0] = accept(new_socket, AI->ai_addr, &(AI->ai_addrlen)) ) < 0) { - closesocket(handles[1]); - handles[1] = -1; - closesocket(new_socket); - return -1; - } - - closesocket(new_socket); - - F = &fd_table[handles[0]]; - F->local_addr = handle0; - - F = &fd_table[handles[1]]; - F->local_addr = localhost; - handle1.NtoA(F->ipaddr, MAX_IPSTRLEN); - F->remote_port = handle1.GetPort(); - - return 0; -} - -int WIN32_getrusage(int who, struct rusage *usage) -{ -#if HAVE_WIN32_PSAPI - - if (WIN32_OS_version >= _WIN_OS_WINNT) { - /* On Windows NT and later call PSAPI.DLL for process Memory */ - /* informations -- Guido Serassio */ - HANDLE hProcess; - PROCESS_MEMORY_COUNTERS pmc; - hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | - PROCESS_VM_READ, - FALSE, GetCurrentProcessId()); - { - /* Microsoft CRT doesn't have getrusage function, */ - /* so we get process CPU time information from PSAPI.DLL. */ - FILETIME ftCreate, ftExit, ftKernel, ftUser; - - if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser)) { - int64_t *ptUser = (int64_t *)&ftUser; - int64_t tUser64 = *ptUser / 10; - int64_t *ptKernel = (int64_t *)&ftKernel; - int64_t tKernel64 = *ptKernel / 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); - usage->ru_stime.tv_usec =(long)(tKernel64 % 1000000); - } else { - CloseHandle( hProcess ); - return -1; - } - } - - if (GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc))) { - usage->ru_maxrss=(DWORD)(pmc.WorkingSetSize / getpagesize()); - usage->ru_majflt=pmc.PageFaultCount; - } else { - CloseHandle( hProcess ); - return -1; - } - - CloseHandle( hProcess ); - } - -#endif - return 0; -} - + int + Win32__WSAFDIsSet(int fd, fd_set FAR * set) { fde *F = &fd_table[fd]; SOCKET s = F->win32.handle; diff --cc tools/purge/copyout.cc index cf74515b15,4e5da68ab4..9f90bf29ac --- a/tools/purge/copyout.cc +++ b/tools/purge/copyout.cc @@@ -164,9 -155,10 +164,10 @@@ copy_out( size_t filesize, size_t metas delete[] filename; return false; } else if ( debug & 0x02 ) { - fprintf( stderr, "# creating %s\n", filename ); + std::cerr << "# creating" << filename; } - *t++ = '/'; + *t = '/'; + ++t; } // create file