From: wessels <> Date: Tue, 15 Jul 1997 11:34:08 +0000 (+0000) Subject: need to flush logs before forking when unbuffered_logs = 1 X-Git-Tag: SQUID_3_0_PRE1~4887 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70364f29e9dddb9dde28ef7d05724e2d03c00f24;p=thirdparty%2Fsquid.git need to flush logs before forking when unbuffered_logs = 1 --- diff --git a/src/dns.cc b/src/dns.cc index c9c6677dc9..f028a315df 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,5 +1,5 @@ /* - * $Id: dns.cc,v 1.36 1997/07/07 05:29:44 wessels Exp $ + * $Id: dns.cc,v 1.37 1997/07/15 05:34:08 wessels Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -143,6 +143,8 @@ dnsOpenServer(const char *command) return -1; } listen(cfd, 1); + /* flush or else we get dup data if unbuffered_logs is set */ + logsFlush(); if ((pid = fork()) < 0) { debug(50, 0) ("dnsOpenServer: fork: %s\n", xstrerror()); comm_close(cfd); diff --git a/src/ftp.cc b/src/ftp.cc index d5cdcead68..8d556e1e87 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.131 1997/07/14 23:44:59 wessels Exp $ + * $Id: ftp.cc,v 1.132 1997/07/15 05:34:09 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1446,7 +1446,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) char *t = NULL; StoreEntry *e = ftpState->entry; http_reply *reply = e->mem_obj->reply; - debug(0,0)("ftpAppendSuccessHeader: %s\n", ftpState->entry->url); if (EBIT_TEST(ftpState->flags, FTP_HTTP_HEADER_SENT)) return; EBIT_SET(ftpState->flags, FTP_HTTP_HEADER_SENT); diff --git a/src/globals.h b/src/globals.h index 618aec78e4..5ca29f8efa 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,5 +1,6 @@ -extern FILE *debug_log; +extern FILE *debug_log; /* NULL */ +extern FILE *cache_useragent_log; /* NULL */ extern Meta_data meta_data; extern SquidConfig Config; extern SquidConfig2 Config2; @@ -89,3 +90,4 @@ extern int fileno_stack_count; /* 0 */ #ifdef HAVE_SYSLOG extern int _db_level; #endif + diff --git a/src/icmp.cc b/src/icmp.cc index 1ee2b7d2b7..6d9c14c85b 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -1,6 +1,6 @@ /* - * $Id: icmp.cc,v 1.39 1997/07/14 03:33:38 wessels Exp $ + * $Id: icmp.cc,v 1.40 1997/07/15 05:34:10 wessels Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -266,6 +266,8 @@ icmpOpen(void) getsockname(child_sock, (struct sockaddr *) &S, &namelen); if (comm_connect_addr(icmp_sock, &S) != COMM_OK) fatal_dump(xstrerror()); + /* flush or else we get dup data if unbuffered_logs is set */ + logsFlush(); if ((pid = fork()) < 0) { debug(50, 0) ("icmpOpen: fork: %s\n", xstrerror()); comm_close(icmp_sock); diff --git a/src/main.cc b/src/main.cc index 6d222d46c9..99242184a7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,5 @@ /* - * $Id: main.cc,v 1.161 1997/07/14 23:45:02 wessels Exp $ + * $Id: main.cc,v 1.162 1997/07/15 05:34:11 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -482,6 +482,7 @@ mainInitialize(void) debug(1, 0) ("Starting Squid Cache version %s for %s...\n", version_string, CONFIG_HOST_TYPE); + debug(1, 0) ("Process ID %d\n", (int) getpid()); debug(1, 1) ("With %d file descriptors available\n", Squid_MaxFD); if (!configured_once) { diff --git a/src/protos.h b/src/protos.h index b20e2627a1..196fc080cc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -560,6 +560,7 @@ extern struct in_addr inaddrFromHostent _PARAMS((const struct hostent * hp)); extern int intAverage _PARAMS((int, int, int, int)); extern double doubleAverage _PARAMS((double, double, int, int)); extern void debug_trap _PARAMS((const char *)); +extern void logsFlush _PARAMS((void)); extern void unlinkdInit _PARAMS((void)); diff --git a/src/redirect.cc b/src/redirect.cc index 25fd2a9d03..09b97dc753 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,5 +1,5 @@ /* - * $Id: redirect.cc,v 1.44 1997/06/04 06:16:07 wessels Exp $ + * $Id: redirect.cc,v 1.45 1997/07/15 05:34:12 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -113,6 +113,8 @@ redirectCreateRedirector(const char *command) return -1; } listen(cfd, 1); + /* flush or else we get dup data if unbuffered_logs is set */ + logsFlush(); if ((pid = fork()) < 0) { debug(50, 0) ("redirect_create_redirector: fork: %s\n", xstrerror()); comm_close(cfd); diff --git a/src/tools.cc b/src/tools.cc index e3b06ad8d2..9cbe14fcf5 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.114 1997/07/14 23:45:07 wessels Exp $ + * $Id: tools.cc,v 1.115 1997/07/15 05:34:13 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -750,3 +750,12 @@ intAverage(int cur, int new, int n, int max) n = max; return (cur * (n - 1)) + new / n; } + +void +logsFlush(void) +{ + if (debug_log) + fflush(debug_log); + if (cache_useragent_log) + fflush(cache_useragent_log); +} diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 8938d33557..9cf268c8a4 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,5 +1,5 @@ /* - * $Id: unlinkd.cc,v 1.7 1997/07/07 05:29:58 wessels Exp $ + * $Id: unlinkd.cc,v 1.8 1997/07/15 05:34:14 wessels Exp $ * * DEBUG: section 43 Unlink Daemon * AUTHOR: Duane Wessels @@ -102,6 +102,8 @@ unlinkdCreate(void) wfd1 = squid_to_unlinkd[1]; rfd2 = unlinkd_to_squid[0]; wfd2 = unlinkd_to_squid[1]; + /* flush or else we get dup data if unbuffered_logs is set */ + logsFlush(); if ((pid = fork()) < 0) { debug(50, 0) ("unlinkdCreate: fork: %s\n", xstrerror()); close(rfd1); diff --git a/src/useragent.cc b/src/useragent.cc index fc4cbcc077..cf15aa9267 100644 --- a/src/useragent.cc +++ b/src/useragent.cc @@ -1,6 +1,6 @@ /* - * $Id: useragent.cc,v 1.7 1997/06/04 06:16:16 wessels Exp $ + * $Id: useragent.cc,v 1.8 1997/07/15 05:34:14 wessels Exp $ * * DEBUG: section 40 User-Agent logging * AUTHOR: Joe Ramey @@ -31,8 +31,6 @@ #include "squid.h" -FILE *cache_useragent_log = NULL; - void useragentOpenLog(void) {