Patch for squid-2.5.STABLE1 does not work in STABLE5(4). Need help!

From: Slivarez ! <slivarez@dont-contact.us>
Date: Mon, 24 May 2004 13:25:21 +0400

patch-aa.patch makes squid write info in access.log by pieces as far as the
receipt of data but not after downloading whole file

Where are errors in this patch? Why after implementing it on STABLE5 information about file appears in access.log after downloading whole file?

patch:
*******************************************************
--- access_log.c.orig Sun Jun 16 18:25:40 2002
+++ access_log.c Mon Mar 31 11:23:03 2003
@@ -223,7 +223,11 @@
     return buf;
 }
 
+#ifdef ACLOG
+char *
+#else
 static char *
+#endif
 accessLogFormatName(const char *name)
 {
     if (NULL == name)
--- client_side.c.orig Mon Sep 23 11:04:03 2002
+++ client_side.c Mon Mar 31 14:58:13 2003
@@ -1,4 +1,3 @@
-
 /*
  * $Id: client_side.c,v 1.561.2.20 2002/09/23 04:04:03 wessels Exp $
  *
@@ -2096,6 +2096,98 @@
         kb_incr(&statCounter.client_http.kbytes_out, size);
         if (isTcpHit(http->log_type))
             kb_incr(&statCounter.client_http.hit_kbytes_out, size);
+
+#ifdef ACLOG
+ {
+ extern int acfd;
+ extern char *acfifo; /* XXX: for error handling */
+
+ if (acfd > -1) {
+ AccessLogEntry * al = &http->al;
+ const char *client = NULL;
+ char *user = NULL;
+ extern char *accessLogFormatName(const char *name);
+ char buf[0x4000];
+ int n;
+
+ ConnStateData *conn = http->conn;
+ request_t *request = http->request;
+ MemObject *mem = NULL;
+
+ if (http->entry)
+ mem = http->entry->mem_obj;
+ if (http->out.size || http->log_type) {
+ http->al.icp.opcode = ICP_INVALID;
+ http->al.url = http->log_uri;
+ if (mem) {
+ http->al.http.code = mem->reply->sline.status;
+ http->al.http.content_type =
+ strBuf(mem->reply->content_type);
+ }
+ http->al.cache.caddr = conn->log_addr;
+ http->al.cache.size = http->out.size;
+ http->al.cache.code = http->log_type;
+ http->al.cache.msec = tvSubMsec(http->start,
+ current_time);
+ if (request) {
+ Packer p;
+ MemBuf mb;
+ memBufDefInit(&mb);
+ packerToMemInit(&p, &mb);
+ httpHeaderPackInto(&request->header, &p);
+ http->al.http.method = request->method;
+ http->al.http.version = request->http_ver;
+ http->al.headers.request = xstrdup(mb.buf);
+ http->al.hier = request->hier;
+ if (request->auth_user_request) {
+ http->al.cache.authuser = xstrdup(
+ authenticateUserRequestUsername(
+ request->auth_user_request));
+ authenticateAuthUserRequestUnlock(
+ request->auth_user_request);
+ request->auth_user_request = NULL;
+ }
+ if (conn->rfc931[0])
+ http->al.cache.rfc931 = conn->rfc931;
+ packerClean(&p);
+ memBufClean(&mb);
+ }
+
+ if (Config.onoff.log_fqdn)
+ client = fqdncache_gethostbyaddr(
+ al->cache.caddr, FQDN_LOOKUP_IF_MISS);
+ if (client == NULL)
+ client = inet_ntoa(al->cache.caddr);
+
+ user = accessLogFormatName(al->cache.authuser ?
+ al->cache.authuser : al->cache.rfc931);
+ n = snprintf(buf, sizeof buf,
+ "%9d.%03d %6d %s %s/%03d %ld (+%ld) "
+ "%s %s %s%s/%s %s\n",
+ (int) current_time.tv_sec,
+ (int) current_time.tv_usec / 1000,
+ al->cache.msec,
+ client,
+ log_tags[al->cache.code],
+ al->http.code,
+ (long int) al->cache.size,
+ size,
+ al->url,
+ user && *user ? user : dash_str,
+ al->hier.ping.timedout ? "TIMEOUT_" : "",
+ hier_strings[al->hier.code],
+ al->hier.host,
+ al->http.content_type);
+
+ /* XXX: blocking write */
+ write(acfd, buf, n > sizeof buf ? sizeof buf : n);
+
+ safe_free(user);
+ }
+ } /* if */
+ }
+#endif
+
     }
 #if SIZEOF_SIZE_T == 4
     if (http->out.size > 0x7FFF0000) {
--- main.c.orig Mon Mar 31 14:10:38 2003
+++ main.c Mon Mar 31 15:09:48 2003
@@ -35,6 +35,11 @@
 
 #include "squid.h"
 
+#ifdef ACLOG
+int acfd = -1;
+char *acfifo = NULL;
+#endif
+
 /* for error reporting from xmalloc and friends */
 extern void (*failure_notify) (const char *);
 
@@ -95,6 +100,9 @@
         " -s Enable logging to syslog.\n"
         " -u port Specify ICP port number (default: %d), disable with 0.\n"
         " -v Print version.\n"
+#ifdef ACLOG
+ " -x fifo Print account log to fifo. default: /dev/null :))\n"
+#endif
         " -z Create swap directories\n"
         " -C Do not catch fatal signals.\n"
         " -D Disable initial DNS tests.\n"
@@ -115,7 +123,12 @@
     extern char *optarg;
     int c;
 
- while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) {
+ while ((c = getopt(argc, argv,
+ "CDFNRSVYXa:d:f:hk:m::su:v"
+#ifdef ACLOG
+ "x:"
+#endif
+ "z?")) != -1) {
         switch (c) {
         case 'C':
             opt_catch_signals = 0;
@@ -222,6 +235,11 @@
             printf("Squid Cache: Version %s\nconfigure options: %s\n", version_string, SQUID_CONFIGURE_OPTIONS);
             exit(0);
             /* NOTREACHED */
+#ifdef ACLOG
+ case 'x':
+ acfifo = optarg;
+ break;
+#endif
         case 'z':
             opt_create_swap_dirs = 1;
             break;
@@ -571,6 +589,22 @@
         eventAdd("ipcache_purgelru", ipcache_purgelru, NULL, 10.0, 1);
         eventAdd("fqdncache_purgelru", fqdncache_purgelru, NULL, 15.0, 1);
     }
+
+#ifdef ACLOG
+ if (!configured_once && acfifo)
+ for (;;) {
+ if ((acfd = open(acfifo, O_WRONLY)) < 0) {
+ if (errno == EINTR)
+ continue;
+ if (errno == ENOENT &&
+ mkfifo(acfifo, 0644) < 0)
+ err(1, acfifo);
+ continue;
+ }
+ break;
+ }
+#endif
+
     configured_once = 1;
 }
*****************************************************************
end of patch
Received on Mon May 24 2004 - 03:25:26 MDT

This archive was generated by hypermail pre-2.1.9 : Mon May 31 2004 - 12:00:02 MDT