]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Wed, 1 Nov 2000 11:03:14 +0000 (11:03 +0000)
committerwessels <>
Wed, 1 Nov 2000 11:03:14 +0000 (11:03 +0000)
 - This patch is some work-in-progress for a "forward.log" that would
   log all server-side requests that get forwarded.

   This patch was previously committed with an incorrect CVS comment so
   I manually removed those revisions and re-committed the patch.

src/cf.data.pre
src/forward.cc
src/http.cc
src/main.cc
src/protos.h
src/structs.h

index 3f29f6d30ea6af4b90ea7a9e12173a9d20bad053..8614967603ff250ad2fcf30768ce5ee1a3f1ca49 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.198 2000/10/04 03:18:58 wessels Exp $
+# $Id: cf.data.pre,v 1.199 2000/11/01 04:03:14 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -3271,5 +3271,16 @@ DOC_START
        Set this to 'round-robin' as an alternative.
 DOC_END
 
+NAME: forward_log
+IFDEF: WIP_FWD_LOG
+TYPE: string
+DEFAULT: none
+LOC: Config.Log.forward
+DOC_START
+       Logs the server-side requests.
+
+       This is currently work in progress.
+DOC_END
+
 EOF
 
index 0190efad045030f1befa37498baa58652e86b042..63628285cfd6021218a3c5edcfe7eca30508998f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.74 2000/10/04 01:12:48 wessels Exp $
+ * $Id: forward.cc,v 1.75 2000/11/01 04:03:14 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -53,6 +53,11 @@ static STABH fwdAbort;
 #define MAX_FWD_STATS_IDX 9
 static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][HTTP_INVALID_HEADER + 1];
 
+#if WIP_FWD_LOG
+static void fwdLog(FwdState * fwdState);
+static Logfile *logfile = NULL;
+#endif
+
 static void
 fwdServerFree(FwdServer * fs)
 {
@@ -70,6 +75,9 @@ fwdStateFree(FwdState * fwdState)
     assert(e->mem_obj);
 #if URL_CHECKSUM_DEBUG
     assert(e->mem_obj->chksum == url_checksum(e->mem_obj->url));
+#endif
+#if WIP_FWD_LOG
+    fwdLog(fwdState);
 #endif
     if (e->store_status == STORE_PENDING) {
        if (e->mem_obj->inmem_hi == 0) {
@@ -631,6 +639,14 @@ fwdInit(void)
     cachemgrRegister("forward",
        "Request Forwarding Statistics",
        fwdStats, 0, 1);
+#if WIP_FWD_LOG
+    if (logfile)
+       (void) 0;
+    else if (NULL == Config.Log.forward)
+       (void) 0;
+    else
+       logfile = logfileOpen(Config.Log.forward, 0, 1);
+#endif
 }
 
 static void
@@ -682,3 +698,39 @@ fwdReforwardableStatus(http_status s)
     }
     /* NOTREACHED */
 }
+
+#if WIP_FWD_LOG
+void
+fwdUninit(void)
+{
+    logfileClose(logfile);
+    logfile = NULL;
+}
+
+void
+fwdLogRotate(void)
+{
+    if (logfile)
+       logfileRotate(logfile);
+}
+
+static void
+fwdLog(FwdState * fwdState)
+{
+    if (NULL == logfile)
+       return;
+    logfilePrintf(logfile, "%9d.%03d %03d %s %s\n",
+       (int) current_time.tv_sec,
+       (int) current_time.tv_usec / 1000,
+       fwdState->last_status,
+       RequestMethodStr[fwdState->request->method],
+       fwdState->request->canonical);
+}
+
+void
+fwdStatus(FwdState * fwdState, http_status s)
+{
+    fwdState->last_status = s;
+}
+
+#endif
index 8296afb171a30dfadf5310e306ef5171a57dab09..a73aec9e03a770f0dadc565dc92334e97f9e0963 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.368 2000/10/31 23:48:13 wessels Exp $
+ * $Id: http.cc,v 1.369 2000/11/01 04:03:14 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -547,6 +547,9 @@ httpReadReply(int fd, void *data)
            httpProcessReplyHeader(httpState, buf, len);
            if (httpState->reply_hdr_state == 2) {
                http_status s = entry->mem_obj->reply->sline.status;
+#if WIP_FWD_LOG
+               fwdStatus(httpState->fwd, s);
+#endif
                /*
                 * If its not a reply that we will re-forward, then
                 * allow the client to get it.
index df76c949284f50ef28026dfed3ed72dd85f92d7f..e8086c64bb3802e424c4da67925f81bc943b8a68 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.320 2000/11/01 03:58:52 wessels Exp $
+ * $Id: main.cc,v 1.321 2000/11/01 04:03:14 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -391,6 +391,9 @@ mainRotate(void)
     accessLogRotate();         /* access.log */
     useragentRotateLog();      /* useragent.log */
     refererRotateLog();                /* referer.log */
+#if WIP_FWD_LOG
+    fwdLogRotate();
+#endif
     icmpOpen();
 #if USE_DNSSERVERS
     dnsInit();
@@ -943,6 +946,9 @@ SquidShutdown(void *unused)
     storeDirSync();            /* Flush log writes */
     storeLogClose();
     accessLogClose();
+#if WIP_FWD_LOG
+    fwdUninit();
+#endif
     storeDirSync();            /* Flush log close */
 #if PURIFY || XMALLOC_TRACE
     storeFsDone();
index e9a0657466f945924318d65fc2f41aa6b12856e2..1605948cf379f3ae6ffa3e2dba3d9a5617659b04 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.385 2000/11/01 03:35:40 wessels Exp $
+ * $Id: protos.h,v 1.386 2000/11/01 04:03:15 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -684,6 +684,11 @@ extern void fwdComplete(FwdState * fwdState);
 extern void fwdInit(void);
 extern int fwdReforwardableStatus(http_status s);
 extern void fwdServersFree(FwdServer ** FS);
+#if WIP_FWD_LOG
+extern void fwdUninit(void);
+extern void fwdLogRotate(void);
+extern void fwdStatus(FwdState *, http_status);
+#endif
 
 extern void urnStart(request_t *, StoreEntry *);
 
index d293af4dfeeee7d23c31faba7c6650de606638f0..6738ba2e9257fe869812c04a420939de8fbce079 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.357 2000/10/31 23:48:15 wessels Exp $
+ * $Id: structs.h,v 1.358 2000/11/01 04:03:15 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -297,6 +297,9 @@ struct _SquidConfig {
 #endif
 #if USE_REFERER_LOG
        char *referer;
+#endif
+#if WIP_FWD_LOG
+       char *forward;
 #endif
        int rotateNumber;
     } Log;
@@ -1746,6 +1749,9 @@ struct _FwdState {
     ErrorState *err;
     time_t start;
     int n_tries;
+#if WIP_FWD_LOG
+    http_status last_status;
+#endif
     struct {
        unsigned int dont_retry:1;
        unsigned int ftp_pasv_failed:1;