Hi all,

My name is Jean-Francois Levesque and I'm working for Savoir-Faire Linux, a consultant firm located in Montreal, Quebec, Canada. I'm the main developper for the iSAK project, a squid based product (http://isak.gplindustries.com/wiki/).

I'm interested in squid access log developpement. As my first developpement, I made a patch to log the redirector output with the logformat (%ro). The patch is attach to this email.

I'd really appreciate to have some feedback about this patch.

In the patch, I free some memory just before allocating the new one at redirect.c:73. Is this the right way to free the used memory? Is there a function called to free a complete AccessLogEntry object?

Thanks!

Jean-Francois
diff -uN squid-2.6.PRE2/src/access_log.c squid-2.6.PRE2-logRedirectorOutput/src/access_log.c
--- squid-2.6.PRE2/src/access_log.c	2006-06-03 17:04:53.000000000 -0400
+++ squid-2.6.PRE2-logRedirectorOutput/src/access_log.c	2006-06-13 11:52:17.000000000 -0400
@@ -339,6 +339,8 @@
     LFT_EXT_LOG,
 #endif
 
+    LFT_REDIRECTOR_OUTPUT,   /* redirector output */
+
     LFT_PERCENT			/* special string cases for escaped chars */
 } logformat_bcode_t;
 
@@ -437,6 +439,8 @@
     {"ea", LFT_EXT_LOG},
 #endif
 
+    {"ro", LFT_REDIRECTOR_OUTPUT},   /* redirector output */
+    
     {"%", LFT_PERCENT},
 
     {NULL, LFT_NONE}		/* this must be last */
@@ -656,6 +660,11 @@
 	    break;
 #endif
 
+    case LFT_REDIRECTOR_OUTPUT:
+        out = al->redirector_output;
+        quote = 0;
+        break;
+        
 	case LFT_PERCENT:
 	    out = "%";
 	    break;
diff -uN squid-2.6.PRE2/src/redirect.c squid-2.6.PRE2-logRedirectorOutput/src/redirect.c
--- squid-2.6.PRE2/src/redirect.c	2006-05-15 22:18:33.000000000 -0400
+++ squid-2.6.PRE2-logRedirectorOutput/src/redirect.c	2006-06-13 12:50:44.000000000 -0400
@@ -67,7 +67,15 @@
     valid = cbdataValid(r->data);
     cbdataUnlock(r->data);
     if (valid)
-	r->handler(r->data, reply);
+    {
+        clientHttpRequest *http = r->data;
+        *t = ' ';
+        safe_free(http->al.redirector_output);
+        http->al.redirector_output = strdup(reply);
+        *t = '\0';
+        debug(61, 5) ("redirectHandleRead valid: {%s}\n", http->al.redirector_output ? http->al.redirector_output : "<NULL>");
+        r->handler(r->data, reply);
+    }
     redirectStateFree(r);
 }

diff -uN squid-2.6.PRE2/src/structs.h squid-2.6.PRE2-logRedirectorOutput/src/structs.h
--- squid-2.6.PRE2/src/structs.h	2006-06-06 13:40:02.000000000 -0400
+++ squid-2.6.PRE2-logRedirectorOutput/src/structs.h	2006-06-13 11:15:46.000000000 -0400
@@ -1159,6 +1159,7 @@
     HierarchyLogEntry hier;
     HttpReply *reply;
     request_t *request;
+    const char *redirector_output;
 };
 
 struct _clientHttpRequest {

Reply via email to