#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
#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>
+ *
+ * <code> == 0, child has exited, info is the exit value
+ * <code> == 1..7e, child has exited, info is the signal number.
+ * <code> == 7f, child has stopped, info was the signal number.
+ * <code> == 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 */
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");
#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.])
*/
#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"
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;
}
*/
/* 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
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
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);
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);
}
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);
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);
}
{
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;
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;
}
#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();
#include "comm.h"
#include "comm/Connection.h"
#include "comm/Loops.h"
- #include "ipc/StartListening.h"
+ #include "comm/UdpOpenDialer.h"
+#include "compat/strsep.h"
#include "ip/Address.h"
#include "ip/tools.h"
#include "snmp_core.h"
#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"
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);
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;
delete[] filename;
return false;
} else if ( debug & 0x02 ) {
- fprintf( stderr, "# creating %s\n", filename );
+ std::cerr << "# creating" << filename;
}
- *t++ = '/';
+ *t = '/';
+ ++t;
}
// create file