Revision: 14733
Author: adrian.chadd
Date: Sun Jul 11 16:49:18 2010
Log: Begin trying to sort out the horrible mess that is AccessLogEntry.
The motivation here is to have Init and Done functions which correctly
call sqinet_init() / sqinet_done(). This is proving to be slightly more
difficult than it should be because of how AccessLogEntry is used
(ie, as a dumping ground for random bits of logging related information
which is also somewhat used elsewhere.)
This first commit includes IPv6-savvy address assignment API additions
but it in particular tries to define some semblence of an "object
lifecycle." There's plenty of ugly direct frobbing of AccessLogEntry
internals by various places in the code - this will have to be teased
apart at some point in the near future.
http://code.google.com/p/lusca-cache/source/detail?r=14733
Modified:
/playpen/LUSCA_HEAD_ipv6/src/access_log.c
/playpen/LUSCA_HEAD_ipv6/src/client_side.c
/playpen/LUSCA_HEAD_ipv6/src/client_side_async_refresh.c
/playpen/LUSCA_HEAD_ipv6/src/client_side_request_parse.c
/playpen/LUSCA_HEAD_ipv6/src/icp_v2.c
/playpen/LUSCA_HEAD_ipv6/src/protos.h
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/access_log.c Sun Jul 4 06:56:53 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/access_log.c Sun Jul 11 16:49:18 2010
@@ -1494,3 +1494,83 @@
}
#endif
+
+/*
+ * AccessLogEntry related routines
+ */
+void
+accessLogEntryInit(AccessLogEntry *al)
+{
+ memset(al, '\0', sizeof(*al));
+}
+
+/*
+ * This is used by httpRequestLog in src/client_side.c . It resets part of
the
+ * AccessLogEntry in preparation for a subsequent request. It should
really be
+ * replaced with a Done/Init pair but the client-side code uses http->al as
+ * a container for some variables which it likely shouldn't.
+ *
+ * It's quite likely that further variables should also be reset but this
is
+ * all that httpRequestLog() did.
+ */
+void
+accessLogEntryClearHack(AccessLogEntry *al)
+{
+ safe_free(al->headers.request);
+ safe_free(al->headers.reply);
+ safe_free(al->cache.authuser);
+ al->request = NULL;
+}
+
+void
+accessLogEntryDone(AccessLogEntry *al)
+{
+ safe_free(al->headers.request);
+ safe_free(al->headers.reply);
+ safe_free(al->cache.authuser);
+ safe_free(al->headers.request);
+ safe_free(al->headers.reply);
+ safe_free(al->cache.authuser);
+ safe_free(al->ext_refresh);
+ /* al->url is just a pointer */
+ /* al->http.content_type is just a pointer */
+ /* al->cache.rfc931 is just a pointer */
+ /* al->cache.ssluser is just a pointer */
+
+ al->request = NULL; /* This is just a pointer; it isn't obtained by
requestLink() */
+ al->reply = NULL; /* This is just a pointer! No reference
counting */
+
+ /* al->hier is a local copy and should be separately free()'d here when
the time comes */
+}
+
+void
+accessLogEntrySetReplyStatus(AccessLogEntry *al, HttpReply *reply)
+{
+ al->http.code = reply->sline.status;
+ al->http.content_type = strBuf(reply->content_type);
+}
+
+void
+accessLogEntrySetClientAddr(AccessLogEntry *al, sqaddr_t *addr)
+{
+ al->cache.caddr = sqinet_get_v4_inaddr(addr, SQADDR_ASSERT_IS_V4);
+}
+
+void
+accessLogEntrySetClientAddr4(AccessLogEntry *al, struct in_addr addr)
+{
+ al->cache.caddr = addr;
+}
+
+void
+accessLogEntrySetOutAddr(AccessLogEntry *al, sqaddr_t *addr)
+{
+ al->cache.out_ip = sqinet_get_v4_inaddr(addr, SQADDR_ASSERT_IS_V4);
+}
+
+void
+accessLogEntrySetOutAddr4(AccessLogEntry *al, struct in_addr addr)
+{
+ al->cache.out_ip = addr;
+}
+
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/client_side.c Sun Jul 11 15:36:23 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/client_side.c Sun Jul 11 16:49:18 2010
@@ -272,15 +272,13 @@
if (!http->al.url)
http->al.url = urlCanonicalClean(request);
debug(33, 9) ("httpRequestLog: al.url='%s'\n", http->al.url);
- http->al.cache.out_ip = request->out_ip;
+ accessLogEntrySetOutAddr4(&http->al, request->out_ip);
if (http->reply && http->log_type != LOG_TCP_DENIED) {
- http->al.http.code = http->reply->sline.status;
- http->al.http.content_type = strBuf(http->reply->content_type);
+ accessLogEntrySetReplyStatus(&http->al, http->reply);
} else if (mem) {
- http->al.http.code = mem->reply->sline.status;
- http->al.http.content_type = strBuf(mem->reply->content_type);
- }
- http->al.cache.caddr = sqinet_get_v4_inaddr(&conn->log_addr2,
SQADDR_ASSERT_IS_V4);
+ accessLogEntrySetReplyStatus(&http->al, mem->reply);
+ }
+ accessLogEntrySetClientAddr(&http->al, &conn->log_addr2);
http->al.cache.size = http->out.size;
http->al.cache.code = http->log_type;
http->al.cache.msec = tvSubMsec(http->start, current_time);
@@ -325,10 +323,7 @@
clientdbUpdate6(&conn->peer2, http->log_type, PROTO_HTTP,
http->out.size);
}
}
- safe_free(http->al.headers.request);
- safe_free(http->al.headers.reply);
- safe_free(http->al.cache.authuser);
- http->al.request = NULL;
+ accessLogEntryClearHack(&http->al);
}
void
@@ -386,6 +381,7 @@
httpReplyDestroy(http->reply);
http->reply = NULL;
assert(DLINK_HEAD(http->conn->reqs) != NULL);
+ accessLogEntryDone(&http->al);
/* Unlink us from the clients request list */
dlinkDelete(&http->node, &http->conn->reqs);
dlinkDelete(&http->active, &ClientActiveRequests);
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/client_side_async_refresh.c Sun Jul 4
06:56:53 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/client_side_async_refresh.c Sun Jul 11
16:49:18 2010
@@ -26,7 +26,7 @@
static aclCheck_t *ch;
MemObject *mem = async->entry->mem_obj;
request_t *request = async->request;
- memset(&al, 0, sizeof(al));
+ accessLogEntryInit(&al);
al.icp.opcode = ICP_INVALID;
al.url = mem->url;
debug(33, 9) ("clientAsyncDone: url='%s'\n", al.url);
@@ -79,9 +79,7 @@
storeUnlockObject(async->entry);
storeUnlockObject(async->old_entry);
requestUnlink(async->request);
- safe_free(al.headers.request);
- safe_free(al.headers.reply);
- safe_free(al.cache.authuser);
+ accessLogEntryDone(&al);
cbdataFree(async);
}
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/client_side_request_parse.c Sun Jul 11
02:47:00 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/client_side_request_parse.c Sun Jul 11
16:49:18 2010
@@ -162,6 +162,7 @@
dlinkAdd(http, &http->active, &ClientActiveRequests);
if (method_p && !*method_p)
*method_p = urlMethodGetKnownByCode(METHOD_NONE);
+ accessLogEntryInit(&http->al);
return http;
}
@@ -423,6 +424,7 @@
/* This tries to back out what is done above */
dlinkDelete(&http->active, &ClientActiveRequests);
safe_free(http->uri);
+ accessLogEntryDone(&http->al);
cbdataFree(http);
return parseHttpRequestAbort(conn, method_p, "error:invalid-request");
}
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/icp_v2.c Sun Jul 4 06:56:53 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/icp_v2.c Sun Jul 11 16:49:18 2010
@@ -58,14 +58,15 @@
clientdbUpdate(caddr, logcode, PROTO_ICP, len);
if (!Config.onoff.log_udp)
return;
- memset(&al, '\0', sizeof(al));
+ accessLogEntryInit(&al);
al.icp.opcode = ICP_QUERY;
al.url = url;
- al.cache.caddr = caddr;
+ accessLogEntrySetClientAddr4(&al, caddr);
al.cache.size = len;
al.cache.code = logcode;
al.cache.msec = delay;
accessLogLog(&al, NULL);
+ accessLogEntryDone(&al);
}
void
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/protos.h Sun Jul 11 02:16:20 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/protos.h Sun Jul 11 16:49:18 2010
@@ -34,6 +34,14 @@
#ifndef SQUID_PROTOS_H
#define SQUID_PROTOS_H
+extern void accessLogEntryInit(AccessLogEntry *al);
+extern void accessLogEntryDone(AccessLogEntry *al);
+extern void accessLogEntryClearHack(AccessLogEntry *al);
+extern void accessLogEntrySetReplyStatus(AccessLogEntry *al, HttpReply
*reply);
+extern void accessLogEntrySetClientAddr(AccessLogEntry *al, sqaddr_t
*addr);
+extern void accessLogEntrySetClientAddr4(AccessLogEntry *al, struct
in_addr addr);
+extern void accessLogEntrySetOutAddr(AccessLogEntry *al, sqaddr_t *addr);
+extern void accessLogEntrySetOutAddr4(AccessLogEntry *al, struct in_addr
addr);
extern void accessLogLog(AccessLogEntry *, aclCheck_t * checklist);
extern void accessLogRotate(void);
extern void accessLogClose(void);
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.