--------------------- PatchSet 8591 Date: 2006/09/02 14:04:18 Author: hno Branch: s26_logfile_daemon Tag: (none) Log: Various portability and bugfixes from squid-2.6 Author: hno Make internal logfile-daemon functions static to keep gcc happy Fix logfile daemon writing of "access_log none" log files Author: serassio Portability fixes to cossdump and logfile-daemon Portability fix to logfile-daemon: HP Tru64 needs sys/stat.h Portability fix: use _PATH_DEVNULL instead of "/dev/null" Portability fix: asprintf() is not available on many platforms Portability fix: MAXPATHLEN is not available on all platforms Portability fix to logfile-daemon: handle different rename() behaviour on Windows and OS/2 Members: src/access_log.c:1.28.2.3->1.28.2.4 src/logfile-daemon.c:1.1.2.10->1.1.2.11 src/logfile.c:1.12.2.9->1.12.2.10 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/access_log.c,v retrieving revision 1.28.2.3 retrieving revision 1.28.2.4 diff -u -r1.28.2.3 -r1.28.2.4 --- squid/src/access_log.c 16 Aug 2006 04:44:41 -0000 1.28.2.3 +++ squid/src/access_log.c 2 Sep 2006 14:04:18 -0000 1.28.2.4 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.28.2.3 2006/08/16 04:44:41 adri Exp $ + * $Id: access_log.c,v 1.28.2.4 2006/09/02 14:04:18 hno Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -1116,6 +1116,7 @@ for (log = Config.Log.accesslogs; log; log = log->next) { if (checklist && log->aclList && aclMatchAclList(log->aclList, checklist) != 1) continue; + if (log->logfile) { logfileLineStart(log->logfile); switch (log->type) { case CLF_AUTO: @@ -1140,6 +1141,7 @@ break; } logfileLineEnd(log->logfile); + } if (!checklist) break; } Index: squid/src/logfile-daemon.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/logfile-daemon.c,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/logfile-daemon.c 2 Sep 2006 13:56:29 -0000 1.1.2.10 +++ squid/src/logfile-daemon.c 2 Sep 2006 14:04:18 -0000 1.1.2.11 @@ -1,25 +1,58 @@ +#include "config.h" + +#if HAVE_STDIO_H #include +#endif +#if HAVE_STDLIB_H #include +#endif +#if HAVE_UNISTD_H #include +#endif +#if HAVE_FCNTL_H #include +#endif +#if HAVE_ASSERT_H #include +#endif +#if HAVE_SYS_PARAM_H #include +#endif +#if HAVE_SYS_STAT_H +#include +#endif +#if HAVE_SIGNAL_H #include +#endif +#if HAVE_ERRNO_H #include +#endif +#if HAVE_STRING_H #include +#endif +#if HAVE_PATHS_H +#include +#endif + +#include "defines.h" + +#define SQUID_MAXPATHLEN 256 +#ifndef MAXPATHLEN +#define MAXPATHLEN SQUID_MAXPATHLEN +#endif /* parse buffer - ie, length of longest expected line */ #define LOGFILE_BUF_LEN 65536 int do_flush = 0; -void +static void signal_alarm(int unused) { do_flush = 1; } -void +static void rotate(const char *path, int rotate_count) { #ifdef S_ISREG @@ -39,10 +72,16 @@ i--; snprintf(from, MAXPATHLEN, "%s.%d", path, i - 1); snprintf(to, MAXPATHLEN, "%s.%d", path, i); +#if defined(_SQUID_OS2_) || defined(_SQUID_WIN32_) + remove(to); +#endif rename(from, to); } if (rotate_count > 0) { snprintf(to, MAXPATHLEN, "%s.%d", path, 0); +#if defined(_SQUID_OS2_) || defined(_SQUID_WIN32_) + remove(to); +#endif rename(path, to); } } @@ -81,7 +120,7 @@ } setbuf(stdout, NULL); close(2); - t = open("/dev/null", O_RDWR); + t = open(_PATH_DEVNULL, O_RDWR); assert(t > -1); dup2(t, 2); Index: squid/src/logfile.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/logfile.c,v retrieving revision 1.12.2.9 retrieving revision 1.12.2.10 diff -u -r1.12.2.9 -r1.12.2.10 --- squid/src/logfile.c 2 Sep 2006 13:56:29 -0000 1.12.2.9 +++ squid/src/logfile.c 2 Sep 2006 14:04:18 -0000 1.12.2.10 @@ -309,7 +309,8 @@ lf->nbufs = 0; /* Queue the initial control data */ - asprintf(&tmpbuf, "r%d\nb%d\n", Config.Log.rotateNumber, Config.onoff.buffered_logs); + tmpbuf = (char *) xmalloc(BUFSIZ); + snprintf(tmpbuf, BUFSIZ, "r%d\nb%d\n", Config.Log.rotateNumber, Config.onoff.buffered_logs); logfileAppend(lf, tmpbuf, strlen(tmpbuf)); xfree(tmpbuf);