-/* $Id: cache_cf.cc,v 1.5 1996/03/27 01:45:54 wessels Exp $ */
+/* $Id: cache_cf.cc,v 1.6 1996/03/27 18:15:40 wessels Exp $ */
#include "squid.h"
int maxObjSize;
int defaultTtl;
} Gopher, Http, Ftp;
-#if USE_WAIS_RELAY
struct {
int maxObjSize;
int defaultTtl;
char *relayHost;
int relayPort;
} Wais;
-#endif
int negativeTtl;
int readTimeout;
int lifetimeDefault;
int sourcePing;
int quickAbort;
int commonLogFormat;
- int debugLevel;
int neighborTimeout;
int stallDelay;
int singleParentBypass;
int withProxy;
} Accel;
char *appendDomain;
+ char *debugOptions;
} Config;
#define DefaultMemMaxSize (16 << 20) /* 16 MB */
#define DefaultGopherMaxObjSize (4 << 20) /* 4 MB */
#define DefaultHttpDefaultTtl (7 * 24 * 60 * 60) /* 1 week */
#define DefaultHttpMaxObjSize (4 << 20) /* 4 MB */
-#if USE_WAIS_RELAY
#define DefaultWaisDefaultTtl (7 * 24 * 60 * 60) /* 1 week */
#define DefaultWaisMaxObjSize (4 << 20) /* 4 MB */
#define DefaultWaisRelayHost (char *)NULL
#define DefaultWaisRelayPort -1
-#endif
#define DefaultNegativeTtl (5 * 60) /* 5 min */
#define DefaultReadTimeout (15 * 60) /* 15 min */
#define DefaultEffectiveGroup (char *)NULL /* default NONE */
#define DefaultAppendDomain (char *)NULL /* default NONE */
-#define DefaultDebugLevel 1 /* default 1 */
+#define DefaultDebugOptions "ALL,1"
#define DefaultAccelHost (char *)NULL /* default NONE */
#define DefaultAccelPrefix (char *)NULL /* default NONE */
#define DefaultAccelPort 0 /* default off */
int single_parent_bypass = 0;
int getDnsChildren();
-static char w_space[] = " \t\n";
+char w_space[] = " \t\n";
static void configSetFactoryDefaults();
static void configDoConfigure();
c3 = ((int) naddr & 0x0000ff00) >> 8;
c4 = ((int) naddr & 0x000000ff);
- debug(10, "ip_access_check: Using %d.%d.%d.%d\n", c1, c2, c3, c4);
+ debug(0, 10, "ip_access_check: Using %d.%d.%d.%d\n", c1, c2, c3, c4);
if ((c1 == 127) && (c2 == 0) && (c3 == 0) && (c4 == 1))
return IP_ALLOW; /* always allow localhost */
for (p = list; p; p = p->next) {
- debug(10, "ip_access_check: %d.%d.%d.%d vs %d.%d.%d.%d\n",
+ debug(0, 10, "ip_access_check: %d.%d.%d.%d vs %d.%d.%d.%d\n",
c1, c2, c3, c4, p->a1, p->a2, p->a3, p->a4);
if (ip_acl_match(c1, c2, c3, c4, p->a1, p->a2, p->a3, p->a4))
return p->access;
self_destruct(line_in);
-void parseCacheHostLine(line_in)
+static void parseCacheHostLine(line_in)
char *line_in;
{
char *type = NULL;
neighbors_cf_add(hostname, type, ascii_port, udp_port, proxy_only);
}
-void parseHostDomainLine(line_in)
+static void parseHostDomainLine(line_in)
char *line_in;
{
char *host = NULL;
}
}
-void parseMailTraceLine(line_in)
+static void parseMailTraceLine(line_in)
char *line_in;
{
fprintf(stderr, "'mail_trace' not supported in this version; ignored.\n");
}
-void parseSourcePingLine(line_in)
+static void parseSourcePingLine(line_in)
char *line_in;
{
char *srcping;
}
-void parseQuickAbortLine(line_in)
+static void parseQuickAbortLine(line_in)
char *line_in;
{
char *abort;
}
-void parseMemLine(line_in)
+static void parseMemLine(line_in)
char *line_in;
{
char *token;
Config.Mem.maxSize = i << 20;
}
-void parseMemHighLine(line_in)
+static void parseMemHighLine(line_in)
char *line_in;
{
char *token;
Config.Mem.highWatherMark = i;
}
-void parseMemLowLine(line_in)
+static void parseMemLowLine(line_in)
char *line_in;
{
char *token;
Config.Mem.lowWaterMark = i;
}
-void parseHotVmFactorLine(line_in)
+static void parseHotVmFactorLine(line_in)
char *line_in;
{
char *token = NULL;
Config.hotVmFactor = d;
}
-void parseSwapLine(line_in)
+static void parseSwapLine(line_in)
char *line_in;
{
char *token;
Config.Swap.maxSize = i << 10;
}
-void parseSwapHighLine(line_in)
+static void parseSwapHighLine(line_in)
char *line_in;
{
char *token;
Config.Swap.highWatherMark = i;
}
-void parseSwapLowLine(line_in)
+static void parseSwapLowLine(line_in)
char *line_in;
{
char *token;
Config.Swap.lowWaterMark = i;
}
-void parseHttpLine(line_in)
+static void parseHttpLine(line_in)
char *line_in;
{
char *token;
Config.Http.defaultTtl = i * 60;
}
-void parseGopherLine(line_in)
+static void parseGopherLine(line_in)
char *line_in;
{
char *token;
Config.Gopher.defaultTtl = i * 60;
}
-void parseFtpLine(line_in)
+static void parseFtpLine(line_in)
char *line_in;
{
char *token;
Config.Ftp.defaultTtl = i * 60;
}
-void parseTTLPattern(line_in)
+static void parseTTLPattern(line_in)
char *line_in;
{
char *token;
safe_free(pattern);
}
-void parseNegativeLine(line_in)
+static void parseNegativeLine(line_in)
char *line_in;
{
char *token;
Config.negativeTtl = i * 60;
}
-void parseReadTimeoutLine(line_in)
+static void parseReadTimeoutLine(line_in)
char *line_in;
{
char *token;
Config.readTimeout = i * 60;
}
-void parseLifetimeLine(line_in)
+static void parseLifetimeLine(line_in)
char *line_in;
{
char *token;
Config.lifetimeDefault = i * 60;
}
-void parseConnectTimeout(line_in)
+static void parseConnectTimeout(line_in)
char *line_in;
{
char *token;
Config.connectTimeout = i;
}
-void parseCleanRateLine(line_in)
+static void parseCleanRateLine(line_in)
char *line_in;
{
char *token;
Config.cleanRate = i * 60;
}
-void parseDnsChildrenLine(line_in)
+static void parseDnsChildrenLine(line_in)
char *line_in;
{
char *token;
Config.dnsChildren = i;
}
-void parseMgrLine(line_in)
+static void parseMgrLine(line_in)
char *line_in;
{
char *token;
Config.adminEmail = xstrdup(token);
}
-void parseDirLine(line_in)
+static void parseDirLine(line_in)
char *line_in;
{
char *token;
}
-void parseHttpdAccelLine(line_in)
+static void parseHttpdAccelLine(line_in)
char *line_in;
{
char *token;
httpd_accel_mode = 1;
}
-void parseHttpdAccelWithProxyLine(line_in)
+static void parseHttpdAccelWithProxyLine(line_in)
char *line_in;
{
char *proxy;
Config.Accel.withProxy = 0;
}
-void parseEffectiveUserLine(line_in)
+static void parseEffectiveUserLine(line_in)
char *line_in;
{
char *token;
Config.effectiveGroup = xstrdup(token);
}
-void parseLogLine(line_in)
+static void parseLogLine(line_in)
char *line_in;
{
char *token;
- int i;
token = strtok(NULL, w_space);
if (token == (char *) NULL)
self_destruct(line_in);
safe_free(Config.Log.log);
Config.Log.log = xstrdup(token);
- GetInteger(i);
- Config.debugLevel = i;
}
-void parseAccessLogLine(line_in)
+static void parseAccessLogLine(line_in)
char *line_in;
{
char *token;
Config.Log.access = xstrdup(token);
}
-void parseHierachyLogLine(line_in)
+static void parseHierachyLogLine(line_in)
char *line_in;
{
char *token;
Config.Log.hierarchy = xstrdup(token);
}
-void parseLogfileRotateLine(line_in)
+static void parseLogfileRotateLine(line_in)
char *line_in;
{
char *token;
Config.Log.rotateNumber = i;
}
-void parseFtpProgramLine(line_in)
+static void parseFtpProgramLine(line_in)
char *line_in;
{
char *token;
Config.Program.ftpget = xstrdup(token);
}
-void parseFtpOptionsLine(line_in)
+static void parseFtpOptionsLine(line_in)
char *line_in;
{
char *token;
Config.Program.ftpget_opts = xstrdup(token);
}
-void parseDnsProgramLine(line_in)
+static void parseDnsProgramLine(line_in)
char *line_in;
{
char *token;
Config.Program.dnsserver = xstrdup(token);
}
-void parseEmulateLine(line_in)
+static void parseEmulateLine(line_in)
char *line_in;
{
char *token;
Config.commonLogFormat = 0;
}
-#if USE_WAIS_RELAY
-void parseWAISRelayLine(line_in)
+static void parseWAISRelayLine(line_in)
char *line_in;
{
char *token;
Config.Wais.maxObjSize = i << 20;
}
-#endif
-
-void parseProxyAllowLine(line_in)
+static void parseProxyAllowLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&proxy_ip_acl, token, IP_ALLOW);
}
-void parseAccelAllowLine(line_in)
+static void parseAccelAllowLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&accel_ip_acl, token, IP_ALLOW);
}
-void parseManagerAllowLine(line_in)
+static void parseManagerAllowLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&manager_ip_acl, token, IP_ALLOW);
}
-void parseProxyDenyLine(line_in)
+static void parseProxyDenyLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&proxy_ip_acl, token, IP_DENY);
}
-void parseAccelDenyLine(line_in)
+static void parseAccelDenyLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&accel_ip_acl, token, IP_DENY);
}
-void parseManagerDenyLine(line_in)
+static void parseManagerDenyLine(line_in)
char *line_in;
{
char *token;
addToIPACL(&manager_ip_acl, token, IP_DENY);
}
-void parseLocalIPLine(line_in)
+static void parseLocalIPLine(line_in)
char *line_in;
{
char *token;
}
}
-void parseHttpStopLine(line_in)
+static void parseHttpStopLine(line_in)
char *line_in;
{
char *token;
addToStopList(&http_stoplist, token);
}
-void parseGopherStopLine(line_in)
+static void parseGopherStopLine(line_in)
char *line_in;
{
char *token;
return;
addToStopList(&gopher_stoplist, token);
}
-void parseFtpStopLine(line_in)
+static void parseFtpStopLine(line_in)
char *line_in;
{
char *token;
addToStopList(&ftp_stoplist, token);
}
-void parseAppendDomainLine(line_in)
+static void parseAppendDomainLine(line_in)
char *line_in;
{
char *token;
Config.appendDomain = xstrdup(token);
}
-void parseBindAddressLine(line_in)
+static void parseBindAddressLine(line_in)
char *line_in;
{
char *token;
token = strtok(NULL, w_space);
if (token == (char *) NULL)
self_destruct(line_in);
- debug(1, "parseBindAddressLine: adding %s\n", token);
+ debug(0, 1, "parseBindAddressLine: adding %s\n", token);
addToStopList(&bind_addr_list, token);
}
-void parseBlockListLine(line_in)
+static void parseBlockListLine(line_in)
char *line_in;
{
char *token;
blockAddToList(token);
}
-void parseLocalDomainLine(line_in)
+static void parseLocalDomainLine(line_in)
char *line_in;
{
char *token;
}
}
-void parseInsideFirewallLine(line_in)
+static void parseInsideFirewallLine(line_in)
char *line_in;
{
char *token;
}
}
-void parseAsciiPortLine(line_in)
+static void parseAsciiPortLine(line_in)
char *line_in;
{
char *token;
Config.Port.ascii = i;
}
-void parseUdpPortLine(line_in)
+static void parseUdpPortLine(line_in)
char *line_in;
{
char *token;
Config.Port.udp = i;
}
-void parseNeighborTimeout(line_in)
+static void parseNeighborTimeout(line_in)
char *line_in;
{
char *token;
Config.neighborTimeout = i;
}
-void parseSingleParentBypassLine(line_in)
+static void parseSingleParentBypassLine(line_in)
char *line_in;
{
char *token;
Config.singleParentBypass = 1;
}
-void parseCacheNeighborObjLine(line_in)
- char *line_in;
-{
- printf("WARNING: 'cache_neighbor_obj' is no longer supported. Please\n");
- printf(" use 'proxy-only' on the 'cache_host' line instead now.\n");
- fflush(stdout);
-}
-
-void parseBehindFirewallLine(line_in)
+static void parseDebugOptionsLine(line_in)
char *line_in;
{
- printf("WARNING: 'behind_firewall' is no longer supported. Please\n");
- printf(" use the 'inside_firewall' and 'local_domain' lines\n");
- printf(" instead now.\n");
- fflush(stdout);
-}
-
-void parseDirectFetchLine(line_in)
- char *line_in;
-{
- printf("WARNING: 'direct_fetch' is no longer supported. Please\n");
- printf(" use the 'inside_firewall' and 'local_domain' lines\n");
- printf(" instead now.\n");
- fflush(stdout);
+ char *token;
+ token = strtok(NULL, ""); /* Note "", don't separate these */
+ safe_free(Config.debugOptions);
+ if (token == (char *) NULL) {
+ Config.debugOptions = NULL;
+ return;
+ }
+ Config.debugOptions = xstrdup(token);
}
-/* Maybe a bit heavy handed, but parser is immune to virtually every sane
- * persons definition of white space */
-
int parseConfigFile(file_name)
char *file_name;
{
- FILE *fp = fopen(file_name, "r");
- char *token, tmp_line[BUFSIZ];
- char line_in[BUFSIZ];
- char fatal_str[4096];
+ FILE *fp = NULL;
+ char *token = NULL;
+ static char tmp_line[BUFSIZ];
+ static char line_in[BUFSIZ];
+ static char fatal_str[4096];
/* Initialize a few global strings, in case they aren't user defined */
configSetFactoryDefaults();
- if (fp == NULL) {
+ if ((fp = fopen(file_name, "r")) == NULL) {
sprintf(fatal_str, "Unable to open configuration file: %s", file_name);
fatal(fatal_str);
}
if (line_in[0] == '#' || line_in[0] == '\n' || line_in[0] == '\0')
continue; /* skip comments */
- /* Use tmp_line as a temporary pointer to the input line */
- /* AWC Debug */
if (line_in[0] == '\n')
continue;
-
strcpy(tmp_line, line_in);
if ((token = strtok(tmp_line, w_space)) == NULL)
continue;
else if (!strcmp(token, "neighbour_timeout")) /* alternate spelling */
parseNeighborTimeout(line_in);
- /* XXX This has been replaced with proxy-only on cache-host line */
- /* give warning if cache_neighbor_obj is used */
- else if (!strcmp(token, "cache_neighbor_obj"))
- parseCacheNeighborObjLine(line_in);
-
/* Parse a cache_dir line */
else if (!strcmp(token, "cache_dir"))
parseDirLine(line_in);
else if (!strcmp(token, "proxy_deny"))
parseProxyDenyLine(line_in);
-#ifndef BACKWARDS_COMPATIBLE
- /* Parse a access_allow line */
- else if (!strcmp(token, "access_allow")) /* now proxy_allow */
- parseProxyAllowLine(line_in);
-
- /* Parse a access_deny line */
- else if (!strcmp(token, "access_deny")) /* now proxy_deny */
- parseProxyDenyLine(line_in);
-#endif
-
/* Parse a accel_allow line */
else if (!strcmp(token, "accel_allow"))
parseAccelAllowLine(line_in);
else if (!strcmp(token, "manager_deny"))
parseManagerDenyLine(line_in);
-#ifndef BACKWARDS_COMPATIBLE
- /* Parse a manager_access_allow line */
- else if (!strcmp(token, "manager_access_allow")) /* now manager_allow */
- parseManagerAllowLine(line_in);
-
- /* Parse a manager_access_deny line */
- else if (!strcmp(token, "manager_access_deny")) /* now manager_deny */
- parseManagerDenyLine(line_in);
-#endif
-
/* Parse a http_stop line */
else if (!strcmp(token, "http_stop"))
parseHttpStopLine(line_in);
else if (!strcmp(token, "source_ping"))
parseSourcePingLine(line_in);
- /* Parse behind_firewall line */
- else if (!strcmp(token, "behind_firewall"))
- parseBehindFirewallLine(line_in);
-
- /* Parse direct_fetch line */
- else if (!strcmp(token, "direct_fetch"))
- parseDirectFetchLine(line_in);
-
/* Parse quick_abort line */
else if (!strcmp(token, "quick_abort"))
parseQuickAbortLine(line_in);
- /* Parse old abort_mode line - FOR BACKWARDS COMPATIBILITY */
- else if (!strcmp(token, "abort_mode"))
- parseQuickAbortLine(line_in);
-
/* Parse emulate_httpd_log line */
else if (!strcmp(token, "emulate_httpd_log"))
parseEmulateLine(line_in);
else if (!strcmp(token, "append_domain"))
parseAppendDomainLine(line_in);
-#if USE_WAIS_RELAY
else if (!strcmp(token, "wais_relay"))
parseWAISRelayLine(line_in);
-#endif
/* Parse a local_ip line */
else if (!strcmp(token, "local_ip"))
else if (!strcmp(token, "single_parent_bypass"))
parseSingleParentBypassLine(line_in);
+ else if (!strcmp(token, "debug_options"))
+ parseDebugOptionsLine(line_in);
+
/* If unknown, treat as a comment line */
else {
- /*EMPTY */ ;
+ /* EMPTY */ ;
}
}
}
-/*
- * Daemonize a process according to guidlines in "Advanced Programming
- * For The UNIX Environment", W.R. Stevens ( Addison Wesley, 1992) - Ch. 13
- */
-int daemonize()
-{
- int n_openf, i;
- pid_t pid;
-
-
- if ((pid = fork()) < 0)
- return (-1);
- else if (pid != 0)
- exit(0);
-
- /* Child continues */
- setsid(); /* Become session leader */
-
- n_openf = getMaxFD(); /* Close any inherited files */
- for (i = 0; i < n_openf; i++)
- close(i);
-
- umask(0); /* Clear file mode creation mask */
-
- return (0);
-}
-
-
-int check_suid()
-{
- struct passwd *pwd;
- struct group *grp;
-
- if (geteuid() == 0) {
- /* Started as a root, check suid option */
- if (Config.effectiveUser && (pwd = getpwnam(Config.effectiveUser))) {
-
- /* change current directory to swap space so we can get core */
- if (chdir(swappath(0))) {
- debug(1, "Chdir Failed: Cached cannot write core file when it crash: %s\n",
- xstrerror());
- }
- if (Config.effectiveGroup && (grp = getgrnam(Config.effectiveGroup))) {
- setgid(grp->gr_gid);
- } else {
- setgid(pwd->pw_gid);
- }
- setuid(pwd->pw_uid);
- }
- }
- return 0;
-}
int getHttpMax()
{
return Config.Gopher.defaultTtl;
}
-#if USE_WAIS_RELAY
int getWAISMax()
{
return Config.Wais.maxObjSize;
{
return Config.Wais.relayPort;
}
-#endif
int getFtpMax()
{
{
return Config.adminEmail;
}
-int getDebugLevel()
+char *getDebugOptions()
{
- return Config.debugLevel;
+ return Config.debugOptions;
}
int getStallDelay()
{
{
return Config.appendDomain;
}
+char *getEffectiveUser()
+{
+ return Config.effectiveUser;
+}
+char *getEffectiveGroup()
+{
+ return Config.effectiveGroup;
+}
int setAsciiPortNum(p)
int p;
{
Config.Gopher.maxObjSize = DefaultGopherMaxObjSize;
Config.Http.defaultTtl = DefaultHttpDefaultTtl;
Config.Http.maxObjSize = DefaultHttpMaxObjSize;
-#if USE_WAIS_RELAY
Config.Wais.defaultTtl = DefaultWaisDefaultTtl;
Config.Wais.maxObjSize = DefaultWaisMaxObjSize;
Config.Wais.relayHost = safe_xstrdup(DefaultWaisRelayHost);
Config.Wais.relayPort = DefaultWaisRelayPort;
-#endif
Config.negativeTtl = DefaultNegativeTtl;
Config.readTimeout = DefaultReadTimeout;
Config.sourcePing = DefaultSourcePing;
Config.quickAbort = DefaultQuickAbort;
Config.commonLogFormat = DefaultCommonLogFormat;
- Config.debugLevel = DefaultDebugLevel;
+ Config.debugOptions = safe_xstrdup(DefaultDebugOptions);
Config.neighborTimeout = DefaultNeighborTimeout;
Config.stallDelay = DefaultStallDelay;
Config.singleParentBypass = DefaultSingleParentBypass;
-/* $Id: comm.cc,v 1.8 1996/03/27 01:45:57 wessels Exp $ */
+/* $Id: comm.cc,v 1.9 1996/03/27 18:15:41 wessels Exp $ */
#include "squid.h"
void comm_handler()
{
/* Call application installed handler. */
- debug(5, "comm_handler:\n");
+ debug(0, 5, "comm_handler:\n");
app_handler();
}
/* If the fd is closed already, just return */
if (!fd_table[fd].openned) {
- debug(0, "comm_port: FD %d has been closed.\n", fd);
+ debug(0, 0, "comm_port: FD %d has been closed.\n", fd);
return (COMM_ERROR);
}
addr_len = sizeof(addr);
if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) {
- debug(1, "comm_port: Failed to retrieve TCP/UDP port number for socket: FD %d: %s\n", fd, xstrerror());
+ debug(0, 1, "comm_port: Failed to retrieve TCP/UDP port number for socket: FD %d: %s\n", fd, xstrerror());
return (COMM_ERROR);
}
- debug(6, "comm_port: FD %d: sockaddr %u.\n", fd, addr.sin_addr.s_addr);
+ debug(0, 6, "comm_port: FD %d: sockaddr %u.\n", fd, addr.sin_addr.s_addr);
fd_table[fd].port = ntohs(addr.sin_port);
return fd_table[fd].port;
addr = getAddress(host);
if (addr == (struct in_addr *) NULL) {
- debug(0, "do_bind: Unknown host: %s\n", host);
+ debug(0, 0, "do_bind: Unknown host: %s\n", host);
return COMM_ERROR;
}
memset(&S, '\0', sizeof(S));
if (bind(s, (struct sockaddr *) &S, sizeof(S)) == 0)
return COMM_OK;
- debug(0, "do_bind: Cannot bind socket FD %d to %s:%d: %s\n",
+ debug(0, 0, "do_bind: Cannot bind socket FD %d to %s:%d: %s\n",
s,
S.sin_addr.s_addr == htonl(INADDR_ANY) ? "*" : inet_ntoa(S.sin_addr),
port, xstrerror());
switch (errno) {
case ENFILE:
case EMFILE:
- debug(1, "comm_open: socket failure: %s\n", xstrerror());
+ debug(0, 1, "comm_open: socket failure: %s\n", xstrerror());
Reserve_More_FDs();
break;
default:
- debug(0, "comm_open: socket failure: %s\n", xstrerror());
+ debug(0, 0, "comm_open: socket failure: %s\n", xstrerror());
}
return (COMM_ERROR);
}
conn->openned = 1;
if (fcntl(new_socket, F_SETFD, 1) < 0) {
- debug(0, "comm_open: FD %d: failed to set close-on-exec flag: %s\n",
+ debug(0, 0, "comm_open: FD %d: failed to set close-on-exec flag: %s\n",
new_socket, xstrerror());
}
if (port > 0) {
if (commSetNoLinger(new_socket) < 0) {
- debug(0, "comm_open: failed to turn off SO_LINGER: %s\n",
+ debug(0, 0, "comm_open: failed to turn off SO_LINGER: %s\n",
xstrerror());
}
if (do_reuse) {
*/
#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
if (fcntl(new_socket, F_SETFL, O_NONBLOCK)) {
- debug(0, "comm_open: FD %d: Failure to set O_NONBLOCK: %s\n",
+ debug(0, 0, "comm_open: FD %d: Failure to set O_NONBLOCK: %s\n",
new_socket, xstrerror());
return (COMM_ERROR);
}
#else
if (fcntl(new_socket, F_SETFL, FNDELAY)) {
- debug(0, "comm_open: FD %d: Failure to set FNDELAY: %s\n",
+ debug(0, 0, "comm_open: FD %d: Failure to set FNDELAY: %s\n",
new_socket, xstrerror());
return (COMM_ERROR);
}
int x;
FD_SET(sock, &receive_sockets);
if ((x = listen(sock, 50)) < 0) {
- debug(0, "comm_listen: listen(%d, 50): %s\n",
+ debug(0, 0, "comm_listen: listen(%d, 50): %s\n",
sock, xstrerror());
return x;
}
to_addr.sin_family = AF_INET;
if ((hp = ipcache_gethostbyname(dest_host)) == 0) {
- debug(1, "comm_connect: Failure to lookup host: %s.\n", dest_host);
+ debug(0, 1, "comm_connect: Failure to lookup host: %s.\n", dest_host);
return (COMM_ERROR);
}
memcpy(&to_addr.sin_addr, hp->h_addr, hp->h_length);
/* sanity check */
if (ntohs(address->sin_port) == 0) {
- debug(10, "comm_connect_addr: %s:%d: URL uses port 0?\n",
+ debug(0, 10, "comm_connect_addr: %s:%d: URL uses port 0?\n",
inet_ntoa(address->sin_addr), ntohs(address->sin_port));
errno = 0;
return COMM_ERROR;
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &x, &len) >= 0)
errno = x;
default:
- debug(1, "comm_connect_addr: %s:%d: socket failure: %s.\n",
+ debug(0, 1, "comm_connect_addr: %s:%d: socket failure: %s.\n",
inet_ntoa(address->sin_addr),
ntohs(address->sin_port),
xstrerror());
/* set the lifetime for this client */
if (status == COMM_OK) {
lft = comm_set_fd_lifetime(sock, getClientLifetime());
- debug(10, "comm_connect_addr: FD %d (lifetime %d): connected to %s:%d.\n",
+ debug(0, 10, "comm_connect_addr: FD %d (lifetime %d): connected to %s:%d.\n",
sock, lft, inet_ntoa(address->sin_addr),
ntohs(address->sin_port));
} else if (status == EINPROGRESS) {
lft = comm_set_fd_lifetime(sock, getConnectTimeout());
- debug(10, "comm_connect_addr: FD %d connection pending, lifetime %d\n",
+ debug(0, 10, "comm_connect_addr: FD %d connection pending, lifetime %d\n",
sock, lft);
}
/* Add new socket to list of open sockets. */
Reserve_More_FDs();
return COMM_ERROR;
default:
- debug(1, "comm_accept: FD %d: accept failure: %s\n",
+ debug(0, 1, "comm_accept: FD %d: accept failure: %s\n",
fd, xstrerror());
return COMM_ERROR;
}
return -1;
if (fdstat_type(fd) == File) {
- debug(0, "FD %d: Someone called comm_close() on a File\n", fd);
+ debug(0, 0, "FD %d: Someone called comm_close() on a File\n", fd);
fatal_dump(NULL);
}
conn = &fd_table[fd];
FD_CLR(fd, &send_sockets);
comm_set_fd_lifetime(fd, -1); /* invalidate the lifetime */
- debug(10, "comm_close: FD %d\n", fd);
+ debug(0, 10, "comm_close: FD %d\n", fd);
/* update fdstat */
fdstat_close(fd);
memset(conn, '\0', sizeof(FD_ENTRY));
to_addr.sin_family = AF_INET;
if ((hp = ipcache_gethostbyname(host)) == 0) {
- debug(1, "comm_udp_send: gethostbyname failure: %s: %s\n",
+ debug(0, 1, "comm_udp_send: gethostbyname failure: %s: %s\n",
host, xstrerror());
return (COMM_ERROR);
}
to_addr.sin_port = htons(port);
if ((bytes_sent = sendto(fd, buf, len, 0, (struct sockaddr *) &to_addr,
sizeof(to_addr))) < 0) {
- debug(1, "comm_udp_send: sendto failure: FD %d: %s\n",
+ debug(0, 1, "comm_udp_send: sendto failure: FD %d: %s\n",
fd, xstrerror());
return COMM_ERROR;
}
int bytes_sent;
if ((bytes_sent = sendto(fd, buf, len, 0, (struct sockaddr *) to_addr, addr_len)) < 0) {
- debug(1, "comm_udp_sendto: sendto failure: FD %d: %s\n", fd, xstrerror());
- debug(1, "comm_udp_sendto: --> sin_family = %d\n", to_addr->sin_family);
- debug(1, "comm_udp_sendto: --> sin_port = %d\n", htons(to_addr->sin_port));
- debug(1, "comm_udp_sendto: --> sin_addr = %s\n", inet_ntoa(to_addr->sin_addr));
+ debug(0, 1, "comm_udp_sendto: sendto failure: FD %d: %s\n", fd, xstrerror());
+ debug(0, 1, "comm_udp_sendto: --> sin_family = %d\n", to_addr->sin_family);
+ debug(0, 1, "comm_udp_sendto: --> sin_port = %d\n", htons(to_addr->sin_port));
+ debug(0, 1, "comm_udp_sendto: --> sin_addr = %s\n", inet_ntoa(to_addr->sin_addr));
return COMM_ERROR;
}
return bytes_sent;
int len = recvfrom(fd, buf, size, 0, (struct sockaddr *) from_addr,
from_size);
if (len < 0) {
- debug(1, "comm_udp_recv: recvfrom failure: FD %d: %s\n", fd,
+ debug(0, 1, "comm_udp_recv: recvfrom failure: FD %d: %s\n", fd,
xstrerror());
return COMM_ERROR;
}
break;
if (errno != EINTR) {
- debug(0, "comm_select: select failure: %s (errno %d).\n",
+ debug(0, 0, "comm_select: select failure: %s (errno %d).\n",
xstrerror(), errno);
examine_select(&readfds, &writefds, &exceptfds);
return COMM_ERROR;
/* if select interrupted, try again */
}
- debug(num ? 5 : 8, "comm_select: %d sockets ready at %d\n",
+ debug(0, num ? 5 : 8, "comm_select: %d sockets ready at %d\n",
num, cached_curtime);
/* Check lifetime and timeout handlers ONCE each second.
continue;
if (FD_ISSET(fd, &readfds)) {
- debug(6, "comm_select: FD %d ready for reading\n", fd);
+ debug(0, 6, "comm_select: FD %d ready for reading\n", fd);
if (fd_table[fd].read_handler) {
int (*tmp) () = fd_table[fd].read_handler;
fd_table[fd].read_handler = 0;
- debug(10, "calling read handler %p(%d,%p)\n",
+ debug(0, 10, "calling read handler %p(%d,%p)\n",
tmp, fd, fd_table[fd].read_data);
tmp(fd, fd_table[fd].read_data);
}
}
if (FD_ISSET(fd, &writefds)) {
- debug(5, "comm_select: FD %d ready for writing\n", fd);
+ debug(0, 5, "comm_select: FD %d ready for writing\n", fd);
if (fd_table[fd].write_handler) {
int (*tmp) () = fd_table[fd].write_handler;
fd_table[fd].write_handler = 0;
- debug(10, "calling write handler %p(%d,%p)\n",
+ debug(0, 10, "calling write handler %p(%d,%p)\n",
tmp, fd, fd_table[fd].write_data);
tmp(fd, fd_table[fd].write_data);
}
}
if (FD_ISSET(fd, &exceptfds)) {
- debug(5, "comm_select: FD %d has an exception\n", fd);
+ debug(0, 5, "comm_select: FD %d has an exception\n", fd);
if (fd_table[fd].except_handler) {
int (*tmp) () = fd_table[fd].except_handler;
fd_table[fd].except_handler = 0;
- debug(10, "calling except handler %p(%d,%p)\n",
+ debug(0, 10, "calling except handler %p(%d,%p)\n",
tmp, fd, fd_table[fd].except_data);
tmp(fd, fd_table[fd].except_data);
}
}
}
- debug(8, "comm_select: time out: %d.\n", cached_curtime);
+ debug(0, 8, "comm_select: time out: %d.\n", cached_curtime);
return COMM_TIMEOUT;
}
case EINTR:
break; /* if select interrupted, try again */
default:
- debug(1, "comm_pending: select failure: %s\n", xstrerror());
+ debug(0, 1, "comm_pending: select failure: %s\n", xstrerror());
return COMM_ERROR;
}
}
- debug(5, "comm_pending: %d sockets ready for reading\n", num);
+ debug(0, 5, "comm_pending: %d sockets ready for reading\n", num);
if (num && FD_ISSET(fd, &readfds)) {
return COMM_OK;
fd_table[fd].timeout_handler = handler;
fd_table[fd].timeout_data = client_data;
if ((timeout <= 0) && handler) {
- debug(2, "comm_set_select_handler_plus_timeout: Zero timeout doesn't make sense\n");
+ debug(0, 2, "comm_set_select_handler_plus_timeout: Zero timeout doesn't make sense\n");
}
}
if (type & COMM_SELECT_READ) {
L.l_onoff = 0; /* off */
L.l_linger = 0;
- debug(10, "commSetNoLinger: turning off SO_LINGER on FD %d\n", fd);
+ debug(0, 10, "commSetNoLinger: turning off SO_LINGER on FD %d\n", fd);
return setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L));
}
int on = 1;
int rc;
- debug(10, "commSetReuseAddr: turning on SO_REUSEADDR on FD %d\n", fd);
+ debug(0, 10, "commSetReuseAddr: turning on SO_REUSEADDR on FD %d\n", fd);
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on));
if (rc < 0)
- debug(1, "commSetReuseAddr: FD=%d: %s\n", fd, xstrerror());
+ debug(0, 1, "commSetReuseAddr: FD=%d: %s\n", fd, xstrerror());
return rc;
}
int commSetNonBlocking(fd)
int fd;
{
- debug(10, "commSetNonBlocking: setting FD %d to non-blocking i/o.\n",
+ debug(0, 10, "commSetNonBlocking: setting FD %d to non-blocking i/o.\n",
fd);
/*
* Set up the flag NOT to have the socket to wait for message from
#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
if (fcntl(fd, F_SETFL, O_NONBLOCK)) {
- debug(0, "comm_open: FD %d: error setting O_NONBLOCK: %s\n",
+ debug(0, 0, "comm_open: FD %d: error setting O_NONBLOCK: %s\n",
fd, xstrerror());
return (COMM_ERROR);
}
#else
if (fcntl(fd, F_SETFL, FNDELAY)) {
- debug(0, "comm_open: FD %d: error setting FNDELAY: %s\n",
+ debug(0, 0, "comm_open: FD %d: error setting FNDELAY: %s\n",
fd, xstrerror());
return (COMM_ERROR);
}
return NULL;
if ((hp = ipcache_gethostbyname(name)))
return hp->h_addr_list;
- debug(0, "getAddress: gethostbyname failure: %s: %s\n",
+ debug(0, 0, "getAddress: gethostbyname failure: %s: %s\n",
name, xstrerror());
return NULL;
}
memcpy(&first.s_addr, *list, 4);
return (&first);
}
- debug(0, "getAddress: gethostbyname failure: %s: %s\n",
+ debug(0, 0, "getAddress: gethostbyname failure: %s: %s\n",
name, xstrerror());
return NULL;
}
int num;
struct timeval tv;
- debug(0, "examine_select: Examining open file descriptors...\n");
+ debug(0, 0, "examine_select: Examining open file descriptors...\n");
for (fd = 0; fd < getMaxFD(); ++fd) {
FD_ZERO(&read_x);
FD_ZERO(&write_x);
FD_SET(fd, &read_x);
num = select(FD_SETSIZE, &read_x, &read_x, &read_x, &tv);
if (num < 0) {
- debug(0, "WARNING: FD %d has handlers, but it's invalid.\n", fd);
- debug(0, "Timeout handler:%x read:%x write:%x except:%x\n",
+ debug(0, 0, "WARNING: FD %d has handlers, but it's invalid.\n", fd);
+ debug(0, 0, "Timeout handler:%x read:%x write:%x except:%x\n",
fd_table[fd].timeout_handler,
fd_table[fd].read_handler,
fd_table[fd].write_handler,
}
}
}
- debug(0, "examine_select: Finished examining open file descriptors.\n");
+ debug(0, 0, "examine_select: Finished examining open file descriptors.\n");
return 0;
}
if ((fd_table[fd].timeout_handler) &&
(fd_table[fd].timeout_time <= cached_curtime)) {
int (*tmp) () = fd_table[fd].timeout_handler;
- debug(5, "comm_select: timeout on socket %d at %d\n",
+ debug(0, 5, "comm_select: timeout on socket %d at %d\n",
fd, cached_curtime);
fd_table[fd].timeout_handler = 0;
tmp(fd, fd_table[fd].timeout_data);
}
if (tmp_local) {
if (use_lifetime_handler) {
- debug(2, "comm_select: FD %d lifetime expire: %d < %d (Lifetime handler %p)\n",
+ debug(0, 2, "comm_select: FD %d lifetime expire: %d < %d (Lifetime handler %p)\n",
fd, lft, cached_curtime, tmp_local);
} else {
- debug(2, "comm_select: FD %d lifetime expire: %d < %d (%s handler %p)\n",
+ debug(0, 2, "comm_select: FD %d lifetime expire: %d < %d (%s handler %p)\n",
fd, lft, cached_curtime,
use_read ? "read" : "write", tmp_local);
}
} else {
- debug(1, "comm_select: FD %d lifetime expire: %d < %d (handler not available.)\n",
+ debug(0, 1, "comm_select: FD %d lifetime expire: %d < %d (handler not available.)\n",
fd, lft, cached_curtime);
}
}
if (fd_table[fd].openned) {
/* hmm.. still openned. do full comm_close */
- debug(5, "comm_select: FD %d lifetime expire: %d < %d : Handler did not close the socket.\n comm_select will do.\n",
+ debug(0, 5, "comm_select: FD %d lifetime expire: %d < %d : Handler did not close the socket.\n comm_select will do.\n",
fd, lft, cached_curtime);
comm_close(fd);
} else {
/* seems like handle closed it.
* clean up fd_table just to make sure */
- debug(5, "comm_select: FD %d lifetime expire: %d : Handler closed the socket.\n",
+ debug(0, 5, "comm_select: FD %d lifetime expire: %d : Handler closed the socket.\n",
fd, lft);
/* just to make sure here */
comm_cleanup_fd_entry(fd);
}
} else {
/* no handle. do full comm_close */
- debug(5, "comm_select: FD %d lifetime expire: %d < %d : No handler to close the socket.\n comm_select will do.\n",
+ debug(0, 5, "comm_select: FD %d lifetime expire: %d < %d : No handler to close the socket.\n comm_select will do.\n",
fd, lft, cached_curtime);
comm_close(fd);
}
RESERVED_FD = RESERVED_FD + 1;
} else if (RESERVED_FD == getMaxFD() - 64) {
RESERVED_FD = RESERVED_FD + 1;
- debug(0, "Don't you have a tiny open-file table size of %d\n",
+ debug(0, 0, "Don't you have a tiny open-file table size of %d\n",
getMaxFD() - RESERVED_FD);
}
}
-/* $Id: debug.cc,v 1.4 1996/03/27 05:12:38 wessels Exp $ */
+/* $Id: debug.cc,v 1.5 1996/03/27 18:15:42 wessels Exp $ */
#include "squid.h"
-extern int getLogfileRotateNumber _PARAMS((void));
-
-static char *_db_modules = 0; /* colon separated list of modules to debug. */
-int _db_level = 0;
char *_db_file = __FILE__;
int _db_line = 0;
-extern char *mkrfc850();
-extern int unbuffered_logs; /* main.c */
-
int syslog_enable = 0;
int stderr_enable = 0;
FILE *debug_log = NULL;
static time_t last_cached_curtime = 0;
static char the_time[81];
+#define MAX_DEBUG_SECTIONS 50
+static int debugLevels[MAX_DEBUG_SECTIONS];
+
#if defined(__STRICT_ANSI__)
-void _db_print(int level,...)
+void _db_print(int section,...)
{
- char *format;
va_list args;
#else
void _db_print(va_alist)
va_dcl
{
- char *format;
- int level;
va_list args;
+ int section;
#endif
+ int level;
+ char *format = NULL;
static char f[BUFSIZ];
static char tmpbuf[BUFSIZ];
- char *module = NULL;
char *s = NULL;
if (debug_log == NULL)
return;
#if defined(__STRICT_ANSI__)
- /* strict ANSI compliance requires the second arg to va_start - we don't */
- va_start(args, level);
- format = va_arg(args, char *);
+ va_start(args, section);
#else
va_start(args);
+ section = va_arg(args, int);
+#endif
level = va_arg(args, int);
format = va_arg(args, char *);
-#endif
- /* Obtain module name from filename. */
- if ((module = strrchr(_db_file, '/')) != NULL)
- module++;
- else
- module = _db_file;
-
- if (_db_level >= level) {
- if (!_db_modules || strstr(_db_modules, module)) {
- /* don't compute the curtime too much */
- if (last_cached_curtime != cached_curtime) {
- last_cached_curtime = cached_curtime;
- the_time[0] = '\0';
- s = mkhttpdlogtime(&cached_curtime);
- strcpy(the_time, s);
- }
- sprintf(f, "[%s] %s:%d:\t %s", the_time, module, _db_line, format);
+ if (debugLevels[section] > level) {
+ va_end(args);
+ return;
+ }
+ /* don't compute the curtime too much */
+ if (last_cached_curtime != cached_curtime) {
+ last_cached_curtime = cached_curtime;
+ the_time[0] = '\0';
+ s = mkhttpdlogtime(&cached_curtime);
+ strcpy(the_time, s);
+ }
+ sprintf(f, "[%s] %s:%d:\t %s",
+ the_time,
+ _db_file,
+ _db_line,
+ format);
#if HAVE_SYSLOG
- /* level 0 go to syslog */
- if ((level == 0) && syslog_enable) {
- tmpbuf[0] = '\0';
- vsprintf(tmpbuf, f, args);
- syslog(LOG_ERR, tmpbuf);
- }
+ /* level 0 go to syslog */
+ if ((level == 0) && syslog_enable) {
+ tmpbuf[0] = '\0';
+ vsprintf(tmpbuf, f, args);
+ syslog(LOG_ERR, tmpbuf);
+ }
#endif /* HAVE_SYSLOG */
- /* write to log file */
- vfprintf(debug_log, f, args);
- if (unbuffered_logs)
- fflush(debug_log);
-
- /* if requested, dump it to stderr also */
- if (stderr_enable) {
- vfprintf(stderr, f, args);
- fflush(stderr);
- }
- }
+ /* write to log file */
+ vfprintf(debug_log, f, args);
+ if (unbuffered_logs)
+ fflush(debug_log);
+
+ /* if requested, dump it to stderr also */
+ if (stderr_enable) {
+ vfprintf(stderr, f, args);
+ fflush(stderr);
}
va_end(args);
}
-void _db_init(prefix, initial_level, logfile)
+static void debugArg(arg)
+ char *arg;
+{
+ int s = 0;
+ int l = 0;
+ int i;
+
+ if (!strncasecmp(arg, "ALL", 3)) {
+ s = -1;
+ arg += 4;
+ } else {
+ s = atoi(arg);
+ while (*arg && *arg++ != ',');
+ }
+ l = atoi (arg);
+
+ if (s >= 0) {
+ debugLevels[s] = l;
+ return;
+ }
+ for (i = 0; i < MAX_DEBUG_SECTIONS; i++)
+ debugLevels[i] = l;
+}
+
+void _db_init(prefix, logfile)
char *prefix;
- int initial_level;
char *logfile;
{
- char *db_level_str, db_buf[MAXPATHLEN];
+ int i;
+ char *p = NULL;
+ char *s = NULL;
- sprintf(db_buf, "%s_debug_level", prefix);
- if ((db_level_str = getenv(db_buf)) != NULL)
- _db_level = atoi(db_level_str);
- else
- _db_level = initial_level;
+ for (i = 0; i < MAX_DEBUG_SECTIONS; i++)
+ debugLevels[i] = -1;
- _db_modules = getenv("DHT_DEBUG_MODULES");
+ if ((p = getDebugOptions())) {
+ p = xstrdup(p);
+ for (s=strtok(p, w_space); s; s=strtok(NULL, w_space)) {
+ debugArg(s);
+ }
+ xfree(p);
+ }
/* open error logging file */
if (logfile != NULL) {
fprintf(stderr, " messages will be sent to 'stderr'.\n");
fflush(stderr);
debug_log = stderr;
- /* avoid reduntancy */
stderr_enable = 0;
}
-/* $Id: disk.cc,v 1.4 1996/03/27 01:45:59 wessels Exp $ */
+/* $Id: disk.cc,v 1.5 1996/03/27 18:15:43 wessels Exp $ */
#include "squid.h"
/* Open file */
if ((fd = open(path, mode | O_NDELAY, 0644)) < 0) {
- debug(0, "file_open: error opening file %s: %s\n",
+ debug(0, 0, "file_open: error opening file %s: %s\n",
path, xstrerror());
return (DISK_ERROR);
}
/* set non-blocking mode */
#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) && !defined(_SQUID_SOLARIS_)
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
- debug(0, "file_open: FD %d: Failure to set O_NONBLOCK: %s\n",
+ debug(0, 0, "file_open: FD %d: Failure to set O_NONBLOCK: %s\n",
fd, xstrerror());
return DISK_ERROR;
}
#else
if (fcntl(fd, F_SETFL, FNDELAY) < 0) {
- debug(0, "file_open: FD %d: Failure to set FNDELAY: %s\n",
+ debug(0, 0, "file_open: FD %d: Failure to set FNDELAY: %s\n",
fd, xstrerror());
return DISK_ERROR;
}
file_table[fd].filename[0] = '\0';
if (fdstat_type(fd) == Socket) {
- debug(0, "FD %d: Someone called file_close() on a socket\n", fd);
+ debug(0, 0, "FD %d: Someone called file_close() on a socket\n", fd);
fatal_dump(NULL);
}
/* update fdstat */
int fd;
{
if (file_table[fd].write_lock == LOCK) {
- debug(0, "trying to lock a locked file\n");
+ debug(0, 0, "trying to lock a locked file\n");
return DISK_WRT_LOCK_FAIL;
} else {
file_table[fd].write_lock = LOCK;
file_table[fd].write_lock = UNLOCK;
return DISK_OK;
} else {
- debug(0, "trying to unlock the file with the wrong access code\n");
+ debug(0, 0, "trying to unlock the file with the wrong access code\n");
return DISK_WRT_WRONG_CODE;
}
}
return DISK_OK;
default:
/* disk i/o failure--flushing all outstanding writes */
- debug(1, "diskHandleWrite: disk write error %s\n",
+ debug(0, 1, "diskHandleWrite: disk write error %s\n",
xstrerror());
entry->write_daemon = NOT_PRESENT;
entry->write_pending = NO_WRT_PENDING;
}
if ((file_table[fd].write_lock == LOCK) &&
(file_table[fd].access_code != access_code)) {
- debug(0, "file write: access code checked failed. Sync problem.\n");
+ debug(0, 0, "file write: access code checked failed. Sync problem.\n");
return DISK_WRT_WRONG_CODE;
}
/* if we got here. Caller is eligible to write. */
case EWOULDBLOCK:
break;
default:
- debug(1, "diskHandleRead: FD %d: error reading: %s\n",
+ debug(0, 1, "diskHandleRead: FD %d: error reading: %s\n",
fd, xstrerror());
ctrl_dat->handler(fd, ctrl_dat->buf,
ctrl_dat->cur_len, DISK_ERROR,
case EWOULDBLOCK:
break;
default:
- debug(1, "diskHandleWalk: FD %d: error readingd: %s\n",
+ debug(0, 1, "diskHandleWalk: FD %d: error readingd: %s\n",
fd, xstrerror());
walk_dat->handler(fd, DISK_ERROR, walk_dat->client_data);
safe_free(walk_dat->buf);
-/* $Id: filemap.cc,v 1.5 1996/03/27 01:46:03 wessels Exp $ */
+/* $Id: filemap.cc,v 1.6 1996/03/27 18:15:44 wessels Exp $ */
#include "squid.h"
fm->max_n_files = n;
fm->nwords = n >> LONG_BIT_SHIFT;
- debug(1, "file_map_create: creating space for %d files\n", n);
- debug(5, "--> %d words of %d bytes each\n",
+ debug(0, 1, "file_map_create: creating space for %d files\n", n);
+ debug(0, 5, "--> %d words of %d bytes each\n",
fm->nwords, sizeof(unsigned long));
fm->file_map = (unsigned long *) xcalloc(fm->nwords, sizeof(unsigned long));
return (fm);
#ifdef XTRA_DEBUG
if (fm->file_map[file_number >> LONG_BIT_SHIFT] & bitmask)
- debug(0, "file_map_bit_set: WARNING: file number %d is already set!\n",
+ debug(0, 0, "file_map_bit_set: WARNING: file number %d is already set!\n",
file_number);
#endif
fm->n_files_in_map++;
if (!fm->toggle && (fm->n_files_in_map > ((fm->max_n_files * 7) >> 3))) {
fm->toggle++;
- debug(0, "You should increment MAX_SWAP_FILE\n");
+ debug(0, 0, "You should increment MAX_SWAP_FILE\n");
} else if (fm->n_files_in_map > (fm->max_n_files - 100)) {
- debug(0, "You've run out of swap file numbers. Freeing 1MB\n");
+ debug(0, 0, "You've run out of swap file numbers. Freeing 1MB\n");
storeGetSwapSpace(1000000);
}
return (file_number);
}
}
- debug(0, "file_map_allocate: All %d files are in use!\n", fm->max_n_files);
- debug(0, "You need to recompile with a larger value for MAX_SWAP_FILE\n");
+ debug(0, 0, "file_map_allocate: All %d files are in use!\n", fm->max_n_files);
+ debug(0, 0, "You need to recompile with a larger value for MAX_SWAP_FILE\n");
fatal_dump(NULL);
return (0); /* NOTREACHED */
}
-/* $Id: ftp.cc,v 1.12 1996/03/27 01:46:04 wessels Exp $ */
+/* $Id: ftp.cc,v 1.13 1996/03/27 18:15:45 wessels Exp $ */
#include "squid.h"
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "ftpLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
+ debug(0, 4, "ftpLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
if (data->icp_page_ptr) {
put_free_8k_page(data->icp_page_ptr);
data->icp_page_ptr = NULL;
clen = entry->mem_obj->e_current_len;
off = entry->mem_obj->e_lowest_offset;
if ((clen - off) > FTP_DELETE_GAP) {
- debug(3, "ftpReadReply: Read deferred for Object: %s\n", entry->key);
- debug(3, "--> Current Gap: %d bytes\n", clen - off);
+ debug(0, 3, "ftpReadReply: Read deferred for Object: %s\n", entry->key);
+ debug(0, 3, "--> Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will automatically be reactivated when
* Gap is big enough. */
comm_set_select_handler(fd,
}
errno = 0;
len = read(fd, buf, READBUFSIZ);
- debug(5, "ftpReadReply: FD %d, Read %d bytes\n", fd, len);
+ debug(0, 5, "ftpReadReply: FD %d, Read %d bytes\n", fd, len);
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
if (len < 0)
- debug(1, "ftpReadReply: read error: %s\n", xstrerror());
+ debug(0, 1, "ftpReadReply: read error: %s\n", xstrerror());
cached_error_entry(entry, ERR_READ_ERROR, NULL);
comm_close(fd);
safe_free(data);
if (!data->got_marker) {
/* If we didn't see the magic marker, assume the transfer failed and arrange
* so the object gets ejected and never gets to disk. */
- debug(1, "ftpReadReply: Didn't see magic marker, purging <URL:%s>.\n", entry->url);
+ debug(0, 1, "ftpReadReply: Didn't see magic marker, purging <URL:%s>.\n", entry->url);
entry->expires = cached_curtime + getNegativeTTL();
BIT_RESET(entry->flag, CACHABLE);
BIT_SET(entry->flag, RELEASE_REQUEST);
StoreEntry *entry = NULL;
entry = data->entry;
- debug(5, "ftpSendComplete: FD %d: size %d: errflag %d.\n",
+ debug(0, 5, "ftpSendComplete: FD %d: size %d: errflag %d.\n",
fd, size, errflag);
if (buf) {
static char tbuf[BUFSIZ];
static char opts[BUFSIZ];
static char *space = " ";
- static char *w_space = " \t\r\n";
char *s = NULL;
int got_timeout = 0;
int got_negttl = 0;
int buflen;
- debug(5, "ftpSendRequest: FD %d\n", fd);
+ debug(0, 5, "ftpSendRequest: FD %d\n", fd);
buflen = strlen(data->request) + 256;
buf = (char *) get_free_8k_page();
strcat(buf, space);
strcat(buf, data->password);
strcat(buf, space);
- debug(5, "ftpSendRequest: FD %d: buf '%s'\n", fd, buf);
+ debug(0, 5, "ftpSendRequest: FD %d: buf '%s'\n", fd, buf);
data->icp_rwd_ptr = icpWrite(fd, buf, strlen(buf), 30, ftpSendComplete, (caddr_t) data);
}
{
StoreEntry *entry = data->entry;
- debug(5, "ftpConnInProgress: FD %d\n", fd);
+ debug(0, 5, "ftpConnInProgress: FD %d\n", fd);
if (comm_connect(fd, "localhost", 3131) != COMM_OK)
switch (errno) {
(caddr_t) data);
return;
case EISCONN:
- debug(5, "ftpConnInProgress: FD %d is now connected.", fd);
+ debug(0, 5, "ftpConnInProgress: FD %d is now connected.", fd);
break; /* cool, we're connected */
default:
comm_close(fd);
FtpData *data = NULL;
int status;
- debug(3, "FtpStart: FD %d <URL:%s>\n", unusedfd, url);
+ debug(0, 3, "FtpStart: FD %d <URL:%s>\n", unusedfd, url);
data = (FtpData *) xcalloc(1, sizeof(FtpData));
data->entry = entry;
safe_free(data);
return COMM_ERROR;
}
- debug(5, "FtpStart: FD %d, host=%s, request=%s, user=%s, passwd=%s\n",
+ debug(0, 5, "FtpStart: FD %d, host=%s, request=%s, user=%s, passwd=%s\n",
unusedfd, data->host, data->request, data->user, data->password);
data->ftp_fd = comm_open(COMM_NONBLOCKING, 0, 0, url);
safe_free(data);
return COMM_ERROR;
} else {
- debug(5, "ftpStart: FD %d: EINPROGRESS.\n", data->ftp_fd);
+ debug(0, 5, "ftpStart: FD %d: EINPROGRESS.\n", data->ftp_fd);
comm_set_select_handler(data->ftp_fd, COMM_SELECT_LIFETIME,
(PF) ftpLifetimeExpire, (caddr_t) data);
comm_set_select_handler(data->ftp_fd, COMM_SELECT_WRITE,
char *ftpget = getFtpProgram();
if (pipe(p) < 0) {
- debug(0, "ftpInitialize: pipe: %s\n", xstrerror());
+ debug(0, 0, "ftpInitialize: pipe: %s\n", xstrerror());
return -1;
}
if ((pid = fork()) < 0) {
- debug(0, "ftpInitialize: fork: %s\n", xstrerror());
+ debug(0, 0, "ftpInitialize: fork: %s\n", xstrerror());
return -1;
}
if (pid != 0) { /* parent */
(void) close(fd);
sprintf(pbuf, "%d", 3131);
execlp(ftpget, ftpget, "-D26,1", "-S", pbuf, NULL);
- debug(0, "ftpInitialize: %s: %s\n", ftpget, xstrerror());
+ debug(0, 0, "ftpInitialize: %s: %s\n", ftpget, xstrerror());
_exit(1);
return (1); /* eliminate compiler warning */
}
-/* $Id: gopher.cc,v 1.8 1996/03/27 01:46:06 wessels Exp $ */
+/* $Id: gopher.cc,v 1.9 1996/03/27 18:15:45 wessels Exp $ */
#include "squid.h"
/* there is no complete line in inbuf */
/* copy it to temp buffer */
if (data->len + len > TEMP_BUF_SIZE) {
- debug(1, "GopherHTML: Buffer overflow. Lost some data on URL: %s\n",
+ debug(0, 1, "GopherHTML: Buffer overflow. Lost some data on URL: %s\n",
entry->url);
len = TEMP_BUF_SIZE - data->len;
}
/* there is no complete line in inbuf */
/* copy it to temp buffer */
if ((len - (pos - inbuf)) > TEMP_BUF_SIZE) {
- debug(1, "GopherHTML: Buffer overflow. Lost some data on URL: %s\n",
+ debug(0, 1, "GopherHTML: Buffer overflow. Lost some data on URL: %s\n",
entry->url);
len = TEMP_BUF_SIZE;
}
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "GopherReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
+ debug(0, 4, "GopherReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
cached_error_entry(entry, ERR_READ_TIMEOUT, NULL);
if (data->icp_page_ptr)
put_free_4k_page(data->icp_page_ptr);
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "gopherLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
+ debug(0, 4, "gopherLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
cached_error_entry(entry, ERR_LIFETIME_EXP, NULL);
if (data->icp_page_ptr)
put_free_4k_page(data->icp_page_ptr);
clen = entry->mem_obj->e_current_len;
off = entry->mem_obj->e_lowest_offset;
if ((clen - off) > GOPHER_DELETE_GAP) {
- debug(3, "gopherReadReply: Read deferred for Object: %s\n",
+ debug(0, 3, "gopherReadReply: Read deferred for Object: %s\n",
entry->key);
- debug(3, " Current Gap: %d bytes\n",
+ debug(0, 3, " Current Gap: %d bytes\n",
clen - off);
/* reschedule, so it will automatically reactivated when
}
buf = get_free_4k_page();
len = read(fd, buf, TEMP_BUF_SIZE - 1); /* leave one space for \0 in gopherToHTML */
- debug(5, "gopherReadReply - fd: %d read len:%d\n", fd, len);
+ debug(0, 5, "gopherReadReply - fd: %d read len:%d\n", fd, len);
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
- debug(1, "gopherReadReply - error reading: %s\n",
+ debug(0, 1, "gopherReadReply - error reading: %s\n",
xstrerror());
cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
comm_close(fd);
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(5, "gopherSendComplete - fd: %d size: %d errflag: %d\n",
+ debug(0, 5, "gopherSendComplete - fd: %d size: %d errflag: %d\n",
fd, size, errflag);
if (errflag) {
cached_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
sprintf(buf, "%s%c%c", data->request, CR, LF);
}
- debug(5, "gopherSendRequest - fd: %d\n", fd);
+ debug(0, 5, "gopherSendRequest - fd: %d\n", fd);
data->icp_rwd_ptr = icpWrite(fd,
buf,
len,
data->entry = entry;
- debug(3, "gopherStart - url: %s\n", url);
+ debug(0, 3, "gopherStart - url: %s\n", url);
/* Parse url. */
if (gopher_url_parser(url, data->host, &data->port,
/* Create socket. */
sock = comm_open(COMM_NONBLOCKING, 0, 0, url);
if (sock == COMM_ERROR) {
- debug(4, "gopherStart: Failed because we're out of sockets.\n");
+ debug(0, 4, "gopherStart: Failed because we're out of sockets.\n");
cached_error_entry(entry, ERR_NO_FDS, xstrerror());
freeGopherData(data);
return COMM_ERROR;
* It should be done before this route is called.
* Otherwise, we cannot check return code for connect. */
if (!ipcache_gethostbyname(data->host)) {
- debug(4, "gopherStart: Called without IP entry in ipcache. OR lookup failed.\n");
+ debug(0, 4, "gopherStart: Called without IP entry in ipcache. OR lookup failed.\n");
comm_close(sock);
cached_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
freeGopherData(data);
freeGopherData(data);
return COMM_ERROR;
} else {
- debug(5, "startGopher - conn %d EINPROGRESS\n", sock);
+ debug(0, 5, "startGopher - conn %d EINPROGRESS\n", sock);
}
}
/* Install connection complete handler. */
-/* $Id: http.cc,v 1.10 1996/03/27 01:46:08 wessels Exp $ */
+/* $Id: http.cc,v 1.11 1996/03/27 18:15:46 wessels Exp $ */
#include "squid.h"
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "httpReadReplyTimeout: FD %d: <URL:%s>\n", fd, entry->url);
+ debug(0, 4, "httpReadReplyTimeout: FD %d: <URL:%s>\n", fd, entry->url);
cached_error_entry(entry, ERR_READ_TIMEOUT, NULL);
if (data->icp_rwd_ptr)
safe_free(data->icp_rwd_ptr);
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "httpLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
+ debug(0, 4, "httpLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
cached_error_entry(entry, ERR_LIFETIME_EXP, NULL);
if (data->icp_page_ptr) {
clen = entry->mem_obj->e_current_len;
off = entry->mem_obj->e_lowest_offset;
if ((clen - off) > HTTP_DELETE_GAP) {
- debug(3, "httpReadReply: Read deferred for Object: %s\n", entry->key);
- debug(3, " Current Gap: %d bytes\n", clen - off);
+ debug(0, 3, "httpReadReply: Read deferred for Object: %s\n", entry->key);
+ debug(0, 3, " Current Gap: %d bytes\n", clen - off);
/* reschedule, so it will be automatically reactivated
* when Gap is big enough. */
comm_set_select_handler(fd,
}
errno = 0;
len = read(fd, buf, READBUFSIZ);
- debug(5, "httpReadReply: FD %d: len %d.\n", fd, len);
+ debug(0, 5, "httpReadReply: FD %d: len %d.\n", fd, len);
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
/* XXX we we should log when len==0 and current_len==0 */
- debug(2, "httpReadReply: FD %d: read failure: %s.\n",
+ debug(0, 2, "httpReadReply: FD %d: read failure: %s.\n",
fd, xstrerror());
if (errno == ECONNRESET) {
/* Connection reset by peer */
StoreEntry *entry = NULL;
entry = data->entry;
- debug(5, "httpSendComplete: FD %d: size %d: errflag %d.\n",
+ debug(0, 5, "httpSendComplete: FD %d: size %d: errflag %d.\n",
fd, size, errflag);
if (buf) {
int len = 0;
int buflen;
- debug(5, "httpSendRequest: FD %d: data %p.\n", fd, data);
+ debug(0, 5, "httpSendRequest: FD %d: data %p.\n", fd, data);
buflen = strlen(data->type) + strlen(data->request);
if (data->mime_hdr)
buflen += strlen(data->mime_hdr);
buf = (char *) get_free_8k_page();
data->icp_page_ptr = buf;
if (buflen > DISK_PAGE_SIZE) {
- debug(0, "Mime header length %d is breaking ICP code\n", buflen);
+ debug(0, 0, "Mime header length %d is breaking ICP code\n", buflen);
}
memset(buf, '\0', buflen);
len += strlen(post_buf);
xfree(post_buf);
}
- debug(6, "httpSendRequest: FD %d: buf '%s'\n", fd, buf);
+ debug(0, 6, "httpSendRequest: FD %d: buf '%s'\n", fd, buf);
data->icp_rwd_ptr = icpWrite(fd, buf, len, 30, httpSendComplete, (caddr_t) data);
}
int sock, status;
HttpData *data = (HttpData *) xmalloc(sizeof(HttpData));
- debug(3, "proxyhttpStart: <URL:%s>\n", url);
- debug(10, "proxyhttpStart: HTTP request header:\n%s\n",
+ debug(0, 3, "proxyhttpStart: <URL:%s>\n", url);
+ debug(0, 10, "proxyhttpStart: HTTP request header:\n%s\n",
entry->mem_obj->mime_hdr);
memset(data, '\0', sizeof(HttpData));
/* Create socket. */
sock = comm_open(COMM_NONBLOCKING, 0, 0, url);
if (sock == COMM_ERROR) {
- debug(4, "proxyhttpStart: Failed because we're out of sockets.\n");
+ debug(0, 4, "proxyhttpStart: Failed because we're out of sockets.\n");
cached_error_entry(entry, ERR_NO_FDS, xstrerror());
safe_free(data);
return COMM_ERROR;
* It should be done before this route is called.
* Otherwise, we cannot check return code for connect. */
if (!ipcache_gethostbyname(data->host)) {
- debug(4, "proxyhttpstart: Called without IP entry in ipcache. OR lookup failed.\n");
+ debug(0, 4, "proxyhttpstart: Called without IP entry in ipcache. OR lookup failed.\n");
comm_close(sock);
cached_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
safe_free(data);
e->neighbor_up = 0;
return COMM_ERROR;
} else {
- debug(5, "proxyhttpStart: FD %d: EINPROGRESS.\n", sock);
+ debug(0, 5, "proxyhttpStart: FD %d: EINPROGRESS.\n", sock);
comm_set_select_handler(sock, COMM_SELECT_LIFETIME,
(PF) httpLifetimeExpire, (caddr_t) data);
comm_set_select_handler(sock, COMM_SELECT_WRITE,
int sock, status;
HttpData *data = (HttpData *) xmalloc(sizeof(HttpData));
- debug(3, "httpStart: %s <URL:%s>\n", type, url);
- debug(10, "httpStart: mime_hdr '%s'\n", mime_hdr);
+ debug(0, 3, "httpStart: %s <URL:%s>\n", type, url);
+ debug(0, 10, "httpStart: mime_hdr '%s'\n", mime_hdr);
memset(data, '\0', sizeof(HttpData));
data->entry = entry;
/* Create socket. */
sock = comm_open(COMM_NONBLOCKING, 0, 0, url);
if (sock == COMM_ERROR) {
- debug(4, "httpStart: Failed because we're out of sockets.\n");
+ debug(0, 4, "httpStart: Failed because we're out of sockets.\n");
cached_error_entry(entry, ERR_NO_FDS, xstrerror());
safe_free(data);
return COMM_ERROR;
* It should be done before this route is called.
* Otherwise, we cannot check return code for connect. */
if (!ipcache_gethostbyname(data->host)) {
- debug(4, "httpstart: Called without IP entry in ipcache. OR lookup failed.\n");
+ debug(0, 4, "httpstart: Called without IP entry in ipcache. OR lookup failed.\n");
comm_close(sock);
cached_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
safe_free(data);
safe_free(data);
return COMM_ERROR;
} else {
- debug(5, "httpStart: FD %d: EINPROGRESS.\n", sock);
+ debug(0, 5, "httpStart: FD %d: EINPROGRESS.\n", sock);
comm_set_select_handler(sock, COMM_SELECT_LIFETIME,
(PF) httpLifetimeExpire, (caddr_t) data);
comm_set_select_handler(sock, COMM_SELECT_WRITE,
-/* $Id: ipcache.cc,v 1.8 1996/03/27 01:46:11 wessels Exp $ */
+/* $Id: ipcache.cc,v 1.9 1996/03/27 18:15:48 wessels Exp $ */
#include "squid.h"
"yale.edu"
};
-static char w_space[] = " \t\n";
static dnsserver_entry **dns_child_table = NULL;
static int last_dns_dispatched = 2;
static struct hostent *static_result = NULL;
int fd;
if ((cfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- debug(0, "ipcache_create_dnsserver: socket: %s\n", xstrerror());
+ debug(0, 0, "ipcache_create_dnsserver: socket: %s\n", xstrerror());
return -1;
}
fdstat_open(cfd, Socket);
addr.sun_family = AF_UNIX;
sprintf(socketname, "dns/dns%d.%d", (int) getpid(), n_dnsserver++);
strcpy(addr.sun_path, socketname);
- debug(4, "ipcache_create_dnsserver: path is %s\n", addr.sun_path);
+ debug(0, 4, "ipcache_create_dnsserver: path is %s\n", addr.sun_path);
if (bind(cfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
close(cfd);
- debug(0, "ipcache_create_dnsserver: bind: %s\n", xstrerror());
+ debug(0, 0, "ipcache_create_dnsserver: bind: %s\n", xstrerror());
return -1;
}
- debug(4, "ipcache_create_dnsserver: bind to local host.\n");
+ debug(0, 4, "ipcache_create_dnsserver: bind to local host.\n");
listen(cfd, 1);
if ((pid = fork()) < 0) {
- debug(0, "ipcache_create_dnsserver: fork: %s\n", xstrerror());
+ debug(0, 0, "ipcache_create_dnsserver: fork: %s\n", xstrerror());
close(cfd);
return -1;
}
/* open new socket for parent process */
if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- debug(0, "ipcache_create_dnsserver: socket: %s\n", xstrerror());
+ debug(0, 0, "ipcache_create_dnsserver: socket: %s\n", xstrerror());
return -1;
}
fcntl(sfd, F_SETFD, 1); /* set close-on-exec */
strcpy(addr.sun_path, socketname);
if (connect(sfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
close(sfd);
- debug(0, "ipcache_create_dnsserver: connect: %s\n", xstrerror());
+ debug(0, 0, "ipcache_create_dnsserver: connect: %s\n", xstrerror());
return -1;
}
- debug(4, "ipcache_create_dnsserver: FD %d connected to %s #%d.\n",
+ debug(0, 4, "ipcache_create_dnsserver: FD %d connected to %s #%d.\n",
sfd, command, n_dnsserver);
return sfd;
}
ipcache_entry *result = 0;
int i;
- debug(5, "ipcache_release: ipcache_count before: %d \n", meta_data.ipcache_count);
+ debug(0, 5, "ipcache_release: ipcache_count before: %d \n", meta_data.ipcache_count);
if (e != NULL && ip_table) { /* sometimes called with NULL e */
hash_link *table_entry = hash_lookup(ip_table, e->name);
if (table_entry) {
result = (ipcache_entry *) table_entry;
- debug(5, "HASH table count before delete: %d\n", ipcache_hash_entry_count());
+ debug(0, 5, "HASH table count before delete: %d\n", ipcache_hash_entry_count());
if (hash_remove_link(ip_table, table_entry)) {
- debug(3, "ipcache_release: Cannot delete '%s' from hash table %d\n", e->name, ip_table);
+ debug(0, 3, "ipcache_release: Cannot delete '%s' from hash table %d\n", e->name, ip_table);
}
- debug(5, "HASH table count after delete: %d\n", ipcache_hash_entry_count());
+ debug(0, 5, "HASH table count after delete: %d\n", ipcache_hash_entry_count());
if (result) {
if (result->status == PENDING) {
- debug(1, "ipcache_release: Try to release entry with PENDING status. ignored.\n");
- debug(5, "ipcache_release: ipcache_count: %d \n", meta_data.ipcache_count);
+ debug(0, 1, "ipcache_release: Try to release entry with PENDING status. ignored.\n");
+ debug(0, 5, "ipcache_release: ipcache_count: %d \n", meta_data.ipcache_count);
return -1;
}
if (result->status == CACHED) {
if (result->entry.h_aliases)
safe_free(result->entry.h_aliases);
safe_free(result->entry.h_name);
- debug(5, "ipcache_release: Released IP cached record for '%s'.\n", e->name);
+ debug(0, 5, "ipcache_release: Released IP cached record for '%s'.\n", e->name);
}
/* XXX: we're having mem mgmt problems; zero, then free */
safe_free(result->name);
safe_free(result);
}
--meta_data.ipcache_count;
- debug(5, "ipcache_release: ipcache_count when return: %d \n", meta_data.ipcache_count);
+ debug(0, 5, "ipcache_release: ipcache_count when return: %d \n", meta_data.ipcache_count);
return meta_data.ipcache_count;
}
}
- debug(3, "ipcache_release: can't delete entry\n");
+ debug(0, 3, "ipcache_release: can't delete entry\n");
return -1; /* can't delete entry */
}
if (LRU_list_count >= LRU_cur_size) {
/* have to realloc */
LRU_cur_size += 16;
- debug(3, "ipcache_purgelru: Have to grow LRU_list to %d. This shouldn't happen.\n",
+ debug(0, 3, "ipcache_purgelru: Have to grow LRU_list to %d. This shouldn't happen.\n",
LRU_cur_size);
LRU_list = (ipcache_entry **) xrealloc((char *) LRU_list,
LRU_cur_size * sizeof(ipcache_entry *));
}
}
- debug(3, "ipcache_purgelru: ipcache_count: %5d\n", meta_data.ipcache_count);
- debug(3, " actual count : %5d\n", local_ip_count);
- debug(3, " high W mark : %5d\n", ipcache_high);
- debug(3, " low W mark : %5d\n", ipcache_low);
- debug(3, " not pending : %5d\n", local_ip_notpending_count);
- debug(3, " LRU candidated : %5d\n", LRU_list_count);
+ debug(0, 3, "ipcache_purgelru: ipcache_count: %5d\n", meta_data.ipcache_count);
+ debug(0, 3, " actual count : %5d\n", local_ip_count);
+ debug(0, 3, " high W mark : %5d\n", ipcache_high);
+ debug(0, 3, " low W mark : %5d\n", ipcache_low);
+ debug(0, 3, " not pending : %5d\n", local_ip_notpending_count);
+ debug(0, 3, " LRU candidated : %5d\n", LRU_list_count);
/* sort LRU candidate list */
qsort((char *) LRU_list, LRU_list_count, sizeof(e), (int (*)(const void *, const void *)) ipcache_compareLastRef);
removed++;
}
- debug(3, " removed : %5d\n", removed);
+ debug(0, 3, " removed : %5d\n", removed);
safe_free(LRU_list);
return (removed > 0) ? 0 : -1;
}
{
static ipcache_entry *ipe;
static ipcache_entry *new;
- debug(5, "ipcache_create: when enter. ipcache_count == %d\n", meta_data.ipcache_count);
+ debug(0, 5, "ipcache_create: when enter. ipcache_count == %d\n", meta_data.ipcache_count);
if (meta_data.ipcache_count > ipcache_high) {
if (ipcache_purgelru() < 0) {
- debug(1, "ipcache_create: Cannot release needed IP entry via LRU: %d > %d, removing first entry...\n", meta_data.ipcache_count, MAX_IP);
+ debug(0, 1, "ipcache_create: Cannot release needed IP entry via LRU: %d > %d, removing first entry...\n", meta_data.ipcache_count, MAX_IP);
ipe = ipcache_GetFirst();
if (!ipe) {
- debug(1, "ipcache_create: First entry is a null pointer ???\n");
+ debug(0, 1, "ipcache_create: First entry is a null pointer ???\n");
/* have to let it grow beyond limit here */
} else if (ipe && ipe->status != PENDING) {
ipcache_release(ipe);
} else {
- debug(1, "ipcache_create: First entry is also PENDING entry.\n");
+ debug(0, 1, "ipcache_create: First entry is also PENDING entry.\n");
/* have to let it grow beyond limit here */
}
}
}
meta_data.ipcache_count++;
- debug(5, "ipcache_create: before return. ipcache_count == %d\n", meta_data.ipcache_count);
+ debug(0, 5, "ipcache_create: before return. ipcache_count == %d\n", meta_data.ipcache_count);
new = (ipcache_entry *) xcalloc(1, sizeof(ipcache_entry));
/* set default to 4, in case parser fail to get token $h_length from
* dnsserver. */
if (!ipcache_initialized)
ipcache_init();
if (hash_join(ip_table, (hash_link *) e)) {
- debug(1, "ipcache_add_to_hash: Cannot add %s (%p) to hash table %d.\n",
+ debug(0, 1, "ipcache_add_to_hash: Cannot add %s (%p) to hash table %d.\n",
e->name, e, ip_table);
}
- debug(5, "ipcache_add_to_hash: name <%s>\n", e->name);
- debug(5, " ipcache_count: %d\n", meta_data.ipcache_count);
+ debug(0, 5, "ipcache_add_to_hash: name <%s>\n", e->name);
+ debug(0, 5, " ipcache_count: %d\n", meta_data.ipcache_count);
}
{
int addr_count, alias_count, i;
- debug(10, "ipcache_add: Adding name '%s' (%s).\n", name,
+ debug(0, 10, "ipcache_add: Adding name '%s' (%s).\n", name,
cached ? "cached" : "not cached");
e->name = xstrdup(name);
{
int addr_count, alias_count, i;
- debug(10, "ipcache_update: Updating name '%s' (%s).\n", name,
+ debug(0, 10, "ipcache_update: Updating name '%s' (%s).\n", name,
cached ? "cached" : "not cached");
if (cached) {
safe_free(p);
}
entry->pending_head = entry->pending_tail = NULL; /* nuke list */
- debug(10, "ipcache_call_pending: Called %d handlers.\n", nhandler);
+ debug(0, 10, "ipcache_call_pending: Called %d handlers.\n", nhandler);
}
void ipcache_call_pending_badname(fd, handler, data)
IPH handler;
caddr_t data;
{
- debug(4, "ipcache_call_pending_badname: Bad Name: Calling handler with NULL result.\n");
+ debug(0, 4, "ipcache_call_pending_badname: Bad Name: Calling handler with NULL result.\n");
handler(fd, NULL, data);
}
}
if (q == NULL) { /* 'p' is not in the list? */
- debug(1, "globalpending_remove: Failure while deleting entry from global pending list.\n");
+ debug(0, 1, "globalpending_remove: Failure while deleting entry from global pending list.\n");
return;
}
/* nuke p from the list; do this carefully... */
/* no complete record here */
if ((endpos = strstr(pos, "$end\n")) == NULL) {
- debug(2, "ipcache_parsebuffer: DNS response incomplete.\n");
+ debug(0, 2, "ipcache_parsebuffer: DNS response incomplete.\n");
break;
}
line_head = line_tail = NULL;
line_cur = (line_entry *) xcalloc(1, sizeof(line_entry));
if ((tpos = memchr(pos, '\n', 4096)) == NULL) {
- debug(2, "ipcache_parsebuffer: DNS response incomplete.\n");
+ debug(0, 2, "ipcache_parsebuffer: DNS response incomplete.\n");
return -1;
}
*tpos = '\0';
line_cur->line = xstrdup(pos);
- debug(7, "ipcache_parsebuffer: %s\n", line_cur->line);
+ debug(0, 7, "ipcache_parsebuffer: %s\n", line_cur->line);
*tpos = '\n';
if (line_tail)
if (strstr(line_head->line, "$alive")) {
data->answer = cached_curtime;
free_lines(line_head);
- debug(10, "ipcache_parsebuffer: $alive succeeded.\n");
+ debug(0, 10, "ipcache_parsebuffer: $alive succeeded.\n");
} else if (strstr(line_head->line, "$fail")) {
/*
* The $fail messages look like:
strcpy(dns_error_message, line_cur->line + 8);
}
if (token == NULL) {
- debug(1, "ipcache_parsebuffer: Invalid $fail for DNS table?\n");
+ debug(0, 1, "ipcache_parsebuffer: Invalid $fail for DNS table?\n");
} else {
plist = globalpending_search(token, data->global_pending);
if (plist) {
plist->entry->status = NEGATIVE_CACHED;
ipcache_call_pending(plist->entry);
globalpending_remove(plist, data);
- debug(10, "ipcache_parsebuffer: $fail succeeded: %s.\n",
+ debug(0, 10, "ipcache_parsebuffer: $fail succeeded: %s.\n",
dns_error_message[0] ? dns_error_message : "why?");
} else {
- debug(1, "ipcache_parsebuffer: No entry in DNS table?\n");
+ debug(0, 1, "ipcache_parsebuffer: No entry in DNS table?\n");
}
}
free_lines(line_head);
tmp_ptr = NULL;
token = strtok(tmp_ptr, w_space);
if (!token) {
- debug(1, "ipcache_parsebuffer: Invalid OPCODE for DNS table?\n");
+ debug(0, 1, "ipcache_parsebuffer: Invalid OPCODE for DNS table?\n");
} else {
plist = globalpending_search(token, data->global_pending);
if (plist) {
ipcache_entry *e = plist->entry;
if (e->status != PENDING) {
- debug(4, "ipcache_parsebuffer: DNS record already resolved.\n");
+ debug(0, 4, "ipcache_parsebuffer: DNS record already resolved.\n");
} else {
e->lastref = e->timestamp = cached_curtime;
e->ttl = IP_POS_TTL;
/* get $h_name */
if (line_cur == NULL ||
!strstr(line_cur->line, "$h_name")) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $h_name.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $h_name.\n");
/* abandon this record */
break;
}
/* get $h_length */
if (line_cur == NULL ||
!strstr(line_cur->line, "$h_len")) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $h_len.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $h_len.\n");
/* abandon this record */
break;
}
/* get $ipcount */
if (line_cur == NULL ||
!strstr(line_cur->line, "$ipcount")) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $ipcount.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $ipcount.\n");
/* abandon this record */
break;
}
line_cur = line_cur->next;
while (i < ipcount) {
if (line_cur == NULL) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $ipcount data.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $ipcount data.\n");
break;
}
e->entry.h_addr_list[i] = (char *) xcalloc(1, e->entry.h_length);
/* get $aliascount */
if (line_cur == NULL ||
!strstr(line_cur->line, "$aliascount")) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $aliascount.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $aliascount.\n");
/* abandon this record */
break;
}
line_cur = line_cur->next;
while (i < aliascount) {
if (line_cur == NULL) {
- debug(1, "ipcache_parsebuffer: DNS record in invalid format? No $aliascount data.\n");
+ debug(0, 1, "ipcache_parsebuffer: DNS record in invalid format? No $aliascount data.\n");
break;
}
e->entry.h_aliases[i] = xstrdup(line_cur->line);
ipcache_call_pending(e);
globalpending_remove(plist, data);
- debug(10, "ipcache_parsebuffer: $name succeeded.\n");
+ debug(0, 10, "ipcache_parsebuffer: $name succeeded.\n");
}
} else {
- debug(1, "ipcache_parsebuffer: No entries in DNS $name record?\n");
+ debug(0, 1, "ipcache_parsebuffer: No entries in DNS $name record?\n");
}
}
free_lines(line_head);
} else {
free_lines(line_head);
- debug(1, "ipcache_parsebuffer: Invalid OPCODE for DNS table?\n");
+ debug(0, 1, "ipcache_parsebuffer: Invalid OPCODE for DNS table?\n");
return -1;
}
}
int char_scanned;
int len = read(fd, data->ip_inbuf + data->offset, data->size - data->offset);
- debug(5, "ipcache_dnsHandleRead: Result from DNS ID %d.\n", data->id);
+ debug(0, 5, "ipcache_dnsHandleRead: Result from DNS ID %d.\n", data->id);
if (len == 0) {
- debug(1, "ipcache_dnsHandleRead: Connection from DNSSERVER is closed.\n");
- debug(1, " Disabling this server ID %d.\n", data->id);
+ debug(0, 1, "ipcache_dnsHandleRead: Connection from DNSSERVER is closed.\n");
+ debug(0, 1, " Disabling this server ID %d.\n", data->id);
data->alive = 0;
update_dns_child_alive();
ipcache_cleanup_pendinglist(data);
IpPending *pending;
dnsserver_entry *dns;
- debug(4, "ipcache_nbgethostbyname: FD %d: Name '%s'.\n", fd, name);
+ debug(0, 4, "ipcache_nbgethostbyname: FD %d: Name '%s'.\n", fd, name);
if (name == NULL || name[0] == '\0') {
- debug(4, "ipcache_nbgethostbyname: Invalid name!\n");
+ debug(0, 4, "ipcache_nbgethostbyname: Invalid name!\n");
ipcache_call_pending_badname(fd, handler, data);
return 0;
}
if ((e = ipcache_get(name)) != NULL && (e->status != PENDING)) {
/* hit here */
- debug(4, "ipcache_nbgethostbyname: Hit for name '%s'.\n", name);
+ debug(0, 4, "ipcache_nbgethostbyname: Hit for name '%s'.\n", name);
pending = (IpPending *) xcalloc(1, sizeof(IpPending));
pending->fd = fd;
pending->handler = handler;
ipcache_call_pending(e);
return 0;
}
- debug(4, "ipcache_nbgethostbyname: Name '%s': MISS or PENDING.\n", name);
+ debug(0, 4, "ipcache_nbgethostbyname: Name '%s': MISS or PENDING.\n", name);
pending = (IpPending *) xcalloc(1, sizeof(IpPending));
pending->fd = fd;
pending->next = NULL;
if (e == NULL) {
/* No entry, create the new one */
- debug(5, "ipcache_nbgethostbyname: Creating new entry for '%s'...\n",
+ debug(0, 5, "ipcache_nbgethostbyname: Creating new entry for '%s'...\n",
name);
e = ipcache_create();
e->name = xstrdup(name);
ipcache_add_to_hash(e);
} else {
/* There is an entry. Add handler to list */
- debug(5, "ipcache_nbgethostbyname: Adding handler to pending list for '%s'.\n", name);
+ debug(0, 5, "ipcache_nbgethostbyname: Adding handler to pending list for '%s'.\n", name);
if (e->pending_head == NULL) { /* empty list */
e->pending_head = e->pending_tail = pending;
} else { /* add to tail of list */
}
dns = dns_child_table[last_dns_dispatched];
- debug(5, "ipcache_nbgethostbyname: Dispatched DNS %d.\n",
+ debug(0, 5, "ipcache_nbgethostbyname: Dispatched DNS %d.\n",
last_dns_dispatched);
/* add to global pending list */
0, /* Handler */
0); /* Handler-data */
- debug(5, "ipcache_nbgethostbyname: Request sent DNS server ID %d.\n", last_dns_dispatched);
+ debug(0, 5, "ipcache_nbgethostbyname: Request sent DNS server ID %d.\n", last_dns_dispatched);
} else {
/* do a blocking mode */
- debug(4, "ipcache_nbgethostbyname: Fall back to blocking mode. Server's dead...\n");
+ debug(0, 4, "ipcache_nbgethostbyname: Fall back to blocking mode. Server's dead...\n");
ipcache_cleanup_pendinglist(dns);
}
return 0;
int i, dnssocket;
char fd_note_buf[FD_ASCII_NOTE_SZ];
- debug(3, "ipcache_init: Called. ipcache_initialized=%d getDnsChildren()=%d\n", ipcache_initialized, getDnsChildren());
+ debug(0, 3, "ipcache_init: Called. ipcache_initialized=%d getDnsChildren()=%d\n", ipcache_initialized, getDnsChildren());
if (ipcache_initialized)
return;
if (mkdir("dns", 0755) < 0 && errno != EEXIST) {
- debug(0, "ipcache_init: mkdir %s\n", xstrerror());
+ debug(0, 0, "ipcache_init: mkdir %s\n", xstrerror());
}
last_dns_dispatched = getDnsChildren() - 1;
dns_error_message = xcalloc(1, 256);
/* test naming lookup */
if (!do_dns_test) {
- debug(4, "ipcache_init: Skipping DNS name lookup tests, -D flag given.\n");
+ debug(0, 4, "ipcache_init: Skipping DNS name lookup tests, -D flag given.\n");
} else if (ipcache_testname() < 0) {
- debug(0, "ipcache_init: DNS name lookup appears to be broken on this machine.\n");
+ debug(0, 0, "ipcache_init: DNS name lookup appears to be broken on this machine.\n");
fprintf(stderr, "ipcache_init: DNS name lookup appears to be broken on this machine.\n");
exit(-1);
} else {
- debug(4, "ipcache_init: Successful DNS name lookup tests...\n");
+ debug(0, 4, "ipcache_init: Successful DNS name lookup tests...\n");
}
ip_table = hash_create(urlcmp, 229); /* small hash table */
/* start up companion process */
dns_child_table = (dnsserver_entry **) xcalloc(getDnsChildren(), sizeof(dnsserver_entry));
dns_child_alive = 0;
- debug(1, "ipcache_init: Starting %d 'dns_server' processes\n",
+ debug(0, 1, "ipcache_init: Starting %d 'dns_server' processes\n",
getDnsChildren());
for (i = 0; i < getDnsChildren(); i++) {
dns_child_table[i] = (dnsserver_entry *) xcalloc(1, sizeof(dnsserver_entry));
if ((dnssocket = ipcache_create_dnsserver(getDnsProgram())) < 0) {
- debug(1, "ipcache_init: WARNING: Cannot run 'dnsserver' process.\n");
- debug(1, " Fallling back to the blocking version.\n");
+ debug(0, 1, "ipcache_init: WARNING: Cannot run 'dnsserver' process.\n");
+ debug(0, 1, " Fallling back to the blocking version.\n");
dns_child_table[i]->alive = 0;
} else {
dns_child_alive = 1;
dns_child_table[i]->id);
file_update_open(dns_child_table[i]->inpipe, fd_note_buf);
- debug(5, "Calling fd_note() with FD %d and buf '%s'\n",
+ debug(0, 5, "Calling fd_note() with FD %d and buf '%s'\n",
dns_child_table[i]->inpipe, fd_note_buf);
fd_note(dns_child_table[i]->inpipe, fd_note_buf);
COMM_SELECT_READ,
(PF) ipcache_dnsHandleRead,
(caddr_t) dns_child_table[i]);
- debug(3, "ipcache_init: 'dns_server' %d started\n", i);
+ debug(0, 3, "ipcache_init: 'dns_server' %d started\n", i);
}
}
ipcache_high = (long) (((float) MAX_IP *
if (p == NULL) {
/* Can not find this ipcache_entry, weird */
- debug(1, "ipcache_unregister: Failed to unregister FD %d from name: %s, can't find this FD.\n",
+ debug(0, 1, "ipcache_unregister: Failed to unregister FD %d from name: %s, can't find this FD.\n",
fd, name);
return 0;
}
ipcache_init();
if (!name) {
- debug(5, "ipcache_gethostbyname: Invalid argument?\n");
+ debug(0, 5, "ipcache_gethostbyname: Invalid argument?\n");
return (NULL);
}
if (!(result = ipcache_get(name))) {
/* cache miss */
if (name) {
- debug(5, "ipcache_gethostbyname: IPcache miss for '%s'.\n", name);
+ debug(0, 5, "ipcache_gethostbyname: IPcache miss for '%s'.\n", name);
}
/* check if it's already a IP address in text form. */
if (sscanf(name, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) == 4) {
if (s_result && s_result->h_name && (s_result->h_name[0] != '\0')) {
/* good address, cached */
- debug(10, "ipcache_gethostbyname: DNS success: cache for '%s'.\n", name);
+ debug(0, 10, "ipcache_gethostbyname: DNS success: cache for '%s'.\n", name);
ipcache_add(name, ipcache_create(), s_result, 1);
result = ipcache_get(name);
return &(result->entry);
} else {
/* bad address, negative cached */
- debug(3, "ipcache_gethostbyname: DNS failure: negative cache for '%s'.\n", name);
+ debug(0, 3, "ipcache_gethostbyname: DNS failure: negative cache for '%s'.\n", name);
ipcache_add(name, ipcache_create(), s_result, 0);
return NULL;
}
}
/* cache hit */
- debug(5, "ipcache_gethostbyname: Hit for '%s'.\n", name ? name : "NULL");
+ debug(0, 5, "ipcache_gethostbyname: Hit for '%s'.\n", name ? name : "NULL");
result->lastref = cached_curtime;
return (result->status == CACHED) ? &(result->entry) : NULL;
}
case NEGATIVE_CACHED:
return ('N');
default:
- debug(1, "ipcache_status_char: unexpected IP cache status.\n");
+ debug(0, 1, "ipcache_status_char: unexpected IP cache status.\n");
}
return ('X');
}
-/* $Id: main.cc,v 1.9 1996/03/27 04:42:08 wessels Exp $ */
+/* $Id: main.cc,v 1.10 1996/03/27 18:15:49 wessels Exp $ */
#include "squid.h"
int theBinaryConnection = -1;
int theUdpConnection = -1;
int do_reuse = 1;
-int debug_level = 0;
int catch_signals = 1;
int do_dns_test = 1;
char *config_file = NULL;
static int binaryPortNumOverride = 0;
static int udpPortNumOverride = 0;
-void raise_debug_lvl(), reset_debug_lvl();
-void sig_child();
-
int main(argc, argv)
int argc;
char **argv;
{
int c;
int malloc_debug_level = 0;
- int debug_level_overwrite = 0;
extern char *optarg;
int errcount = 0;
static int neighbors = 0;
case 'u':
udpPortNumOverride = atoi(optarg);
break;
- case 'd':
- stderr_enable = 1;
- debug_level_overwrite = 1;
- debug_level = atoi(optarg);
- unbuffered_logs = 1;
- break;
case 'm':
malloc_debug_level = atoi(optarg);
break;
case 'h':
default:
printf("\
-Usage: cached [-Rsehvz] [-f config-file] [-d debug-level] [-[apu] port]\n\
+Usage: cached [-Rsehvz] [-f config-file] [-[apu] port]\n\
-e Print messages to stderr.\n\
-h Print help message.\n\
-s Disable syslog output.\n\
-R Do not set REUSEADDR on port.\n\
-f file Use given config-file instead of\n\
$HARVEST_HOME/lib/cached.conf.\n\
- -d level Use given debug-level, prints messages to stderr.\n\
-a port Specify ASCII port number (default: %d).\n\
-u port Specify UDP port number (default: %d).\n",
CACHE_HTTP_PORT, CACHE_ICP_PORT);
if (udpPortNumOverride > 0)
setUdpPortNum(udpPortNumOverride);
- if (!debug_level_overwrite) {
- debug_level = getDebugLevel();
- }
- /* to toggle debugging */
-#ifdef SIGUSR1
- signal(SIGUSR1, raise_debug_lvl);
-#endif
-#ifdef SIGUSR2
- signal(SIGUSR2, reset_debug_lvl);
-#endif
-
-#ifdef NO_LOGGING
- _db_init("cached", 0, getCacheLogFile());
-#else
- _db_init("cached", debug_level, getCacheLogFile());
-#endif
+ _db_init("cached", getCacheLogFile());
fdstat_open(fileno(debug_log), LOG);
fd_note(fileno(debug_log), getCacheLogFile());
- debug(0, "Starting Harvest Cache (version %s)...\n", SQUID_VERSION);
+ debug(0, 0, "Starting Harvest Cache (version %s)...\n", SQUID_VERSION);
/* init ipcache */
ipcache_init();
#if defined(MALLOC_DBG)
- malloc_debug(malloc_debug_level);
+ malloc_debug(0, malloc_debug_level);
#endif
theAsciiConnection = comm_open(COMM_NONBLOCKING,
COMM_SELECT_READ,
asciiHandleConn,
0);
- debug(1, "Accepting HTTP (ASCII) connections on FD %d.\n",
+ debug(0, 1, "Accepting HTTP (ASCII) connections on FD %d.\n",
theAsciiConnection);
if (!httpd_accel_mode || getAccelWithProxy()) {
COMM_SELECT_READ,
icpHandleTcp,
0);
- debug(1, "Binary connection opened on fd %d\n", theBinaryConnection);
+ debug(0, 1, "Binary connection opened on fd %d\n", theBinaryConnection);
#endif
if (getUdpPortNum() > -1) {
theUdpConnection = comm_open(COMM_NONBLOCKING | COMM_DGRAM,
COMM_SELECT_READ,
icpHandleUdp,
0);
- debug(1, "Accepting ICP (UDP) connections on FD %d.\n",
+ debug(0, 1, "Accepting ICP (UDP) connections on FD %d.\n",
theUdpConnection);
}
}
/* after this point we want to see the mallinfo() output */
do_mallinfo = 1;
- debug(0, "Ready to serve requests.\n");
+ debug(0, 0, "Ready to serve requests.\n");
/* main loop */
if (getCleanRate() > 0)
break;
case COMM_ERROR:
errcount++;
- debug(0, "Select loop Error. Retry. %d\n", errcount);
+ debug(0, 0, "Select loop Error. Retry. %d\n", errcount);
if (errcount == 10)
fatal_dump("Select Loop failed.!\n");
break;
* when next_cleaning has arrived */
/* garbage collection */
if (getCleanRate() > 0 && cached_curtime >= next_cleaning) {
- debug(1, "Performing a garbage collection...\n");
+ debug(0, 1, "Performing a garbage collection...\n");
n = storePurgeOld();
- debug(1, "Garbage collection done, %d objects removed\n", n);
+ debug(0, 1, "Garbage collection done, %d objects removed\n", n);
next_cleaning = cached_curtime + getCleanRate();
}
/* house keeping */
break;
default:
- debug(0, "MAIN: Internal error -- this should never happen.\n");
+ debug(0, 0, "MAIN: Internal error -- this should never happen.\n");
break;
}
}
/* NOTREACHED */
exit(0);
}
-
-void raise_debug_lvl()
-{
- extern int _db_level;
- _db_level = 10;
-
-#if defined(_SQUID_SYSV_SIGNALS_) && defined(SIGUSR1)
- signal(SIGUSR1, raise_debug_lvl);
-#endif
-}
-
-void reset_debug_lvl()
-{
- extern int _db_level;
- _db_level = debug_level;
-
-#if defined(_SQUID_SYSV_SIGNALS_) && defined(SIGUSR2)
- signal(SIGUSR2, reset_debug_lvl);
-#endif
-}
-/* $Id: neighbors.cc,v 1.4 1996/03/27 01:46:14 wessels Exp $ */
+/* $Id: neighbors.cc,v 1.5 1996/03/27 18:15:50 wessels Exp $ */
#include "squid.h"
port = ntohs(from->sin_port);
ip = from->sin_addr;
- debug(3, "whichEdge: from %s port %d\n", inet_ntoa(ip), port);
+ debug(0, 3, "whichEdge: from %s port %d\n", inet_ntoa(ip), port);
for (e = friends->edges_head; e; e = e->next) {
for (j = 0; j < e->n_addresses; j++) {
{
edge *e;
- debug(1, "Adding a %s: %s\n", type, host);
+ debug(0, 1, "Adding a %s: %s\n", type, host);
e = (edge *) xcalloc(1, sizeof(edge));
if (getsockname(fd, (struct sockaddr *) &our_socket_name,
&sock_name_length) == -1) {
- debug(1, "getsockname(%d,%p,%p) failed.\n",
+ debug(0, 1, "getsockname(%d,%p,%p) failed.\n",
fd, &our_socket_name, &sock_name_length);
}
friends->fd = fd;
if ((fname = getHierarchyLogFile())) {
log_fd = file_open(fname, NULL, O_WRONLY | O_CREAT | O_APPEND);
if (log_fd < 0) {
- debug(1, "%s: %s\n", fname, xstrerror());
- debug(1, "Hierachical logging is disabled.\n");
+ debug(0, 1, "%s: %s\n", fname, xstrerror());
+ debug(0, 1, "Hierachical logging is disabled.\n");
} else if (!(cache_hierarchy_log = fdopen(log_fd, "a"))) {
- debug(1, "%s: %s\n", fname, xstrerror());
- debug(1, "Hierachical logging is disabled.\n");
+ debug(0, 1, "%s: %s\n", fname, xstrerror());
+ debug(0, 1, "Hierachical logging is disabled.\n");
}
}
/* Prepare neighbor connections, one at a time */
for (e = friends->edges_head; e; e = e->next) {
- debug(2, "Finding IP addresses for '%s'\n", e->host);
+ debug(0, 2, "Finding IP addresses for '%s'\n", e->host);
if ((list = getAddressList(e->host)) == NULL) {
sprintf(tmp_error_buf, "DNS lookup for '%s' failed! Cannot continue.\n",
e->host);
fatal(tmp_error_buf);
}
for (j = 0; j < e->n_addresses; j++) {
- debug(2, "--> IP address #%d: %s\n", j, inet_ntoa(e->addresses[j]));
+ debug(0, 2, "--> IP address #%d: %s\n", j, inet_ntoa(e->addresses[j]));
}
e->rtt = 1000;
ap->sin_port = htons(e->udp_port);
if (e->type == is_a_parent) {
- debug(3, "parent_install: host %s addr %s port %d\n",
+ debug(0, 3, "parent_install: host %s addr %s port %d\n",
e->host, inet_ntoa(ap->sin_addr),
e->udp_port);
e->neighbor_up = 1;
} else {
- debug(3, "neighbor_install: host %s addr %s port %d\n",
+ debug(0, 3, "neighbor_install: host %s addr %s port %d\n",
e->host, inet_ntoa(ap->sin_addr),
e->udp_port);
e->neighbor_up = 1;
for (i = 0, e = friends->first_ping; i++ < friends->n; e = e->next) {
if (e == (edge *) NULL)
e = friends->edges_head;
- debug(5, "neighborsUdpPing: Edge %s\n", e->host);
+ debug(0, 5, "neighborsUdpPing: Edge %s\n", e->host);
/* Don't resolve refreshes through neighbors because we don't resolve
* misses through neighbors */
if (!edgeWouldBePinged(e, host))
continue; /* next edge */
- debug(4, "neighborsUdpPing: pinging cache %s for <URL:%s>\n",
+ debug(0, 4, "neighborsUdpPing: pinging cache %s for <URL:%s>\n",
e->host, url);
e->header.reqnum++;
if (e->udp_port == echo_port) {
- debug(4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n");
+ debug(0, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n");
icpUdpSend(friends->fd, url, &echo_hdr, &e->in_addr, ICP_OP_DECHO);
} else {
icpUdpSend(friends->fd, url, &e->header, &e->in_addr, ICP_OP_QUERY);
/* do this to prevent wrap around but we still want it
* to move a bit so we can debug it easier. */
e->ack_deficit = HIER_MAX_DEFICIT + 1;
- debug(6, "cache %s is considered dead but send PING anyway, hope it comes up soon.\n",
+ debug(0, 6, "cache %s is considered dead but send PING anyway, hope it comes up soon.\n",
inet_ntoa(e->in_addr.sin_addr));
/* log it once at the threshold */
if ((e->ack_deficit == HIER_MAX_DEFICIT)) {
/* only do source_ping if we have neighbors */
if (echo_hdr.opcode) {
if (proto->source_ping && (hep = ipcache_gethostbyname(host))) {
- debug(6, "neighborsUdpPing: Send to original host\n");
- debug(6, "neighborsUdpPing: url=%s, host=%s, t=%d\n",
+ debug(0, 6, "neighborsUdpPing: Send to original host\n");
+ debug(0, 6, "neighborsUdpPing: url=%s, host=%s, t=%d\n",
url, host, t);
to_addr.sin_family = AF_INET;
memcpy(&to_addr.sin_addr, hep->h_addr, hep->h_length);
to_addr.sin_port = echo_port;
echo_hdr.reqnum = cached_curtime;
- debug(6, "neighborsUdpPing - url: %s to url-host %s \n",
+ debug(0, 6, "neighborsUdpPing - url: %s to url-host %s \n",
url, inet_ntoa(to_addr.sin_addr));
/* send to original site */
icpUdpSend(friends->fd, url, &echo_hdr, &to_addr, ICP_OP_SECHO);
} else {
- debug(6, "neighborsUdpPing: Source Ping is disabled.\n");
+ debug(0, 6, "neighborsUdpPing: Source Ping is disabled.\n");
}
}
return (entry->mem_obj->e_pings_n_pings);
{
edge *e = NULL;
- debug(6, "neighborsUdpAck: url=%s (%d chars), header=0x%x, from=0x%x, ent=0x%x\n",
+ debug(0, 6, "neighborsUdpAck: url=%s (%d chars), header=0x%x, from=0x%x, ent=0x%x\n",
url, strlen(url), header, from, entry);
- debug(6, " hdr: opcode=%d, ver=%d, shostid=%x, len=%d, rn=0x%x\n",
+ debug(0, 6, " hdr: opcode=%d, ver=%d, shostid=%x, len=%d, rn=0x%x\n",
header->opcode, header->version, header->shostid,
header->length, header->reqnum);
- debug(6, " from: fam=%d, port=%d, addr=0x%x\n",
+ debug(0, 6, " from: fam=%d, port=%d, addr=0x%x\n",
from->sin_family, from->sin_port, from->sin_addr.s_addr);
/* look up for neighbor/parent entry */
/* check if someone is already fetching it */
if (BIT_TEST(entry->flag, REQ_DISPATCHED) || (entry->ping_status != WAITING)) {
if (entry->ping_status == DONE) {
- debug(5, "There is already a cache/source dispatched for this object\n");
- debug(5, "--> <URL:%s>\n", entry->url);
- debug(5, "--> entry->flag & REQ_DISPATCHED = %d\n",
+ debug(0, 5, "There is already a cache/source dispatched for this object\n");
+ debug(0, 5, "--> <URL:%s>\n", entry->url);
+ debug(0, 5, "--> entry->flag & REQ_DISPATCHED = %d\n",
BIT_TEST(entry->flag, REQ_DISPATCHED));
- debug(5, "--> entry->ping_status = %d\n", entry->ping_status);
+ debug(0, 5, "--> entry->ping_status = %d\n", entry->ping_status);
} else {
- debug(5, "The ping already timed out.\n");
- debug(5, "--> <URL:%s>\n", entry->url);
- debug(5, "--> entry->flag & REQ_DISPATCHED = %lx\n",
+ debug(0, 5, "The ping already timed out.\n");
+ debug(0, 5, "--> <URL:%s>\n", entry->url);
+ debug(0, 5, "--> entry->flag & REQ_DISPATCHED = %lx\n",
BIT_TEST(entry->flag, REQ_DISPATCHED));
- debug(5, "--> entry->ping_status = %d\n", entry->ping_status);
+ debug(0, 5, "--> entry->ping_status = %d\n", entry->ping_status);
}
return;
}
- debug(6, "neighborsUdpAck - url: %s to us %s \n",
+ debug(0, 6, "neighborsUdpAck - url: %s to us %s \n",
url, e ? inet_ntoa(e->in_addr.sin_addr) : "url-host");
if (header->opcode == ICP_OP_SECHO) {
/* receive ping back from source or from non-cached cache */
if (e) {
- debug(6, "Got SECHO from non-cached cache:%s\n",
+ debug(0, 6, "Got SECHO from non-cached cache:%s\n",
inet_ntoa(e->in_addr.sin_addr));
- debug(6, "This is not supposed to happen. Ignored.\n");
+ debug(0, 6, "This is not supposed to happen. Ignored.\n");
} else {
/* if we reach here, source is the one has the fastest respond. */
/* fetch directly from source */
- debug(6, "Source is the first to respond.\n");
+ debug(0, 6, "Source is the first to respond.\n");
hierarchy_log_append(entry->url,
HIER_SOURCE_FASTEST,
0,
return;
}
/* GOT a HIT here */
- debug(6, "HIT: Getting %s from host: %s\n", entry->url, e->host);
+ debug(0, 6, "HIT: Getting %s from host: %s\n", entry->url, e->host);
if (e->type == is_a_neighbor) {
hierarchy_log_append(entry->url, HIER_NEIGHBOR_HIT, 0, e->host);
} else {
/* receive ping back from non-cached cache */
if (e) {
- debug(6, "Got DECHO from non-cached cache:%s\n",
+ debug(0, 6, "Got DECHO from non-cached cache:%s\n",
inet_ntoa(e->in_addr.sin_addr));
- debug(6, "Good.");
+ debug(0, 6, "Good.");
if (e->type == is_a_parent) {
if (entry->mem_obj->e_pings_first_miss == NULL) {
- debug(6, "OK. We got dumb-cached parent as the first miss here.\n");
+ debug(0, 6, "OK. We got dumb-cached parent as the first miss here.\n");
entry->mem_obj->e_pings_first_miss = e;
}
} else {
- debug(6, "Dumb Cached as a neighbor does not make sense.\n");
- debug(6, "Count it anyway.\n");
+ debug(0, 6, "Dumb Cached as a neighbor does not make sense.\n");
+ debug(0, 6, "Count it anyway.\n");
}
} else {
- debug(6, "Got DECHO from non-cached cache: But the host is not in the list.\n");
- debug(6, "Count it anyway.\n");
+ debug(0, 6, "Got DECHO from non-cached cache: But the host is not in the list.\n");
+ debug(0, 6, "Count it anyway.\n");
}
} else {
if (entry->mem_obj->e_pings_n_acks == entry->mem_obj->e_pings_n_pings) {
BIT_SET(entry->flag, REQ_DISPATCHED);
entry->ping_status = DONE;
- debug(6, "Receive MISSes from all neighbors and parents\n");
+ debug(0, 6, "Receive MISSes from all neighbors and parents\n");
/* pass in fd=0 here so getFromCache() looks up the real FD
* and resets the timeout handler */
getFromDefaultSource(0, entry);
return;
}
} else {
- debug(0, "neighborsUdpAck: WHY ARE WE HERE? header->opcode = %d\n",
+ debug(0, 0, "neighborsUdpAck: WHY ARE WE HERE? header->opcode = %d\n",
header->opcode);
}
}
t->ascii_port, t->udp_port, t->proxy_only,
t->domains);
} else {
- debug(0, "neighbors_init: skipping cache_host %s %s %d %d\n",
+ debug(0, 0, "neighbors_init: skipping cache_host %s %s %d %d\n",
t->type, t->host, t->ascii_port, t->udp_port);
- debug(0, "neighbors_init: because it seems to be identical to this cached\n");
+ debug(0, 0, "neighbors_init: because it seems to be identical to this cached\n");
}
xfree(t->host);
xfree(t->type);
if ((fname = getHierarchyLogFile()) == NULL)
return;
- debug(1, "neighbors_rotate_log: Rotating.\n");
+ debug(0, 1, "neighbors_rotate_log: Rotating.\n");
/* Rotate numbers 0 through N up one */
for (i = getLogfileRotateNumber(); i > 1;) {
fclose(cache_hierarchy_log);
log_fd = file_open(fname, NULL, O_WRONLY | O_CREAT | O_APPEND);
if (log_fd < 0) {
- debug(0, "rotate_logs: %s: %s\n", fname, xstrerror());
- debug(1, "Hierachical logging is disabled.\n");
+ debug(0, 0, "rotate_logs: %s: %s\n", fname, xstrerror());
+ debug(0, 1, "Hierachical logging is disabled.\n");
} else if ((cache_hierarchy_log = fdopen(log_fd, "a")) == NULL) {
- debug(0, "rotate_logs: %s: %s\n",
+ debug(0, 0, "rotate_logs: %s: %s\n",
fname, xstrerror());
- debug(1, "Hierachical logging is disabled.\n");
+ debug(0, 1, "Hierachical logging is disabled.\n");
}
}
-/* $Id: squid.h,v 1.3 1996/03/27 05:12:39 wessels Exp $ */
+/* $Id: squid.h,v 1.4 1996/03/27 18:15:52 wessels Exp $ */
#include "config.h"
#include "autoconf.h"
extern time_t cached_starttime; /* main.c */
extern time_t next_cleaning; /* main.c */
-extern int debug_level; /* main.c */
extern int catch_signals; /* main.c */
-/* $Id: stat.cc,v 1.7 1996/03/27 01:46:20 wessels Exp $ */
+/* $Id: stat.cc,v 1.8 1996/03/27 18:15:53 wessels Exp $ */
#include "squid.h"
continue;
if ((++N & 0xFF) == 0) {
cached_curtime = time(NULL);
- debug(3, "stat_objects_get: Processed %d objects...\n", N);
+ debug(0, 3, "stat_objects_get: Processed %d objects...\n", N);
}
obj_size = entry->object_len;
npend = storePendingNClients(entry);
httpd_accel_mode);
storeAppend(sentry, line, strlen(line));
- sprintf(line, "{DebugLevel %d \"# Cache debug level\"}\n",
- debug_level);
- storeAppend(sentry, line, strlen(line));
-
/* end of stats */
storeAppend(sentry, close_bracket, strlen(close_bracket));
}
if (file_write(obj->logfile_fd, buf = xstrdup(tmp), strlen(tmp),
obj->logfile_access, NULL, NULL) != DISK_OK) {
- debug(1, "log_append: File write failed.\n");
+ debug(0, 1, "log_append: File write failed.\n");
safe_free(buf);
}
}
/* open the logfile */
obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
- debug(0, "Cannot open logfile: %s\n", obj->logfilename);
+ debug(0, 0, "Cannot open logfile: %s\n", obj->logfilename);
obj->logfile_status = LOG_DISABLE;
}
obj->logfile_access = file_write_lock(obj->logfile_fd);
/* reopen it anyway */
obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
- debug(0, "Cannot open logfile: %s\n", obj->logfilename);
+ debug(0, 0, "Cannot open logfile: %s\n", obj->logfilename);
obj->logfile_status = LOG_DISABLE;
}
/* at the moment, store one char to make a storage manager happy */
memcpy(obj->logfilename, logfilename, (int) (strlen(logfilename) + 1) % 256);
obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
- debug(0, "Cannot open logfile: %s\n", obj->logfilename);
+ debug(0, 0, "Cannot open logfile: %s\n", obj->logfilename);
obj->logfile_status = LOG_DISABLE;
fatal("Cannot open logfile.\n");
}
if ((fname = CacheInfo->logfilename) == NULL)
return;
- debug(1, "stat_rotate_log: Rotating\n");
+ debug(0, 1, "stat_rotate_log: Rotating\n");
/* Rotate numbers 0 through N up one */
for (i = getLogfileRotateNumber(); i > 1;) {
file_close(CacheInfo->logfile_fd);
CacheInfo->logfile_fd = file_open(fname, NULL, O_RDWR | O_CREAT | O_APPEND);
if (CacheInfo->logfile_fd == DISK_ERROR) {
- debug(0, "rotate_logs: Cannot open logfile: %s\n", fname);
+ debug(0, 0, "rotate_logs: Cannot open logfile: %s\n", fname);
CacheInfo->logfile_status = LOG_DISABLE;
fatal("Cannot open logfile.\n");
}
-/* $Id: stmem.cc,v 1.3 1996/03/27 01:46:22 wessels Exp $ */
+/* $Id: stmem.cc,v 1.4 1996/03/27 18:15:54 wessels Exp $ */
#include "squid.h"
return current_offset;
}
if (current_offset != target_offset) {
- debug(1, "memFreeDataBehind: This shouldn't happen. Some odd condition.\n");
- debug(1, " Current offset: %d Target offset: %d p: %p\n",
+ debug(0, 1, "memFreeDataBehind: This shouldn't happen. Some odd condition.\n");
+ debug(0, 1, " Current offset: %d Target offset: %d p: %p\n",
current_offset, target_offset, p);
}
return current_offset;
int avail_len;
int len_to_copy;
- debug(6, "memAppend: len %d\n", len);
+ debug(0, 6, "memAppend: len %d\n", len);
/* Does the last block still contain empty space?
* If so, fill out the block before dropping into the
char *str_i, *mem_i;
int i = 0, blk_idx = 0, state, goal;
- debug(6, "memGrep: looking for %s in less than %d bytes.\n",
+ debug(0, 6, "memGrep: looking for %s in less than %d bytes.\n",
string, nbytes);
if (!p)
return 0;
if (mem->origin_offset != 0) {
- debug(1, "memGrep: Some lower chunk of data has been erased. Can't do memGrep!\n");
+ debug(0, 1, "memGrep: Some lower chunk of data has been erased. Can't do memGrep!\n");
return 0;
}
str_i = string;
int bytes_from_this_packet = 0;
int bytes_into_this_packet = 0;
- debug(6, "memCopy: offset %d: size %d\n", offset, size);
+ debug(0, 6, "memCopy: offset %d: size %d\n", offset, size);
if (size <= 0)
return size;
if (p->next)
p = p->next;
else {
- debug(1, "memCopy: Offset: %d is off limit of current object of %d\n", t_off, offset);
+ debug(0, 1, "memCopy: Offset: %d is off limit of current object of %d\n", t_off, offset);
return 0;
}
}
}
sm_stats.n_pages_in_use++;
if (page == NULL) {
- debug(0, "Null page pointer?");
+ debug(0, 0, "Null page pointer?");
fatal_dump(NULL);
}
return (page);
#if USE_MEMALIGN
if ((int) page % SM_PAGE_SIZE) {
- debug(0, "Someone tossed a string into the 4k page pool\n");
+ debug(0, 0, "Someone tossed a string into the 4k page pool\n");
fatal_dump(NULL);
}
#endif
if (full_stack(&sm_stats.free_page_stack)) {
sm_stats.total_pages_allocated--;
if (!stack_overflow_warning_toggle) {
- debug(0, "Stack of free stmem pages overflowed. Resize it?");
+ debug(0, 0, "Stack of free stmem pages overflowed. Resize it?");
stack_overflow_warning_toggle++;
}
}
}
disk_stats.n_pages_in_use++;
if (page == NULL) {
- debug(0, "Null page pointer?");
+ debug(0, 0, "Null page pointer?");
fatal_dump(NULL);
}
return (page);
#if USE_MEMALIGN
if ((int) page % DISK_PAGE_SIZE) {
- debug(0, "Someone tossed a string into the 8k page pool\n");
+ debug(0, 0, "Someone tossed a string into the 8k page pool\n");
fatal_dump(NULL);
}
#endif
if (full_stack(&disk_stats.free_page_stack)) {
disk_stats.total_pages_allocated--;
if (!stack_overflow_warning_toggle) {
- debug(0, "Stack of free disk pages overflowed. Resize it?");
+ debug(0, 0, "Stack of free disk pages overflowed. Resize it?");
stack_overflow_warning_toggle++;
}
}
-/* $Id: store.cc,v 1.12 1996/03/27 05:12:39 wessels Exp $ */
+/* $Id: store.cc,v 1.13 1996/03/27 18:15:54 wessels Exp $ */
/*
* Here is a summary of the routines which change mem_status and swap_status:
{
if (e) {
if (has_mem_obj(e))
- debug(1, "create_store_mem_obj: old memory not released\n");
+ debug(0, 1, "create_store_mem_obj: old memory not released\n");
e->mem_obj = (MemObject *) xcalloc(1, sizeof(MemObject));
meta_data.store_in_mem_objects++;
}
if (e->mem_status == IN_MEMORY && status != IN_MEMORY) {
if (e->key == NULL) {
- debug(0, "storeSetMemStatus: NULL key for %s\n", e->url);
+ debug(0, 0, "storeSetMemStatus: NULL key for %s\n", e->url);
return;
}
if ((ptr = hash_lookup(in_mem_table, e->key)))
if (e == (StoreEntry *) NULL)
return;
- debug(5, "storeFreeEntry: Freeing %s\n", e->url);
+ debug(0, 5, "storeFreeEntry: Freeing %s\n", e->url);
if (has_mem_obj(e)) {
store_mem_size -= e->mem_obj->e_current_len - e->mem_obj->e_lowest_offset;
- debug(8, "storeFreeEntry: Freeing %d in-memory bytes\n",
+ debug(0, 8, "storeFreeEntry: Freeing %d in-memory bytes\n",
e->mem_obj->e_current_len);
- debug(8, "storeFreeEntry: store_mem_size = %d\n", store_mem_size);
+ debug(0, 8, "storeFreeEntry: store_mem_size = %d\n", store_mem_size);
if (e->mem_obj->data) {
e->mem_obj->data->mem_free(e->mem_obj->data);
e->mem_obj->data = NULL;
void storeFreeEntryData(e)
StoreEntry *e;
{
- debug(5, "storeFreeEntryData: Freeing data-buffer only %s\n", e->url);
+ debug(0, 5, "storeFreeEntryData: Freeing data-buffer only %s\n", e->url);
store_mem_size -= e->mem_obj->e_current_len - e->mem_obj->e_lowest_offset;
- debug(8, "storeFreeEntryData: Freeing %d in-memory bytes\n",
+ debug(0, 8, "storeFreeEntryData: Freeing %d in-memory bytes\n",
e->mem_obj->e_current_len);
- debug(8, "storeFreeEntryData: store_mem_size = %d\n", store_mem_size);
+ debug(0, 8, "storeFreeEntryData: store_mem_size = %d\n", store_mem_size);
e->object_len = 0;
e->mem_obj->e_current_len = 0;
if (e->mem_obj->data) {
void storePurgeMem(e)
StoreEntry *e;
{
- debug(5, "storePurgeMem: Freeing memory-copy of %s\n", e->url);
+ debug(0, 5, "storePurgeMem: Freeing memory-copy of %s\n", e->url);
if (!has_mem_obj(e))
return;
if (storeEntryLocked(e)) {
- debug(0, "storePurgeMem: someone (storeGetMemSpace?) is purging a locked object?\n");
- debug(0, "%s", storeToString(e));
+ debug(0, 0, "storePurgeMem: someone (storeGetMemSpace?) is purging a locked object?\n");
+ debug(0, 0, "%s", storeToString(e));
fatal_dump(NULL);
}
/* free up memory data */
--meta_data.hot_vm;
}
store_mem_size -= e->object_len - e->mem_obj->e_lowest_offset;
- debug(8, "storePurgeMem: Freeing %d in-memory bytes\n",
+ debug(0, 8, "storePurgeMem: Freeing %d in-memory bytes\n",
e->object_len);
- debug(8, "storePurgeMem: store_mem_size = %d\n", store_mem_size);
+ debug(0, 8, "storePurgeMem: store_mem_size = %d\n", store_mem_size);
storeSetMemStatus(e, NOT_IN_MEMORY);
e->mem_obj->e_current_len = 0;
/* free up pending list table */
int status = 0;
e->lock_count++;
- debug(5, "storeLockObject: locks %d: <URL:%s>\n", e->lock_count, e->url);
+ debug(0, 5, "storeLockObject: locks %d: <URL:%s>\n", e->lock_count, e->url);
if ((e->mem_status == NOT_IN_MEMORY) && /* Not in memory */
(e->swap_status != SWAP_OK) && /* Not on disk */
(e->status != STORE_PENDING) /* Not being fetched */
) {
- debug(0, "storeLockObject: NOT_IN_MEMORY && !SWAP_OK && !STORE_PENDING conflict: <URL:%s>. aborting...\n", e->url);
+ debug(0, 0, "storeLockObject: NOT_IN_MEMORY && !SWAP_OK && !STORE_PENDING conflict: <URL:%s>. aborting...\n", e->url);
/* If this sanity check fails, we should just ... */
fatal_dump(NULL);
}
if ((int) e->lock_count > 0)
e->lock_count--;
else if (e->lock_count == 0) {
- debug(0, "Entry lock count %d is out-of-whack\n", e->lock_count);
+ debug(0, 0, "Entry lock count %d is out-of-whack\n", e->lock_count);
}
/* Prevent UMR if we end up freeing the entry */
e_lock_count = (int) e->lock_count;
{
hash_link *hptr = NULL;
- debug(5, "storeGet: looking up %s\n", url);
+ debug(0, 5, "storeGet: looking up %s\n", url);
if (table != (HashID) 0) {
if ((hptr = hash_lookup(table, url)) != NULL)
char *url;
int request_type_id;
{
- debug(5, "storeGenerateKey: type=%d %s\n", request_type_id, url);
+ debug(0, 5, "storeGenerateKey: type=%d %s\n", request_type_id, url);
if (request_type_id == REQUEST_OP_POST) {
sprintf(key_temp_buffer, "/post/%s", url);
return key_temp_buffer;
char key[MAX_URL + 16];
StoreEntry *e = NULL;
- debug(5, "storeAdd: %s\n", url);
+ debug(0, 5, "storeAdd: %s\n", url);
meta_data.store_entries++;
meta_data.url_strings += strlen(url);
{
StoreEntry *e = NULL;
- debug(5, "StoreAddDiskRestore: <URL:%s>: size %d: expires %d: file_number %d\n",
+ debug(0, 5, "StoreAddDiskRestore: <URL:%s>: size %d: expires %d: file_number %d\n",
url, size, expires, file_number);
if (file_map_bit_test(file_number)) {
- debug(0, "This file number is already allocated!\n");
- debug(0, " --> file_number %d\n", file_number);
- debug(0, " --> <URL:%s>\n", url);
+ debug(0, 0, "This file number is already allocated!\n");
+ debug(0, 0, " --> file_number %d\n", file_number);
+ debug(0, 0, " --> <URL:%s>\n", url);
return (NULL);
}
meta_data.store_entries++;
PendingEntry *pe = (PendingEntry *) xmalloc(sizeof(PendingEntry));
int old_size, i, j;
- debug(5, "storeRegister: FD %d <URL:%s>\n", fd, e->url);
+ debug(0, 5, "storeRegister: FD %d <URL:%s>\n", fd, e->url);
memset(pe, '\0', sizeof(PendingEntry));
pe->fd = fd;
safe_free(e->mem_obj->pending);
e->mem_obj->pending = tmp;
- debug(10, "storeRegister: grew pending list to %d for slot %d.\n",
+ debug(0, 10, "storeRegister: grew pending list to %d for slot %d.\n",
e->mem_obj->pending_list_size, i);
}
int i;
int freed = 0;
- debug(10, "storeUnregister: called for FD %d <URL:%s>\n", fd, e->url);
+ debug(0, 10, "storeUnregister: called for FD %d <URL:%s>\n", fd, e->url);
/* look for entry in client_list */
if (e->mem_obj->client_list) {
}
}
- debug(10, "storeUnregister: returning %d\n", freed);
+ debug(0, 10, "storeUnregister: returning %d\n", freed);
return freed;
}
int n_client = 0;
int i;
- debug(3, "storeDeleteBehind: Object: %s\n", e->key);
- debug(3, "storeDeleteBehind:\tOriginal Lowest Offset: %d \n", e->mem_obj->e_lowest_offset);
+ debug(0, 3, "storeDeleteBehind: Object: %s\n", e->key);
+ debug(0, 3, "storeDeleteBehind:\tOriginal Lowest Offset: %d \n", e->mem_obj->e_lowest_offset);
free_up_to = e->mem_obj->e_lowest_offset;
target_offset = 0;
}
if (n_client == 0) {
- debug(3, "storeDeleteBehind:\tThere is no client in the list.\n");
- debug(3, "\t\tTry to delete as fast as possible.\n");
+ debug(0, 3, "storeDeleteBehind:\tThere is no client in the list.\n");
+ debug(0, 3, "\t\tTry to delete as fast as possible.\n");
target_offset = e->mem_obj->e_current_len;
}
- debug(3, "storeDeleteBehind:\tThe target offset is : %d\n", target_offset);
+ debug(0, 3, "storeDeleteBehind:\tThe target offset is : %d\n", target_offset);
if (target_offset) {
free_up_to = (int) e->mem_obj->data->mem_free_data_upto(e->mem_obj->data,
target_offset);
- debug(3, " Object is freed upto : %d\n", free_up_to);
+ debug(0, 3, " Object is freed upto : %d\n", free_up_to);
store_mem_size -= free_up_to - e->mem_obj->e_lowest_offset;
}
- debug(3, "storeDeleteBehind:\tOutgoing Lowest Offset : %d\n", free_up_to);
+ debug(0, 3, "storeDeleteBehind:\tOutgoing Lowest Offset : %d\n", free_up_to);
e->mem_obj->e_lowest_offset = free_up_to;
}
void storeStartDeleteBehind(e)
StoreEntry *e;
{
- debug(2, "storeStartDeleteBehind: Object: %s\n", e->key);
+ debug(0, 2, "storeStartDeleteBehind: Object: %s\n", e->key);
if (e->flag & DELETE_BEHIND) {
- debug(2, "storeStartDeleteBehind:\tis already in delete behind mode.\n");
+ debug(0, 2, "storeStartDeleteBehind:\tis already in delete behind mode.\n");
return;
}
- debug(2, "storeStartDeleteBehind:\tis now in delete behind mode.\n");
+ debug(0, 2, "storeStartDeleteBehind:\tis now in delete behind mode.\n");
/* change its key, so it couldn't be found by other client */
storeChangeKey(e);
BIT_SET(e->flag, DELETE_BEHIND);
{
/* validity check -- sometimes it's called with bogus values */
if (e == NULL || !has_mem_obj(e) || e->mem_obj->data == NULL) {
- debug(0, "storeAppend (len = %d): Invalid StoreEntry, aborting...\n",
+ debug(0, 0, "storeAppend (len = %d): Invalid StoreEntry, aborting...\n",
len);
if (len < 512)
fwrite(data, len, 1, debug_log);
- debug(0, "%s", storeToString(e));
+ debug(0, 0, "%s", storeToString(e));
fatal_dump(NULL);
}
if (len) {
- debug(5, "storeAppend: appending %d bytes for %s\n", len, e->url);
+ debug(0, 5, "storeAppend: appending %d bytes for %s\n", len, e->url);
/* get some extra storage if needed */
(void) storeGetMemSpace(len, 0);
store_mem_size += len;
- debug(8, "storeAppend: growing store_mem_size by %d\n", len);
- debug(8, "storeAppend: store_mem_size = %d\n", store_mem_size);
+ debug(0, 8, "storeAppend: growing store_mem_size by %d\n", len);
+ debug(0, 8, "storeAppend: store_mem_size = %d\n", store_mem_size);
(void) e->mem_obj->data->mem_append(e->mem_obj->data,
data, len);
e->mem_obj->e_current_len += len;
- debug(8, "storeAppend: e_current_len = %d\n",
+ debug(0, 8, "storeAppend: e_current_len = %d\n",
e->mem_obj->e_current_len);
}
if ((e->status != STORE_ABORTED) && !(e->flag & DELAY_SENDING))
StoreEntry *e;
int offset_notused;
{
- debug(2, "storeSwapInHandle: <URL:%s>\n", e->url);
+ debug(0, 2, "storeSwapInHandle: <URL:%s>\n", e->url);
if ((flag < 0) && (flag != DISK_EOF)) {
- debug(0, "storeSwapInHandle: SwapIn failure (err code = %d).\n", flag);
+ debug(0, 0, "storeSwapInHandle: SwapIn failure (err code = %d).\n", flag);
put_free_8k_page(e->mem_obj->e_swap_buf);
storeSetMemStatus(e, NOT_IN_MEMORY);
file_close(e->mem_obj->swap_fd);
swapInError(-1, e); /* Invokes storeAbort() and completes the I/O */
return -1;
}
- debug(5, "storeSwapInHandle: e->swap_offset = %d\n",
+ debug(0, 5, "storeSwapInHandle: e->swap_offset = %d\n",
e->mem_obj->swap_offset);
- debug(5, "storeSwapInHandle: len = %d\n",
+ debug(0, 5, "storeSwapInHandle: len = %d\n",
len);
- debug(5, "storeSwapInHandle: e->e_current_len = %d\n",
+ debug(0, 5, "storeSwapInHandle: e->e_current_len = %d\n",
e->mem_obj->e_current_len);
- debug(5, "storeSwapInHandle: e->object_len = %d\n",
+ debug(0, 5, "storeSwapInHandle: e->object_len = %d\n",
e->object_len);
/* always call these, even if len == 0 */
storeSetMemStatus(e, IN_MEMORY);
put_free_8k_page(e->mem_obj->e_swap_buf);
file_close(e->mem_obj->swap_fd);
- debug(5, "storeSwapInHandle: SwapIn complete: <URL:%s> from %s.\n",
+ debug(0, 5, "storeSwapInHandle: SwapIn complete: <URL:%s> from %s.\n",
e->url, storeSwapFullPath(e->swap_file_number, NULL));
if (e->mem_obj->e_current_len != e->object_len) {
- debug(0, "storeSwapInHandle: WARNING! Object size mismatch.\n");
- debug(0, " --> <URL:%s>\n", e->url);
- debug(0, " --> Expecting %d bytes from file: %s\n", e->object_len,
+ debug(0, 0, "storeSwapInHandle: WARNING! Object size mismatch.\n");
+ debug(0, 0, " --> <URL:%s>\n", e->url);
+ debug(0, 0, " --> Expecting %d bytes from file: %s\n", e->object_len,
storeSwapFullPath(e->swap_file_number, NULL));
- debug(0, " --> Only read %d bytes\n",
+ debug(0, 0, " --> Only read %d bytes\n",
e->mem_obj->e_current_len);
}
if (e->flag & RELEASE_REQUEST)
/* sanity check! */
if ((e->swap_status != SWAP_OK) || (e->swap_file_number < 0)) {
- debug(0, "storeSwapInStart: <No filename:%d> ? <URL:%s>\n", e->swap_file_number, e->url);
+ debug(0, 0, "storeSwapInStart: <No filename:%d> ? <URL:%s>\n", e->swap_file_number, e->url);
if (has_mem_obj(e))
e->mem_obj->swap_fd = -1;
return -1;
e->mem_obj->swap_fd = fd =
file_open(storeSwapFullPath(e->swap_file_number, NULL), NULL, O_RDONLY);
if (fd < 0) {
- debug(0, "storeSwapInStart: Unable to open swapfile: %s for\n\t<URL:%s>\n",
+ debug(0, 0, "storeSwapInStart: Unable to open swapfile: %s for\n\t<URL:%s>\n",
storeSwapFullPath(e->swap_file_number, NULL), e->url);
storeSetMemStatus(e, NOT_IN_MEMORY);
/* Invoke a store abort that should free the destroy_store_mem_obj(e); */
return -1;
}
- debug(5, "storeSwapInStart: initialized swap file '%s' for <URL:%s>\n",
+ debug(0, 5, "storeSwapInStart: initialized swap file '%s' for <URL:%s>\n",
storeSwapFullPath(e->swap_file_number, NULL), e->url);
e->mem_obj->data = memInit();
static char logmsg[6000];
char *page_ptr = NULL;
- debug(5, "storeSwapOutHandle: <URL:%s>\n", e->url);
+ debug(0, 5, "storeSwapOutHandle: <URL:%s>\n", e->url);
e->timestamp = cached_curtime;
storeSwapFullPath(e->swap_file_number, filename);
page_ptr = e->mem_obj->e_swap_buf;
if (flag < 0) {
- debug(1, "storeSwapOutHandle: SwapOut failure (err code = %d).\n",
+ debug(0, 1, "storeSwapOutHandle: SwapOut failure (err code = %d).\n",
flag);
e->swap_status = NO_SWAP;
put_free_8k_page(page_ptr);
}
return;
}
- debug(6, "storeSwapOutHandle: e->swap_offset = %d\n",
+ debug(0, 6, "storeSwapOutHandle: e->swap_offset = %d\n",
e->mem_obj->swap_offset);
- debug(6, "storeSwapOutHandle: e->e_swap_buf_len = %d\n",
+ debug(0, 6, "storeSwapOutHandle: e->e_swap_buf_len = %d\n",
e->mem_obj->e_swap_buf_len);
- debug(6, "storeSwapOutHandle: e->object_len = %d\n",
+ debug(0, 6, "storeSwapOutHandle: e->object_len = %d\n",
e->object_len);
- debug(6, "storeSwapOutHandle: store_swap_size = %dk\n",
+ debug(0, 6, "storeSwapOutHandle: store_swap_size = %dk\n",
store_swap_size);
e->mem_obj->swap_offset += e->mem_obj->e_swap_buf_len;
/* swapping complete */
e->swap_status = SWAP_OK;
file_close(e->mem_obj->swap_fd);
- debug(5, "storeSwapOutHandle: SwapOut complete: <URL:%s> to %s.\n",
+ debug(0, 5, "storeSwapOutHandle: SwapOut complete: <URL:%s> to %s.\n",
e->url, storeSwapFullPath(e->swap_file_number, NULL));
put_free_8k_page(page_ptr);
sprintf(logmsg, "FILE: %s URL: %s %d %d %d\n",
fd = file_open(swapfilename, NULL, O_RDWR | O_CREAT | O_TRUNC);
if (fd < 0) {
- debug(0, "storeSwapOutStart: Unable to open swapfile: %s\n",
+ debug(0, 0, "storeSwapOutStart: Unable to open swapfile: %s\n",
swapfilename);
file_map_bit_reset(swapfileno);
e->swap_file_number = -1;
return -1;
}
e->mem_obj->swap_fd = fd;
- debug(5, "storeSwapOutStart: Begin SwapOut <URL:%s> to FD %d FILE %s.\n",
+ debug(0, 5, "storeSwapOutStart: Begin SwapOut <URL:%s> to FD %d FILE %s.\n",
e->url, fd, swapfilename);
e->swap_file_number = swapfileno;
if ((e->mem_obj->e_swap_access = file_write_lock(e->mem_obj->swap_fd)) < 0) {
- debug(0, "storeSwapOutStart: Unable to lock swapfile: %s\n",
+ debug(0, 0, "storeSwapOutStart: Unable to lock swapfile: %s\n",
swapfilename);
file_map_bit_reset(e->swap_file_number);
e->swap_file_number = -1;
int fast_mode = 0;
for (i = 0; i < ncache_dirs; ++i)
- debug(1, "Rebuilding storage from disk image in %s\n", swappath(i));
+ debug(0, 1, "Rebuilding storage from disk image in %s\n", swappath(i));
start = cached_curtime = time(NULL);
sprintf(line_in, "%s/log-last-clean", swappath(0));
}
}
if (fast_mode)
- debug(1, "Rebuilding in FAST MODE.\n");
+ debug(0, 1, "Rebuilding in FAST MODE.\n");
/* go to top of the file */
(void) lseek(swaplog_fd, 0L, SEEK_SET);
cached_curtime = time(NULL);
if ((linecount & 0xFFF) == 0)
- debug(1, " %7d Lines read so far.\n", linecount);
+ debug(0, 1, " %7d Lines read so far.\n", linecount);
- debug(10, "line_in: %s", line_in);
+ debug(0, 10, "line_in: %s", line_in);
if ((line_in[0] == '\0') || (line_in[0] == '\n') ||
(line_in[0] == '#'))
continue; /* skip bad lines */
if (stat(swapfile, &sb) < 0) {
if (expires < cached_curtime) {
- debug(3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
+ debug(0, 3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
#ifdef UNLINK_ON_RELOAD
safeunlink(swapfile, 1);
#endif
expcount++;
} else {
- debug(3, "storeRebuildFromDisk: Swap file missing: <URL:%s>: %s: %s.\n", url, swapfile, xstrerror());
+ debug(0, 3, "storeRebuildFromDisk: Swap file missing: <URL:%s>: %s: %s.\n", url, swapfile, xstrerror());
#ifdef UNLINK_ON_RELOAD
safeunlink(log_swapfile, 1);
#endif
continue;
}
timestamp = sb.st_mtime;
- debug(10, "storeRebuildFromDisk: Cached file exists: <URL:%s>: %s\n",
+ debug(0, 10, "storeRebuildFromDisk: Cached file exists: <URL:%s>: %s\n",
url, swapfile);
}
if ((e = storeGet(url))) {
- debug(6, "storeRebuildFromDisk: Duplicate: <URL:%s>\n", url);
+ debug(0, 6, "storeRebuildFromDisk: Duplicate: <URL:%s>\n", url);
storeRelease(e);
objcount--;
dupcount++;
}
if (expires < cached_curtime) {
- debug(3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
+ debug(0, 3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
#ifdef UNLINK_ON_RELOAD
safeunlink(swapfile, 1);
#endif
r = stop - start;
/* swapfileno = sfileno; */
/* PBD: Start swapfileno at zero, so that old swap files are overwritten */
- debug(1, "Finished rebuilding storage from disk image.\n");
- debug(1, " %7d Lines read from previous logfile.\n", linecount);
- debug(1, " %7d Objects loaded.\n", objcount);
- debug(1, " %7d Objects expired.\n", expcount);
- debug(1, " %7d Duplicate URLs purged.\n", dupcount);
- debug(1, " %7d Swapfile clashes avoided.\n", clashcount);
- debug(1, " Took %d seconds (%6.1lf objects/sec).\n",
+ debug(0, 1, "Finished rebuilding storage from disk image.\n");
+ debug(0, 1, " %7d Lines read from previous logfile.\n", linecount);
+ debug(0, 1, " %7d Objects loaded.\n", objcount);
+ debug(0, 1, " %7d Objects expired.\n", expcount);
+ debug(0, 1, " %7d Duplicate URLs purged.\n", dupcount);
+ debug(0, 1, " %7d Swapfile clashes avoided.\n", clashcount);
+ debug(0, 1, " Took %d seconds (%6.1lf objects/sec).\n",
r > 0 ? r : 0, (double) objcount / (r > 0 ? r : 1));
- debug(1, " store_swap_size = %dk\n", store_swap_size);
+ debug(0, 1, " store_swap_size = %dk\n", store_swap_size);
/* touch a timestamp file */
sprintf(line_in, "%s/log-last-clean", swappath(0));
void storeComplete(e)
StoreEntry *e;
{
- debug(5, "storeComplete: <URL:%s>\n", e->url);
+ debug(0, 5, "storeComplete: <URL:%s>\n", e->url);
e->object_len = e->mem_obj->e_current_len;
InvokeHandlers(e);
static char mime_hdr[300];
static char abort_msg[2000];
- debug(6, "storeAbort: <URL:%s>\n", e->url);
+ debug(0, 6, "storeAbort: <URL:%s>\n", e->url);
e->expires = cached_curtime + getNegativeTTL();
e->status = STORE_ABORTED;
storeSetMemStatus(e, IN_MEMORY);
if ((int) (strlen(msg) + strlen(mime_hdr) + 50) < 2000) {
sprintf(abort_msg, "HTTP/1.0 400 Cache Detected Error\r\n%s\r\n\r\n%s", mime_hdr, msg);
} else {
- debug(0, "storeAbort: WARNING: Must increase msg length!");
+ debug(0, 0, "storeAbort: WARNING: Must increase msg length!");
}
storeAppend(e, abort_msg, strlen(abort_msg));
e->mem_obj->e_abort_msg = xstrdup(abort_msg);
if ((++n & 0xFF) == 0)
cached_curtime = time(NULL);
if ((n & 0xFFF) == 0)
- debug(2, "storeWalkThrough: %7d objects so far.\n", n);
+ debug(0, 2, "storeWalkThrough: %7d objects so far.\n", n);
count += proc(e, data);
}
return count;
{
time_t curtime = *((time_t *) data);
- debug(5, "removeOldEntry: Checking: %s\n", e->url);
- debug(6, "removeOldEntry: * curtime: %8ld\n", curtime);
- debug(6, "removeOldEntry: * e->timestamp: %8ld\n", e->timestamp);
- debug(6, "removeOldEntry: * time in cache: %8ld\n",
+ debug(0, 5, "removeOldEntry: Checking: %s\n", e->url);
+ debug(0, 6, "removeOldEntry: * curtime: %8ld\n", curtime);
+ debug(0, 6, "removeOldEntry: * e->timestamp: %8ld\n", e->timestamp);
+ debug(0, 6, "removeOldEntry: * time in cache: %8ld\n",
curtime - e->timestamp);
- debug(6, "removeOldEntry: * time-to-live: %8ld\n",
+ debug(0, 6, "removeOldEntry: * time-to-live: %8ld\n",
e->expires - cached_curtime);
if ((cached_curtime > e->expires) && (e->status != STORE_PENDING)) {
{
int n;
- debug(3, "storePurgeOld: Begin purging TTL-expired objects\n");
+ debug(0, 3, "storePurgeOld: Begin purging TTL-expired objects\n");
n = storeWalkThrough(removeOldEntry, (caddr_t) & cached_curtime);
- debug(3, "storePurgeOld: Done purging TTL-expired objects.\n");
- debug(3, "storePurgeOld: %d objects expired\n", n);
+ debug(0, 3, "storePurgeOld: Done purging TTL-expired objects.\n");
+ debug(0, 3, "storePurgeOld: %d objects expired\n", n);
return n;
}
if (!check_vm_number && ((store_mem_size + size) < store_mem_high))
return 0;
- debug(2, "storeGetMemSpace: Starting...\n");
+ debug(0, 2, "storeGetMemSpace: Starting...\n");
LRU_list = create_dynamic_array(meta_data.store_in_mem_objects, MEM_LRUSCAN_BLOCK);
pending_entry_list = create_dynamic_array(meta_data.store_in_mem_objects, MEM_LRUSCAN_BLOCK);
continue;
}
if (cached_curtime > e->expires) {
- debug(2, "storeGetMemSpace: Expired: %s\n", e->url);
+ debug(0, 2, "storeGetMemSpace: Expired: %s\n", e->url);
n_expired++;
/* Delayed release */
storeRelease(e);
} else {
n_cantpurge++;
mem_cantpurge += e->mem_obj->e_current_len;
- debug(5, "storeGetMemSpace: Can't purge %7d bytes: %s\n",
+ debug(0, 5, "storeGetMemSpace: Can't purge %7d bytes: %s\n",
e->mem_obj->e_current_len, e->url);
if (e->swap_status != SWAP_OK)
- debug(5, "storeGetMemSpace: --> e->swap_status != SWAP_OK\n");
+ debug(0, 5, "storeGetMemSpace: --> e->swap_status != SWAP_OK\n");
if (e->lock_count)
- debug(5, "storeGetMemSpace: --> e->lock_count %d\n", e->lock_count);
+ debug(0, 5, "storeGetMemSpace: --> e->lock_count %d\n", e->lock_count);
}
}
- debug(2, "storeGetMemSpace: Current size: %7d bytes\n", store_mem_size);
- debug(2, "storeGetMemSpace: High W Mark: %7d bytes\n", store_mem_high);
- debug(2, "storeGetMemSpace: Low W Mark: %7d bytes\n", store_mem_low);
- debug(2, "storeGetMemSpace: Entry count: %7d items\n", meta_data.store_entries);
- debug(2, "storeGetMemSpace: Scanned: %7d items\n", n_scanned);
- debug(2, "storeGetMemSpace: In memory: %7d items\n", n_inmem);
- debug(2, "storeGetMemSpace: Hot vm count: %7d items\n", meta_data.hot_vm);
- debug(2, "storeGetMemSpace: Expired: %7d items\n", n_expired);
- debug(2, "storeGetMemSpace: Negative Cached: %7d items\n", n_aborted);
- debug(2, "storeGetMemSpace: Can't purge: %7d items\n", n_cantpurge);
- debug(2, "storeGetMemSpace: Can't purge size: %7d bytes\n", mem_cantpurge);
- debug(2, "storeGetMemSpace: Sorting LRU_list: %7d items\n", LRU_list->index);
+ debug(0, 2, "storeGetMemSpace: Current size: %7d bytes\n", store_mem_size);
+ debug(0, 2, "storeGetMemSpace: High W Mark: %7d bytes\n", store_mem_high);
+ debug(0, 2, "storeGetMemSpace: Low W Mark: %7d bytes\n", store_mem_low);
+ debug(0, 2, "storeGetMemSpace: Entry count: %7d items\n", meta_data.store_entries);
+ debug(0, 2, "storeGetMemSpace: Scanned: %7d items\n", n_scanned);
+ debug(0, 2, "storeGetMemSpace: In memory: %7d items\n", n_inmem);
+ debug(0, 2, "storeGetMemSpace: Hot vm count: %7d items\n", meta_data.hot_vm);
+ debug(0, 2, "storeGetMemSpace: Expired: %7d items\n", n_expired);
+ debug(0, 2, "storeGetMemSpace: Negative Cached: %7d items\n", n_aborted);
+ debug(0, 2, "storeGetMemSpace: Can't purge: %7d items\n", n_cantpurge);
+ debug(0, 2, "storeGetMemSpace: Can't purge size: %7d bytes\n", mem_cantpurge);
+ debug(0, 2, "storeGetMemSpace: Sorting LRU_list: %7d items\n", LRU_list->index);
qsort((char *) LRU_list->collection, LRU_list->index, sizeof(e), (int (*)(const void *, const void *)) compareLastRef);
/* Kick LRU out until we have enough memory space */
destroy_dynamic_array(LRU_list);
- debug(2, "storeGetMemSpace: After freeing size: %7d bytes\n", store_mem_size);
- debug(2, "storeGetMemSpace: Purged: %7d items\n", n_purged);
- debug(2, "storeGetMemSpace: Released: %7d items\n", n_released);
+ debug(0, 2, "storeGetMemSpace: After freeing size: %7d bytes\n", store_mem_size);
+ debug(0, 2, "storeGetMemSpace: Purged: %7d items\n", n_purged);
+ debug(0, 2, "storeGetMemSpace: Released: %7d items\n", n_released);
if (check_vm_number) {
/* don't check for size */
destroy_dynamic_array(pending_entry_list);
- debug(2, "storeGetMemSpace: Done.\n");
+ debug(0, 2, "storeGetMemSpace: Done.\n");
return 0;
}
if ((store_mem_size + size) < store_mem_high) {
/* we don't care for hot_vm count here, just the storage size. */
over_highwater = over_max = 0;
destroy_dynamic_array(pending_entry_list);
- debug(2, "storeGetMemSpace: Done.\n");
+ debug(0, 2, "storeGetMemSpace: Done.\n");
return 0;
}
if ((store_mem_size + size) < getCacheMemMax()) {
/* We're over high water mark here, but still under absolute max */
if (!over_highwater) {
/* print only once when the condition occur until it clears. */
- debug(1, "storeGetMemSpace: Allocating beyond the high water mark with total size of %d\n",
+ debug(0, 1, "storeGetMemSpace: Allocating beyond the high water mark with total size of %d\n",
store_mem_size + size);
over_highwater = 1;
}
/* We're over absolute max */
if (!over_max) {
/* print only once when the condition occur until it clears. */
- debug(1, "storeGetMemSpace: Allocating beyond the MAX Store with total size of %d\n",
+ debug(0, 1, "storeGetMemSpace: Allocating beyond the MAX Store with total size of %d\n",
store_mem_size + size);
- debug(1, " Start Deleting Behind for every pending objects\n:");
- debug(1, " You should really adjust your cache_mem, high/low water mark,\n");
- debug(1, " max object size to suit your need.\n");
+ debug(0, 1, " Start Deleting Behind for every pending objects\n:");
+ debug(0, 1, " You should really adjust your cache_mem, high/low water mark,\n");
+ debug(0, 1, " max object size to suit your need.\n");
over_max = 1;
}
/* delete all of them, we desperate for a space. */
storeStartDeleteBehind(pending_entry_list->collection[i]);
}
if (n_deleted_behind) {
- debug(1, "storeGetMemSpace: Due to memory flucuation, put %d objects to DELETE_BEHIND MODE.\n",
+ debug(0, 1, "storeGetMemSpace: Due to memory flucuation, put %d objects to DELETE_BEHIND MODE.\n",
n_deleted_behind);
}
destroy_dynamic_array(pending_entry_list);
- debug(2, "storeGetMemSpace: Done.\n");
+ debug(0, 2, "storeGetMemSpace: Done.\n");
return 0;
}
StoreEntry **e1, **e2;
{
if (!e1 || !e2) {
- debug(1, "compareSize: Called with at least one null argument, shouldn't happen.\n");
+ debug(0, 1, "compareSize: Called with at least one null argument, shouldn't happen.\n");
return 0;
}
if ((*e1)->mem_obj->e_current_len > (*e2)->mem_obj->e_current_len)
if (!fReduceSwap && (store_swap_size + kb_size <= store_swap_high)) {
return 0;
}
- debug(2, "storeGetSwapSpace: Starting...\n");
+ debug(0, 2, "storeGetSwapSpace: Starting...\n");
/* Set flag if swap size over high-water-mark */
if (store_swap_size + kb_size > store_swap_high)
fReduceSwap = 1;
- debug(2, "storeGetSwapSpace: Need %d bytes...\n", size);
+ debug(0, 2, "storeGetSwapSpace: Need %d bytes...\n", size);
LRU_list = create_dynamic_array(LRU_cur_size, LRU_cur_size);
/* remove expired objects until recover enough space or no expired objects */
(e->lock_count == 0) && /* Be overly cautious */
(e->mem_status != SWAPPING_IN)) { /* Not if it's being faulted into memory */
if (cached_curtime > e->expires) {
- debug(2, "storeRemoveExpiredObj: Expired: <URL:%s>\n", e->url);
+ debug(0, 2, "storeRemoveExpiredObj: Expired: <URL:%s>\n", e->url);
/* just call release. don't have to check for lock status.
* storeRelease will take care of that and set a pending flag
* if it's still locked. */
++scan_in_objs;
}
} else {
- debug(2, "storeGetSwapSpace: Can't purge %7d bytes: <URL:%s>\n",
+ debug(0, 2, "storeGetSwapSpace: Can't purge %7d bytes: <URL:%s>\n",
e->object_len, e->url);
if (e->lock_count) {
- debug(2, "\t\te->lock_count %d\n", e->lock_count);
+ debug(0, 2, "\t\te->lock_count %d\n", e->lock_count);
}
if (e->swap_status == SWAPPING_OUT) {
- debug(2, "\t\te->swap_status == SWAPPING_OUT\n");
+ debug(0, 2, "\t\te->swap_status == SWAPPING_OUT\n");
}
locked++;
locked_size += e->mem_obj->e_current_len;
) {
fReduceSwap = 0;
destroy_dynamic_array(LRU_list);
- debug(2, "storeGetSwapSpace: Finished, %d objects expired.\n",
+ debug(0, 2, "storeGetSwapSpace: Finished, %d objects expired.\n",
expired);
return 0;
}
} /* for */
/* end of candidate selection */
- debug(2, "storeGetSwapSpace: Current Size: %7d kbytes\n", store_swap_size);
- debug(2, "storeGetSwapSpace: High W Mark: %7d kbytes\n", store_swap_high);
- debug(2, "storeGetSwapSpace: Low W Mark: %7d kbytes\n", store_swap_low);
- debug(2, "storeGetSwapSpace: Entry count: %7d items\n", meta_data.store_entries);
- debug(2, "storeGetSwapSpace: Scanned: %7d items\n", scanned);
- debug(2, "storeGetSwapSpace: Expired: %7d items\n", expired);
- debug(2, "storeGetSwapSpace: Locked: %7d items\n", locked);
- debug(2, "storeGetSwapSpace: Locked Space: %7d bytes\n", locked_size);
- debug(2, "storeGetSwapSpace: Scan in array: %7d bytes\n", scan_in_objs);
- debug(2, "storeGetSwapSpace: LRU candidate: %7d items\n", LRU_list->index);
+ debug(0, 2, "storeGetSwapSpace: Current Size: %7d kbytes\n", store_swap_size);
+ debug(0, 2, "storeGetSwapSpace: High W Mark: %7d kbytes\n", store_swap_high);
+ debug(0, 2, "storeGetSwapSpace: Low W Mark: %7d kbytes\n", store_swap_low);
+ debug(0, 2, "storeGetSwapSpace: Entry count: %7d items\n", meta_data.store_entries);
+ debug(0, 2, "storeGetSwapSpace: Scanned: %7d items\n", scanned);
+ debug(0, 2, "storeGetSwapSpace: Expired: %7d items\n", expired);
+ debug(0, 2, "storeGetSwapSpace: Locked: %7d items\n", locked);
+ debug(0, 2, "storeGetSwapSpace: Locked Space: %7d bytes\n", locked_size);
+ debug(0, 2, "storeGetSwapSpace: Scan in array: %7d bytes\n", scan_in_objs);
+ debug(0, 2, "storeGetSwapSpace: LRU candidate: %7d items\n", LRU_list->index);
/* Although all expired objects removed, still didn't recover enough */
/* space. Kick LRU out until we have enough swap space */
if (storeRelease(LRU) == 0) {
removed++;
} else {
- debug(2, "storeGetSwapSpace: Help! Can't remove objects. <%s>\n",
+ debug(0, 2, "storeGetSwapSpace: Help! Can't remove objects. <%s>\n",
LRU->url);
}
}
}
- debug(2, "storeGetSwapSpace: After Freeing Size: %7d kbytes\n", store_swap_size);
+ debug(0, 2, "storeGetSwapSpace: After Freeing Size: %7d kbytes\n", store_swap_size);
/* free the list */
destroy_dynamic_array(LRU_list);
if ((store_swap_size + kb_size > store_swap_high)) {
if (++swap_help > SWAP_MAX_HELP) {
- debug(0, "storeGetSwapSpace: Nothing to free with %d Kbytes in use.\n",
+ debug(0, 0, "storeGetSwapSpace: Nothing to free with %d Kbytes in use.\n",
store_swap_size);
- debug(0, "--> Asking for %d bytes\n", size);
- debug(0, "WARNING! Repeated failures to allocate swap space!\n");
- debug(0, "WARNING! Please check your disk space.\n");
+ debug(0, 0, "--> Asking for %d bytes\n", size);
+ debug(0, 0, "WARNING! Repeated failures to allocate swap space!\n");
+ debug(0, 0, "WARNING! Please check your disk space.\n");
swap_help = 0;
} else {
- debug(2, "storeGetSwapSpace: Nothing to free with %d Kbytes in use.\n",
+ debug(0, 2, "storeGetSwapSpace: Nothing to free with %d Kbytes in use.\n",
store_swap_size);
- debug(2, "--> Asking for %d bytes\n", size);
+ debug(0, 2, "--> Asking for %d bytes\n", size);
}
} else {
swap_help = 0;
}
- debug(2, "storeGetSwapSpace: Finished, %d objects removed.\n", removed);
+ debug(0, 2, "storeGetSwapSpace: Finished, %d objects removed.\n", removed);
return 0;
}
BIT_SET(e->flag, RELEASE_REQUEST);
return -1;
}
- debug(5, "storeRelease: Releasing: %s\n", e->url);
+ debug(0, 5, "storeRelease: Releasing: %s\n", e->url);
if (table == (HashID) 0)
return -1;
if (e->key == NULL) {
- debug(0, "storeRelease: NULL key for %s\n", e->url);
- debug(0, "Dump of Entry 'e':\n %s\n", storeToString(e));
+ debug(0, 0, "storeRelease: NULL key for %s\n", e->url);
+ debug(0, 0, "Dump of Entry 'e':\n %s\n", storeToString(e));
fatal_dump(NULL);
}
if ((hptr = hash_lookup(table, e->key)) == NULL) {
- debug(0, "storeRelease: Not Found: %s\n", e->url);
- debug(0, "Dump of Entry 'e':\n %s\n", storeToString(e));
+ debug(0, 0, "storeRelease: Not Found: %s\n", e->url);
+ debug(0, 0, "Dump of Entry 'e':\n %s\n", storeToString(e));
fatal_dump(NULL);
}
result = (StoreEntry *) hptr;
if (result != e) {
- debug(0, "storeRelease: Duplicated entry? <URL:%s>\n",
+ debug(0, 0, "storeRelease: Duplicated entry? <URL:%s>\n",
result->url ? result->url : "NULL");
- debug(0, "Dump of Entry 'e':\n%s", storeToString(e));
- debug(0, "Dump of Entry 'result':\n%s", storeToString(result));
+ debug(0, 0, "Dump of Entry 'e':\n%s", storeToString(e));
+ debug(0, 0, "Dump of Entry 'result':\n%s", storeToString(result));
fatal_dump(NULL);
}
if (e->type_id == REQUEST_OP_GET) {
}
}
}
- debug(3, "storeRelease: Release object key: %s \n", e->key);
+ debug(0, 3, "storeRelease: Release object key: %s \n", e->key);
if (e->swap_status == SWAP_OK && (e->swap_file_number > -1)) {
(void) safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 0);
return;
if (e->key == NULL) {
- debug(0, "storeChangeKey: NULL key for %s\n", e->url);
+ debug(0, 0, "storeChangeKey: NULL key for %s\n", e->url);
return;
}
if (table != (HashID) 0) {
BIT_SET(result->flag, KEY_CHANGE);
BIT_RESET(result->flag, KEY_URL);
} else {
- debug(1, "storeChangeKey: Key is not unique for key: %s\n", e->key);
+ debug(0, 1, "storeChangeKey: Key is not unique for key: %s\n", e->key);
}
}
}
StoreEntry *e;
{
if (!e) {
- debug(0, "This entry should be valid.\n");
- debug(0, "%s", storeToString(e));
+ debug(0, 0, "This entry should be valid.\n");
+ debug(0, 0, "%s", storeToString(e));
fatal_dump(NULL);
}
return ((e->lock_count) ||
if (stateoffset < e->mem_obj->e_lowest_offset) {
/* this should not happen. Logic race !!! */
- debug(1, "storeCopy: Client Request a chunk of data in area lower than the lowest_offset\n");
- debug(1, " Current Lowest offset : %d\n", e->mem_obj->e_lowest_offset);
- debug(1, " Requested offset : %d\n", stateoffset);
+ debug(0, 1, "storeCopy: Client Request a chunk of data in area lower than the lowest_offset\n");
+ debug(0, 1, " Current Lowest offset : %d\n", e->mem_obj->e_lowest_offset);
+ debug(0, 1, " Requested offset : %d\n", stateoffset);
/* can't really do anything here. Client may hang until lifetime runout. */
return 0;
}
*size = (available_to_write >= maxSize) ?
maxSize : available_to_write;
- debug(6, "storeCopy: avail_to_write=%d, store_offset=%d\n",
+ debug(0, 6, "storeCopy: avail_to_write=%d, store_offset=%d\n",
*size, stateoffset);
if (*size > 0)
if (stateoffset < e->mem_obj->e_lowest_offset) {
/* this should not happen. Logic race !!! */
- debug(1, "storeClientCopy: Client Request a chunk of data in area lower than the lowest_offset\n");
- debug(1, " fd : %d\n", fd);
- debug(1, " Current Lowest offset : %d\n", e->mem_obj->e_lowest_offset);
- debug(1, " Requested offset : %d\n", stateoffset);
+ debug(0, 1, "storeClientCopy: Client Request a chunk of data in area lower than the lowest_offset\n");
+ debug(0, 1, " fd : %d\n", fd);
+ debug(0, 1, " Current Lowest offset : %d\n", e->mem_obj->e_lowest_offset);
+ debug(0, 1, " Requested offset : %d\n", stateoffset);
/* can't really do anything here. Client may hang until lifetime runout. */
return 0;
}
*size = (available_to_write >= maxSize) ?
maxSize : available_to_write;
- debug(6, "storeCopy: avail_to_write=%d, store_offset=%d\n",
+ debug(0, 6, "storeCopy: avail_to_write=%d, store_offset=%d\n",
*size, stateoffset);
/* update the lowest requested offset */
for (inx = 0; inx < ncache_dirs; ++inx) {
path = swappath(inx);
- debug(10, "storeInit: Creating swap space in %s\n", path);
+ debug(0, 10, "storeInit: Creating swap space in %s\n", path);
if (stat(path, &sb) < 0) {
/* we need to create a directory for swap file here. */
if (mkdir(path, 0777) < 0) {
path, xstrerror());
fatal(tmpbuf);
}
- debug(1, "storeInit: Created swap directory %s\n", path);
+ debug(0, 1, "storeInit: Created swap directory %s\n", path);
directory_created = 1;
}
if (zap_disk_store) {
- debug(1, "storeInit: Zapping all objects on disk storage.\n");
+ debug(0, 1, "storeInit: Zapping all objects on disk storage.\n");
/* This could be dangerous, second copy of cache can destroy the existing
* swap files of the previous cache. We may use rc file do it. */
tmpbuf[0] = '\0';
sprintf(tmpbuf, "cd %s; rm -rf log [0-9][0-9]", path);
- debug(1, "storeInit: Running '%s'\n", tmpbuf);
+ debug(0, 1, "storeInit: Running '%s'\n", tmpbuf);
system(tmpbuf);
}
}
}
swaplog_stream = fdopen(swaplog_fd, "w");
if (!swaplog_stream) {
- debug(1, "storeInit: fdopen(%d, \"w\"): %s\n", swaplog_fd, xstrerror());
+ debug(0, 1, "storeInit: fdopen(%d, \"w\"): %s\n", swaplog_fd, xstrerror());
sprintf(tmpbuf, "Cannot open a stream for swap logfile: %s\n", swaplog_file);
fatal(tmpbuf);
}
return (atoi(&s[len + 1]));
}
}
- debug(1, "parse_file_number: Could not determine the swap file number from %s.\n", s);
+ debug(0, 1, "parse_file_number: Could not determine the swap file number from %s.\n", s);
return (0);
}
e = (StoreEntry *) link_ptr;
if ((cached_curtime > e->expires) &&
(e->swap_status == SWAP_OK)) {
- debug(2, "storeMaintainSwapSpace: Expired: <TTL:%d> <URL:%s>\n",
+ debug(0, 2, "storeMaintainSwapSpace: Expired: <TTL:%d> <URL:%s>\n",
e->expires - cached_curtime, e->url);
/* just call release. don't have to check for lock status.
* storeRelease will take care of that and set a pending flag
time_t start, stop, r;
if (!ok_write_clean_log) {
- debug(1, "storeWriteCleanLog: Not currently OK to rewrite swap log.\n");
- debug(1, "storeWriteCleanLog: Operation aborted.\n");
+ debug(0, 1, "storeWriteCleanLog: Not currently OK to rewrite swap log.\n");
+ debug(0, 1, "storeWriteCleanLog: Operation aborted.\n");
return 0;
}
- debug(1, "storeWriteCleanLog: Starting...\n");
+ debug(0, 1, "storeWriteCleanLog: Starting...\n");
start = cached_curtime = time(NULL);
sprintf(clean_log, "%s/log_clean", swappath(0));
sprintf(swaplog_file, "%s/log", swappath(0));
if ((fp = fopen(clean_log, "a+")) == NULL) {
- debug(0, "storeWriteCleanLog: %s: %s", clean_log, xstrerror());
+ debug(0, 0, "storeWriteCleanLog: %s: %s", clean_log, xstrerror());
return 0;
}
for (e = storeGetFirst(); e; e = storeGetNext()) {
- debug(5, "storeWriteCleanLog: <URL:%s>\n", e->url);
+ debug(0, 5, "storeWriteCleanLog: <URL:%s>\n", e->url);
if (e->swap_file_number < 0)
continue;
if (e->swap_status != SWAP_OK)
e->object_len);
if ((++n & 0xFFF) == 0) {
cached_curtime = time(NULL);
- debug(1, " %7d lines written so far.\n", n);
+ debug(0, 1, " %7d lines written so far.\n", n);
}
}
fclose(fp);
if (file_write_unlock(swaplog_fd, swaplog_lock) != DISK_OK) {
- debug(0, "storeWriteCleanLog: Failed to unlock swaplog!\n");
- debug(0, "storeWriteCleanLog: Current swap logfile not replaced.\n");
+ debug(0, 0, "storeWriteCleanLog: Failed to unlock swaplog!\n");
+ debug(0, 0, "storeWriteCleanLog: Current swap logfile not replaced.\n");
return 0;
}
if (rename(clean_log, swaplog_file) < 0) {
- debug(0, "storeWriteCleanLog: rename failed: %s\n",
+ debug(0, 0, "storeWriteCleanLog: rename failed: %s\n",
xstrerror());
return 0;
}
stop = cached_curtime = time(NULL);
r = stop - start;
- debug(1, " Finished. Wrote %d lines.\n", n);
- debug(1, " Took %d seconds (%6.1lf lines/sec).\n",
+ debug(0, 1, " Finished. Wrote %d lines.\n", n);
+ debug(0, 1, " Took %d seconds (%6.1lf lines/sec).\n",
r > 0 ? r : 0, (double) n / (r > 0 ? r : 1));
/* touch a timestamp file */
-/* $Id: tools.cc,v 1.9 1996/03/27 05:12:40 wessels Exp $ */
+/* $Id: tools.cc,v 1.10 1996/03/27 18:15:55 wessels Exp $ */
#include "squid.h"
}
void death(sig)
- int sig;
+ int sig;
{
if (sig == SIGSEGV)
- fprintf(stderr, "FATAL: Received Segment Violation...dying.\n");
+ fprintf(stderr, "FATAL: Received Segment Violation...dying.\n");
else if (sig == SIGBUS)
- fprintf(stderr, "FATAL: Received bus error...dying.\n");
+ fprintf(stderr, "FATAL: Received bus error...dying.\n");
else
- fprintf(stderr, "FATAL: Received signal %d...dying.\n", sig);
+ fprintf(stderr, "FATAL: Received signal %d...dying.\n", sig);
signal(SIGSEGV, SIG_DFL);
signal(SIGBUS, SIG_DFL);
signal(sig, SIG_DFL);
void rotate_logs(sig)
int sig;
{
- debug(1, "rotate_logs: SIGHUP received.\n");
+ debug(0, 1, "rotate_logs: SIGHUP received.\n");
storeWriteCleanLog();
neighbors_rotate_log();
void shut_down(sig)
int sig;
{
- debug(1, "Shutting down...\n");
+ debug(0, 1, "Shutting down...\n");
storeWriteCleanLog();
PrintRusage(NULL, stderr);
- debug(0, "Harvest Cache (Version %s): Exiting due to signal %d.\n",
+ debug(0, 0, "Harvest Cache (Version %s): Exiting due to signal %d.\n",
SQUID_VERSION, sig);
exit(1);
}
fflush(stderr);
PrintRusage(NULL, stderr);
if (debug_log != stderr) {
- debug(0, "FATAL: %s\n", message);
- debug(0, "Harvest Cache (Version %s): Terminated abnormally.\n",
+ debug(0, 0, "FATAL: %s\n", message);
+ debug(0, 0, "Harvest Cache (Version %s): Terminated abnormally.\n",
SQUID_VERSION);
}
}
int pid;
if ((pid = waitpid(-1, &status, WNOHANG)) > 0)
- debug(3, "sig_child: Ate pid %d\n", pid);
+ debug(0, 3, "sig_child: Ate pid %d\n", pid);
#if defined(_SQUID_SYSV_SIGNALS_)
signal(sig, sig_child);
#else
i = 64; /* 64 is a safe default */
#endif
- debug(10, "getMaxFD set MaxFD at %d\n", i);
+ debug(0, 10, "getMaxFD set MaxFD at %d\n", i);
}
return (i);
}
if (!present) {
host[0] = '\0';
if (gethostname(host, SQUIDHOSTNAMELEN) == -1) {
- debug(1, "comm_hostname: gethostname failed: %s\n",
+ debug(0, 1, "comm_hostname: gethostname failed: %s\n",
xstrerror());
return NULL;
} else {
int err;
if ((err = unlink(s)) < 0)
if (!quiet)
- debug(1, "safeunlink: Couldn't delete %s. %s\n", s, xstrerror());
+ debug(0, 1, "safeunlink: Couldn't delete %s. %s\n", s, xstrerror());
return (err);
}
+
+/*
+ * Daemonize a process according to guidlines in "Advanced Programming
+ * For The UNIX Environment", W.R. Stevens ( Addison Wesley, 1992) - Ch. 13
+ */
+int daemonize()
+{
+ int n_openf, i;
+ pid_t pid;
+ if ((pid = fork()) < 0)
+ return -1;
+ else if (pid != 0)
+ exit(0);
+ /* Child continues */
+ setsid(); /* Become session leader */
+ n_openf = getMaxFD(); /* Close any inherited files */
+ for (i = 0; i < n_openf; i++)
+ close(i);
+ umask(0); /* Clear file mode creation mask */
+ return 0;
+}
+
+void check_suid()
+{
+ struct passwd *pwd = NULL;
+ struct group *grp = NULL;
+ if (geteuid() != 0)
+ return;
+ /* Started as a root, check suid option */
+ if (getEffectiveUser() == NULL)
+ return;
+ if ((pwd = getpwnam(getEffectiveUser())) == NULL)
+ return;
+ /* change current directory to swap space so we can get core */
+ if (chdir(swappath(0))) {
+ debug(0, 1, "Chdir Failed: Cached cannot write core file when it crash: %s\n",
+ xstrerror());
+ }
+ if (getEffectiveGroup() && (grp = getgrnam(getEffectiveGroup()))) {
+ setgid(grp->gr_gid);
+ } else {
+ setgid(pwd->pw_gid);
+ }
+ setuid(pwd->pw_uid);
+}
-/* $Id: url.cc,v 1.3 1996/03/27 01:46:28 wessels Exp $ */
+/* $Id: url.cc,v 1.4 1996/03/27 18:15:57 wessels Exp $ */
#include "squid.h"
/* discard "/head/" or "head/" from the key and get url */
return URL;
} else {
- debug(0, "Should not be here. Unknown format of the key: %s\n",
+ debug(0, 0, "Should not be here. Unknown format of the key: %s\n",
e->key);
return (NULL);
}
-/* $Id: wais.cc,v 1.9 1996/03/27 01:46:29 wessels Exp $ */
+/* $Id: wais.cc,v 1.10 1996/03/27 18:15:58 wessels Exp $ */
#include "squid.h"
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "waisReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
+ debug(0, 4, "waisReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
cached_error_entry(entry, ERR_READ_TIMEOUT);
comm_set_select_handler(fd, COMM_SELECT_READ, 0, 0);
comm_close(fd);
StoreEntry *entry = NULL;
entry = data->entry;
- debug(4, "waisLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
+ debug(0, 4, "waisLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
cached_error_entry(entry, ERR_LIFETIME_EXP);
comm_set_select_handler(fd, COMM_SELECT_READ | COMM_SELECT_WRITE, 0, 0);
comm_close(fd);
/* check if we want to defer reading */
if ((entry->mem_obj->e_current_len -
entry->mem_obj->e_lowest_offset) > WAIS_DELETE_GAP) {
- debug(3, "waisReadReply: Read deferred for Object: %s\n", entry->key);
- debug(3, " Current Gap: %d bytes\n",
+ debug(0, 3, "waisReadReply: Read deferred for Object: %s\n", entry->key);
+ debug(0, 3, " Current Gap: %d bytes\n",
entry->mem_obj->e_current_len -
entry->mem_obj->e_lowest_offset);
}
}
len = read(fd, buf, 4096);
- debug(5, "waisReadReply - fd: %d read len:%d\n", fd, len);
+ debug(0, 5, "waisReadReply - fd: %d read len:%d\n", fd, len);
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
- debug(1, "waisReadReply - error reading errno %d: %s\n",
+ debug(0, 1, "waisReadReply - error reading errno %d: %s\n",
errno, xstrerror());
if (errno == ECONNRESET) {
/* Connection reset by peer */
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(5, "waisSendComplete - fd: %d size: %d errflag: %d\n",
+ debug(0, 5, "waisSendComplete - fd: %d size: %d errflag: %d\n",
fd, size, errflag);
if (errflag) {
cached_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
int len = strlen(data->request) + 4;
char *buf;
- debug(5, "waisSendRequest - fd: %d\n", fd);
+ debug(0, 5, "waisSendRequest - fd: %d\n", fd);
if (data->type)
len += strlen(data->type);
data->mime_hdr, CR, LF);
else
sprintf(buf, "%s %s%c%c", data->type, data->request, CR, LF);
- debug(6, "waisSendRequest - buf:%s\n", buf);
+ debug(0, 6, "waisSendRequest - buf:%s\n", buf);
icpWrite(fd, buf, len, 30, waisSendComplete, data);
}
int sock, status;
WAISData *data = NULL;
- debug(3, "waisStart - url:%s, type:%s\n", url, type);
- debug(4, " header: %s\n", mime_hdr);
+ debug(0, 3, "waisStart - url:%s, type:%s\n", url, type);
+ debug(0, 4, " header: %s\n", mime_hdr);
data = (WAISData *) xcalloc(1, sizeof(WAISData));
data->entry = entry;
if (!getWaisRelayHost()) {
- debug(0, "waisStart: Failed because no relay host defined!\n");
+ debug(0, 0, "waisStart: Failed because no relay host defined!\n");
cached_error_entry(entry, ERR_NO_RELAY);
safe_free(data);
return COMM_ERROR;
/* Create socket. */
sock = comm_open(COMM_NONBLOCKING, 0, 0, url);
if (sock == COMM_ERROR) {
- debug(4, "waisStart: Failed because we're out of sockets.\n");
+ debug(0, 4, "waisStart: Failed because we're out of sockets.\n");
cached_error_entry(entry, ERR_NO_FDS);
safe_free(data);
return COMM_ERROR;
* It should be done before this route is called.
* Otherwise, we cannot check return code for connect. */
if (!ipcache_gethostbyname(data->host)) {
- debug(4, "waisstart: Called without IP entry in ipcache. OR lookup failed.\n");
+ debug(0, 4, "waisstart: Called without IP entry in ipcache. OR lookup failed.\n");
comm_close(sock);
cached_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
safe_free(data);
safe_free(data);
return COMM_ERROR;
} else {
- debug(5, "waisStart - conn %d EINPROGRESS\n", sock);
+ debug(0, 5, "waisStart - conn %d EINPROGRESS\n", sock);
}
}
/* Install connection complete handler. */