From: wessels <> Date: Wed, 1 Nov 2000 11:03:14 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1797 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=225644d76d8519720b9c39d531e3216a7b886d3f;p=thirdparty%2Fsquid.git DW: - 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. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index 3f29f6d30e..8614967603 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/forward.cc b/src/forward.cc index 0190efad04..63628285cf 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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 diff --git a/src/http.cc b/src/http.cc index 8296afb171..a73aec9e03 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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. diff --git a/src/main.cc b/src/main.cc index df76c94928..e8086c64bb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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(); diff --git a/src/protos.h b/src/protos.h index e9a0657466..1605948cf3 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 *); diff --git a/src/structs.h b/src/structs.h index d293af4dfe..6738ba2e92 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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;