#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.in,v 1.31 1996/07/22 16:40:19 wessels Exp $
+# $Id: Makefile.in,v 1.32 1996/07/27 07:07:41 wessels Exp $
#
# Uncomment and customize the following to suit your needs:
#
DEFAULT_DNSSERVER = $(libexecdir)/dnsserver
DEFAULT_CACHE_LOG = $(localstatedir)/logs/cache.log
DEFAULT_ACCESS_LOG = $(localstatedir)/logs/access.log
-DEFAULT_HIERARCHY_LOG = $(localstatedir)/logs/hierarchy.log
DEFAULT_STORE_LOG = $(localstatedir)/logs/store.log
DEFAULT_SWAP_DIR = $(localstatedir)/cache
-DDEFAULT_DNSSERVER=\"$(DEFAULT_DNSSERVER)\" \
-DDEFAULT_CACHE_LOG=\"$(DEFAULT_CACHE_LOG)\" \
-DDEFAULT_ACCESS_LOG=\"$(DEFAULT_ACCESS_LOG)\" \
- -DDEFAULT_HIERARCHY_LOG=\"$(DEFAULT_HIERARCHY_LOG)\" \
-DDEFAULT_STORE_LOG=\"$(DEFAULT_STORE_LOG)\" \
-DDEFAULT_SWAP_DIR=\"$(DEFAULT_SWAP_DIR)\"
s%@DEFAULT_DNSSERVER@%$(DEFAULT_DNSSERVER)%g;\
s%@DEFAULT_CACHE_LOG@%$(DEFAULT_CACHE_LOG)%g;\
s%@DEFAULT_ACCESS_LOG@%$(DEFAULT_ACCESS_LOG)%g;\
- s%@DEFAULT_HIERARCHY_LOG@%$(DEFAULT_HIERARCHY_LOG)%g;\
s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\
s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g" <$? >$@
/*
- * $Id: cache_cf.cc,v 1.66 1996/07/26 19:28:49 wessels Exp $
+ * $Id: cache_cf.cc,v 1.67 1996/07/27 07:07:41 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
#define DefaultCacheLogFile DEFAULT_CACHE_LOG
#define DefaultAccessLogFile DEFAULT_ACCESS_LOG
-#define DefaultHierarchyLogFile DEFAULT_HIERARCHY_LOG
#define DefaultStoreLogFile DEFAULT_STORE_LOG
#define DefaultLogRotateNumber 10
#define DefaultAdminEmail "webmaster"
Config.Log.access = xstrdup(token);
}
-static void parseHierachyLogLine()
-{
- char *token;
- token = strtok(NULL, w_space);
- if (token == NULL)
- self_destruct();
- safe_free(Config.Log.hierarchy);
- Config.Log.hierarchy = xstrdup(token);
-}
-
static void parseStoreLogLine()
{
char *token;
else if (!strcmp(token, "cache_access_log"))
parseAccessLogLine();
- else if (!strcmp(token, "cache_hierarchy_log"))
- parseHierachyLogLine();
-
else if (!strcmp(token, "cache_store_log"))
parseStoreLogLine();
safe_free(Config.Wais.relayHost);
safe_free(Config.Log.log);
safe_free(Config.Log.access);
- safe_free(Config.Log.hierarchy);
safe_free(Config.Log.store);
safe_free(Config.adminEmail);
safe_free(Config.effectiveUser);
Config.Port.icp = DefaultIcpPortNum;
Config.Log.log = safe_xstrdup(DefaultCacheLogFile);
Config.Log.access = safe_xstrdup(DefaultAccessLogFile);
- Config.Log.hierarchy = safe_xstrdup(DefaultHierarchyLogFile);
Config.Log.store = safe_xstrdup(DefaultStoreLogFile);
Config.Log.rotateNumber = DefaultLogRotateNumber;
Config.Program.ftpget = safe_xstrdup(DefaultFtpgetProgram);
/*
- * $Id: neighbors.cc,v 1.39 1996/07/26 21:09:37 wessels Exp $
+ * $Id: neighbors.cc,v 1.40 1996/07/27 07:07:43 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
static icp_common_t echo_hdr;
static u_short echo_port;
-FILE *cache_hierarchy_log = NULL;
-
char *hier_strings[] =
{
"NONE",
return (NULL);
}
-
-void hierarchy_log_append(entry, code, timeout, cache_host)
- StoreEntry *entry;
+void hierarchyNote(request, code, timeout, cache_host)
+ request_t *request;
hier_code code;
int timeout;
char *cache_host;
{
- char *url = entry->url;
- MemObject *mem = entry->mem_obj;
- static time_t last_time = 0;
- LOCAL_ARRAY(char, time_str, 128);
- char *s = NULL;
-
- if (!cache_hierarchy_log)
- return;
-
- if (code > HIER_MAX)
- code = HIER_MAX;
- if (mem)
- mem->request->hierarchy_code = code;
- if (mem && cache_host)
- mem->request->hierarchy_host = xstrdup(cache_host);
-
- if (Config.commonLogFormat) {
- if (squid_curtime != last_time) {
- s = mkhttpdlogtime(&squid_curtime);
- strcpy(time_str, s);
- last_time = squid_curtime;
- }
- if (cache_host) {
- fprintf(cache_hierarchy_log, "[%s] %s %s%s %s\n",
- time_str,
- url,
- timeout ? "TIMEOUT_" : "",
- hier_strings[code],
- cache_host);
- } else {
- fprintf(cache_hierarchy_log, "[%s] %s %s%s\n",
- time_str,
- url,
- timeout ? "TIMEOUT_" : "",
- hier_strings[code]);
- }
- } else {
- if (cache_host) {
- fprintf(cache_hierarchy_log, "%d.%03d %s %s%s %s\n",
- (int) current_time.tv_sec,
- (int) current_time.tv_usec / 1000,
- url,
- timeout ? "TIMEOUT_" : "",
- hier_strings[code],
- cache_host);
- } else {
- fprintf(cache_hierarchy_log, "%d.%03d %s %s%s\n",
- (int) current_time.tv_sec,
- (int) current_time.tv_usec / 1000,
- url,
- timeout ? "TIMEOUT_" : "",
- hier_strings[code]);
- }
+ if (request) {
+ request->hierarchy.code = code;
+ request->hierarchy.timeout = timeout;
+ request->hierarchy.host = xstrdup(cache_host);
}
- if (unbuffered_logs)
- fflush(cache_hierarchy_log);
}
static int edgeWouldBePinged(e, request)
friends = NULL;
}
-static void neighborsOpenLog(fname)
- char *fname;
-{
- int log_fd = -1;
- /* Close and reopen the log. It may have been renamed "manually"
- * before HUP'ing us. */
- if (cache_hierarchy_log) {
- file_close(fileno(cache_hierarchy_log));
- fclose(cache_hierarchy_log);
- cache_hierarchy_log = NULL;
- }
- if (strcmp(fname, "none") != 0) {
- log_fd = file_open(fname, NULL, O_WRONLY | O_CREAT);
- if (log_fd < 0) {
- debug(15, 0, "neighborsOpenLog: %s: %s\n", fname, xstrerror());
- } else if ((cache_hierarchy_log = fdopen(log_fd, "a")) == NULL) {
- file_close(log_fd);
- debug(15, 0, "neighborsOpenLog: %s: %s\n", fname, xstrerror());
- }
- }
- if (log_fd < 0 || cache_hierarchy_log == NULL)
- debug(15, 1, "Hierachical logging is disabled.\n");
-}
-
void neighbors_open(fd)
int fd;
{
/* if we reach here, source-ping reply is the first 'parent',
* so fetch directly from the source */
debug(15, 6, "Source is the first to respond.\n");
- hierarchy_log_append(entry,
+ hierarchyNote(entry->mem_obj->request,
HIER_SOURCE_FASTEST,
0,
fqdnFromAddr(from->sin_addr));
httpProcessReplyHeader(httpState, data, data_sz);
storeAppend(entry, data, data_sz);
storeComplete(entry);
- hierarchy_log_append(entry,
+ hierarchyNote(entry->mem_obj->request,
e->type == EDGE_PARENT ? HIER_PARENT_UDP_HIT_OBJ : HIER_SIBLING_UDP_HIT_OBJ,
0,
e->host);
if (e == NULL) {
debug(15, 1, "neighborsUdpAck: Ignoring HIT from non-neighbor\n");
} else {
- hierarchy_log_append(entry,
+ hierarchyNote(entry->mem_obj->request,
e->type == EDGE_SIBLING ? HIER_SIBLING_HIT : HIER_PARENT_HIT,
0,
e->host);
struct neighbor_cf *next = NULL;
char *me = getMyHostname();
edge *e = NULL;
- char *fname = NULL;
debug(15, 1, "neighbors_init: Initializing Neighbors...\n");
if (friends == NULL)
friends = xcalloc(1, sizeof(neighbors));
- if ((fname = Config.Log.hierarchy))
- neighborsOpenLog(fname);
-
for (t = Neighbor_cf; t; t = next) {
next = t->next;
if (!strcmp(t->host, me) && t->http_port == Config.Port.http) {
any_addr.s_addr = inet_addr("0.0.0.0");
}
-void neighbors_rotate_log()
-{
- char *fname = NULL;
- int i;
- LOCAL_ARRAY(char, from, MAXPATHLEN);
- LOCAL_ARRAY(char, to, MAXPATHLEN);
-
- if ((fname = Config.Log.hierarchy) == NULL)
- return;
-
- debug(15, 1, "neighbors_rotate_log: Rotating.\n");
-
- /* Rotate numbers 0 through N up one */
- for (i = Config.Log.rotateNumber; i > 1;) {
- i--;
- sprintf(from, "%s.%d", fname, i - 1);
- sprintf(to, "%s.%d", fname, i);
- rename(from, to);
- }
- /* Rotate the current log to .0 */
- if (Config.Log.rotateNumber > 0) {
- sprintf(to, "%s.%d", fname, 0);
- rename(fname, to);
- }
- neighborsOpenLog(fname);
-}
-
edge *neighborFindByName(name)
char *name;
{
/*
- * $Id: stat.cc,v 1.50 1996/07/26 17:18:26 wessels Exp $
+ * $Id: stat.cc,v 1.51 1996/07/27 07:07:46 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
}
-void log_append(obj, url, caddr, size, action, method, http_code, msec, ident, hier, neighbor)
+void log_append(obj, url, caddr, size, action, method, http_code, msec, ident, hierData)
cacheinfo *obj;
char *url;
struct in_addr caddr;
int http_code;
int msec;
char *ident;
- hier_code hier;
- char *neighbor;
+ struct _hierarchyLogData *hierData;
{
LOCAL_ARRAY(char, tmp, 6000); /* MAX_URL is 4096 */
int x;
static char *dash = "-";
char *client = NULL;
+ hier_code hier_code = HIER_NONE;
+ char *hier_host = dash;
+ int hier_timeout = 0;
if (Config.Log.log_fqdn)
client = fqdncache_gethostbyaddr(caddr, 0);
url = dash;
if (!ident || ident[0] == '\0')
ident = dash;
- if (!neighbor)
- neighbor = dash;
+ if (hierData) {
+ hier_code = hierData->code;
+ hier_host = hierData->host;
+ hier_timeout = hierData->timeout;
+ }
if (obj->logfile_status == LOG_ENABLE) {
if (Config.commonLogFormat)
action,
size);
else
- sprintf(tmp, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s/%s\n",
+ sprintf(tmp, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s\n",
(int) current_time.tv_sec,
(int) current_time.tv_usec / 1000,
msec,
method,
url,
ident,
- hier_strings[hier],
- neighbor);
+ hier_timeout ? "TIMEOUT_" : "",
+ hier_strings[hier_code],
+ hier_host);
x = file_write(obj->logfile_fd,
xstrdup(tmp),
strlen(tmp),