--------------------- PatchSet 8609 Date: 2006/09/04 15:50:45 Author: adri Branch: s26_logfile_daemon Tag: (none) Log: Warning: this stuff doesn't compile yet Start breaking out the logfile code into a few chunks. * the logfile.c code just takes care of calling the right logfile module and will do the 'shared' bit like logfilePrintf() * move the logfile_daemon related code into logfile_mod_daemon.c what needs doing: * modify access/store log code to call logfileOpen() with the right 'type' string * modify logfileOpen() to 'know' about logfile module types! * break out the per-module stuff out of struct Logfile ; add a void * data pointer to it * write logfile_mod_syslog; logfile_mod_stdio modules * get the codebase compiling again.. Members: src/Makefile.am:1.44.2.1->1.44.2.2 src/logfile.c:1.12.2.11->1.12.2.12 src/logfile_mod_daemon.c:1.1->1.1.2.1 src/protos.h:1.118.2.4->1.118.2.5 src/structs.h:1.126.2.6->1.126.2.7 src/typedefs.h:1.39.2.1->1.39.2.2 Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.44.2.1 retrieving revision 1.44.2.2 diff -u -r1.44.2.1 -r1.44.2.2 --- squid/src/Makefile.am 8 Aug 2006 08:07:50 -0000 1.44.2.1 +++ squid/src/Makefile.am 4 Sep 2006 15:50:45 -0000 1.44.2.2 @@ -180,6 +180,7 @@ $(LEAKFINDERSOURCE) \ locrewrite.c \ logfile.c \ + logfile_mod_daemon.c \ main.c \ mem.c \ MemPool.c \ Index: squid/src/logfile.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/logfile.c,v retrieving revision 1.12.2.11 retrieving revision 1.12.2.12 diff -u -r1.12.2.11 -r1.12.2.12 --- squid/src/logfile.c 2 Sep 2006 14:12:19 -0000 1.12.2.11 +++ squid/src/logfile.c 4 Sep 2006 15:50:46 -0000 1.12.2.12 @@ -34,295 +34,26 @@ #include "squid.h" -/* How many buffers to keep before we say we've buffered too much */ -#define LOGFILE_MAXBUFS 128 - -/* Size of the logfile buffer */ -/* - * For optimal performance this should match LOGFILE_BUFSIZ in logfile-daemon.c - */ -#define LOGFILE_BUFSZ 32768 - -/* How many seconds between warnings */ -#define LOGFILE_WARN_TIME 30 - -#if HAVE_SYSLOG - -/* Define LOG_AUTHPRIV as LOG_AUTH on systems still using the old deprecated LOG_AUTH */ -#if !defined(LOG_AUTHPRIV) && defined(LOG_AUTH) -#define LOG_AUTHPRIV LOG_AUTH -#endif - -typedef struct { - const char *name; - int value; -} syslog_symbol_t; - -static int -syslog_ntoa(const char *s) -{ -#define syslog_symbol(a) #a, a - static syslog_symbol_t symbols[] = - { -#ifdef LOG_AUTHPRIV - {syslog_symbol(LOG_AUTHPRIV)}, -#endif -#ifdef LOG_DAEMON - {syslog_symbol(LOG_DAEMON)}, -#endif -#ifdef LOG_LOCAL0 - {syslog_symbol(LOG_LOCAL0)}, -#endif -#ifdef LOG_LOCAL1 - {syslog_symbol(LOG_LOCAL1)}, -#endif -#ifdef LOG_LOCAL2 - {syslog_symbol(LOG_LOCAL2)}, -#endif -#ifdef LOG_LOCAL3 - {syslog_symbol(LOG_LOCAL3)}, -#endif -#ifdef LOG_LOCAL4 - {syslog_symbol(LOG_LOCAL4)}, -#endif -#ifdef LOG_LOCAL5 - {syslog_symbol(LOG_LOCAL5)}, -#endif -#ifdef LOG_LOCAL6 - {syslog_symbol(LOG_LOCAL6)}, -#endif -#ifdef LOG_LOCAL7 - {syslog_symbol(LOG_LOCAL7)}, -#endif -#ifdef LOG_USER - {syslog_symbol(LOG_USER)}, -#endif -#ifdef LOG_ERR - {syslog_symbol(LOG_ERR)}, -#endif -#ifdef LOG_WARNING - {syslog_symbol(LOG_WARNING)}, -#endif -#ifdef LOG_NOTICE - {syslog_symbol(LOG_NOTICE)}, -#endif -#ifdef LOG_INFO - {syslog_symbol(LOG_INFO)}, -#endif -#ifdef LOG_DEBUG - {syslog_symbol(LOG_DEBUG)}, -#endif - {NULL, 0} - }; - syslog_symbol_t *p; - - for (p = symbols; p->name != NULL; ++p) - if (!strcmp(s, p->name) || !strcmp(s, p->name + 4)) - return p->value; - return 0; -} - -#define PRIORITY_MASK (LOG_ERR | LOG_WARNING | LOG_NOTICE | LOG_INFO | LOG_DEBUG) -#endif /* HAVE_SYSLOG */ - -/* Internal code */ -static void -logfileNewBuffer(Logfile * lf) -{ - logfile_buffer_t *b; - - debug(50, 5) ("logfileNewBuffer: %s: new buffer\n", lf->path); - - - b = xcalloc(1, sizeof(logfile_buffer_t)); - assert(b != NULL); - b->buf = xcalloc(1, LOGFILE_BUFSZ); - assert(b->buf != NULL); - b->size = LOGFILE_BUFSZ; - b->written_len = 0; - b->len = 0; - dlinkAddTail(b, &b->node, &lf->bufs); - lf->nbufs++; -} - -static void -logfileFreeBuffer(Logfile * lf, logfile_buffer_t * b) -{ - assert(b != NULL); - dlinkDelete(&b->node, &lf->bufs); - lf->nbufs--; - xfree(b->buf); - xfree(b); -} - -static void -logfileHandleWrite(int fd, void *data) -{ - Logfile *lf = (Logfile *) data; - int ret; - logfile_buffer_t *b; - - /* - * We'll try writing the first entry until its done - if we - * get a partial write then we'll re-schedule until its completed. - * Its naive but it'll do for now. - */ - b = lf->bufs.head->data; - assert(b != NULL); - lf->flush_pending = 0; - - ret = FD_WRITE_METHOD(lf->wfd, b->buf + b->written_len, b->len - b->written_len); - debug(50, 3) ("logfileHandleWrite: %s: write returned %d\n", lf->path, ret); - if (ret < 0) { - if (ignoreErrno(errno)) { - /* something temporary */ - goto reschedule; - } - debug(50, 1) ("logfileHandleWrite: %s: error writing (%s)\n", lf->path, xstrerror()); - /* XXX should handle this better */ - fatal("I don't handle this error well!"); - } - if (ret == 0) { - /* error? */ - debug(50, 1) ("logfileHandleWrite: %s: wrote 0 bytes?\n", lf->path); - /* XXX should handle this better */ - fatal("I don't handle this error well!"); - } - /* ret > 0, so something was written */ - b->written_len += ret; - assert(b->written_len <= b->len); - if (b->written_len == b->len) { - /* written the whole buffer! */ - logfileFreeBuffer(lf, b); - b = NULL; - } - /* Is there more to write? */ - if (lf->bufs.head == NULL) { - goto finish; - } - /* there is, so schedule more */ - - reschedule: - commSetSelect(lf->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); - lf->flush_pending = 1; - finish: - return; -} - -static void logfileAppend(Logfile * lf, const char *buf, int len); - -static void -logfileQueueWrite(Logfile * lf) -{ - if (lf->flush_pending || lf->bufs.head == NULL) { - return; - } - lf->flush_pending = 1; - if (lf->bufs.head) { - logfile_buffer_t *b = lf->bufs.head->data; - if (b->len + 2 <= b->size) - logfileAppend(lf, "F\n", 2); - } - /* Ok, schedule a write-event */ - commSetSelect(lf->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); -} - -static void -logfileAppend(Logfile * lf, const char *buf, int len) -{ - logfile_buffer_t *b; - int s; - - /* Is there a buffer? If not, create one */ - if (lf->bufs.head == NULL) { - logfileNewBuffer(lf); - } - debug(50, 3) ("logfileAppend: %s: appending %d bytes\n", lf->path, len); - /* Copy what can be copied */ - while (len > 0) { - b = lf->bufs.tail->data; - debug(50, 3) ("logfileAppend: current buffer has %d of %d bytes before append\n", b->len, b->size); - s = XMIN(len, (b->size - b->len)); - xmemcpy(b->buf + b->len, buf, s); - len = len - s; - buf = buf + s; - b->len = b->len + s; - assert(b->len <= LOGFILE_BUFSZ); - assert(len >= 0); - if (len > 0) { - logfileNewBuffer(lf); - } - } -} - -/* - * only schedule a flush (write) if one isn't scheduled. - */ -static void -logfileFlushEvent(void *data) -{ - Logfile *lf = (Logfile *) data; - - /* - * This might work better if we keep track of when we wrote last and only - * schedule a write if we haven't done so in the last second or two. - */ - logfileQueueWrite(lf); - eventAdd("logfileFlush", logfileFlushEvent, lf, 1.0, 1); -} - +extern int logfile_mod_daemon_open(Logfile *lf, const char *path, size_t bufsz, int fatal_flag); /* External code */ CBDATA_TYPE(Logfile); Logfile * -logfileOpen(const char *path, size_t bufsz, int fatal_flag) +logfileOpen(const char *path, const char *type, size_t bufsz, int fatal_flag) { Logfile *lf; - const char *args[5]; char *tmpbuf; CBDATA_INIT_TYPE(Logfile); lf = cbdataAlloc(Logfile); cbdataLock(lf); debug(50, 1) ("Logfile: opening log %s\n", path); xstrncpy(lf->path, path, MAXPATHLEN); - lf->eol = 1; -#if HAVE_SYSLOG - if (strcmp(path, "syslog") == 0 || strncmp(path, "syslog:", 7) == 0) { - lf->flags.syslog = 1; - lf->rfd = -1; - lf->wfd = -1; - if (path[6] != '\0') { - const char *priority = path + 7; - char *facility = (char *) strchr(priority, '|'); - if (facility) { - *facility++ = '\0'; - lf->syslog_priority |= syslog_ntoa(facility); - } - lf->syslog_priority |= syslog_ntoa(priority); - } - if ((lf->syslog_priority & PRIORITY_MASK) == 0) - lf->syslog_priority |= LOG_INFO; - } else -#endif - { - args[0] = "(logfile-daemon)"; - args[1] = path; - args[2] = NULL; - lf->pid = ipcCreate(IPC_STREAM, Config.Program.logfile_daemon, args, "logfile-daemon", &lf->rfd, &lf->wfd); - if (lf->pid < 0) - fatal("Couldn't start logfile helper"); - } - lf->nbufs = 0; - /* Queue the initial control data */ - 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); - - /* Start the flush event */ - eventAdd("logfileFlush", logfileFlushEvent, lf, 1.0, 1); + /* need to call the per-logfile-type code */ + if (! logfile_mod_daemon_open(lf, path, bufsz, fatal_flag)) { + fatalf("logfileOpen: type %s path %s: couldn't open!\n", type, path); + } if (fatal_flag) lf->flags.fatal = 1; @@ -333,11 +64,8 @@ logfileClose(Logfile * lf) { debug(50, 1) ("Logfile: closing log %s\n", lf->path); - logfileFlush(lf); - fd_close(lf->rfd); - fd_close(lf->wfd); - kill(lf->pid, SIGTERM); - eventDelete(logfileFlushEvent, lf); + lf->f_flush(lf); + lf->f_close(lf); cbdataUnlock(lf); cbdataFree(lf); } @@ -347,65 +75,26 @@ { char tb[3]; debug(50, 1) ("logfileRotate: %s\n", lf->path); - tb[0] = 'R'; - tb[1] = '\n'; - tb[2] = '\0'; - logfileAppend(lf, tb, 2); + lf->f_rotate(lf); } -/* - * This routine assumes that up to one line is written. Don't try to - * call this routine with more than one line or subsequent lines - * won't be prefixed with the command type and confuse the logging - * daemon somewhat. - */ void logfileWrite(Logfile * lf, char *buf, size_t len) { -#if HAVE_SYSLOG - if (lf->flags.syslog) { - syslog(lf->syslog_priority, "%s", (char *) buf); - return; - } -#endif - - /* Make sure the logfile buffer isn't too large */ - if (lf->nbufs > LOGFILE_MAXBUFS) { - if (lf->last_warned < squid_curtime - LOGFILE_WARN_TIME) { - lf->last_warned = squid_curtime; - debug(50, 1) ("Logfile: %s: queue is too large; some log messages have been lost.\n", lf->path); - } - return; - } - /* Append this data to the end buffer; create a new one if needed */ - /* Are we eol? If so, prefix with our logfile command byte */ - logfileAppend(lf, buf, len); + lf->f_linewrite(lf, buf, len); } void logfileLineStart(Logfile * lf) { - char tb[2]; - assert(lf->eol == 1); - lf->eol = 0; - tb[0] = 'L'; - tb[1] = '\0'; - logfileAppend(lf, tb, 1); + lf->f_linestart(lf); } void logfileLineEnd(Logfile * lf) { - logfile_buffer_t *b; - assert(lf->eol == 0); - lf->eol = 1; - /* Kick a write off if the head buffer is -full- */ - if (lf->bufs.head != NULL) { - b = lf->bufs.head->data; - if (b->node.next != NULL || !Config.onoff.buffered_logs) - logfileQueueWrite(lf); - } + lf->f_lineend(lf); } void @@ -444,15 +133,5 @@ void logfileFlush(Logfile * lf) { - if (commUnsetNonBlocking(lf->wfd)) { - debug(50, 1) ("Logfile: Couldn't set the pipe blocking for flush! You're now missing some log entries.\n"); - return; - } - while (lf->bufs.head != NULL) { - logfileHandleWrite(lf->wfd, lf); - } - if (commSetNonBlocking(lf->wfd)) { - fatalf("Logfile: %s: Couldn't set the pipe non-blocking for flush!\n", lf->path); - return; - } + lf->f_flush(lf); } --- /dev/null Wed Feb 14 01:16:58 2007 +++ squid/src/logfile_mod_daemon.c Wed Feb 14 01:17:04 2007 @@ -0,0 +1,326 @@ +/* + * $Id: logfile_mod_daemon.c,v 1.1.2.1 2006/09/04 15:50:46 adri Exp $ + * + * DEBUG: section 50 Log file handling + * AUTHOR: Duane Wessels + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" + +/* How many buffers to keep before we say we've buffered too much */ +#define LOGFILE_MAXBUFS 128 + +/* Size of the logfile buffer */ +/* + * For optimal performance this should match LOGFILE_BUFSIZ in logfile-daemon.c + */ +#define LOGFILE_BUFSZ 32768 + +/* How many seconds between warnings */ +#define LOGFILE_WARN_TIME 30 + +static LOGWRITE logfile_mod_daemon_writeline; +static LOGLINESTART logfile_mod_daemon_linestart; +static LOGLINEEND logfile_mod_daemon_lineend; +static LOGROTATE logfile_mod_daemon_rotate; +static LOGFLUSH logfile_mod_daemon_flush; +static LOGCLOSE logfile_mod_daemon_close; + +/* Internal code */ +static void +logfileNewBuffer(Logfile * lf) +{ + logfile_buffer_t *b; + + debug(50, 5) ("logfileNewBuffer: %s: new buffer\n", lf->path); + + b = xcalloc(1, sizeof(logfile_buffer_t)); + assert(b != NULL); + b->buf = xcalloc(1, LOGFILE_BUFSZ); + assert(b->buf != NULL); + b->size = LOGFILE_BUFSZ; + b->written_len = 0; + b->len = 0; + dlinkAddTail(b, &b->node, &lf->bufs); + lf->nbufs++; +} + +static void +logfileFreeBuffer(Logfile * lf, logfile_buffer_t * b) +{ + assert(b != NULL); + dlinkDelete(&b->node, &lf->bufs); + lf->nbufs--; + xfree(b->buf); + xfree(b); +} + +static void +logfileHandleWrite(int fd, void *data) +{ + Logfile *lf = (Logfile *) data; + int ret; + logfile_buffer_t *b; + + /* + * We'll try writing the first entry until its done - if we + * get a partial write then we'll re-schedule until its completed. + * Its naive but it'll do for now. + */ + b = lf->bufs.head->data; + assert(b != NULL); + lf->flush_pending = 0; + + ret = FD_WRITE_METHOD(lf->wfd, b->buf + b->written_len, b->len - b->written_len); + debug(50, 3) ("logfileHandleWrite: %s: write returned %d\n", lf->path, ret); + if (ret < 0) { + if (ignoreErrno(errno)) { + /* something temporary */ + goto reschedule; + } + debug(50, 1) ("logfileHandleWrite: %s: error writing (%s)\n", lf->path, xstrerror()); + /* XXX should handle this better */ + fatal("I don't handle this error well!"); + } + if (ret == 0) { + /* error? */ + debug(50, 1) ("logfileHandleWrite: %s: wrote 0 bytes?\n", lf->path); + /* XXX should handle this better */ + fatal("I don't handle this error well!"); + } + /* ret > 0, so something was written */ + b->written_len += ret; + assert(b->written_len <= b->len); + if (b->written_len == b->len) { + /* written the whole buffer! */ + logfileFreeBuffer(lf, b); + b = NULL; + } + /* Is there more to write? */ + if (lf->bufs.head == NULL) { + goto finish; + } + /* there is, so schedule more */ + + reschedule: + commSetSelect(lf->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); + lf->flush_pending = 1; + finish: + return; +} + +static void logfileAppend(Logfile * lf, const char *buf, int len); + +static void +logfileQueueWrite(Logfile * lf) +{ + if (lf->flush_pending || lf->bufs.head == NULL) { + return; + } + lf->flush_pending = 1; + if (lf->bufs.head) { + logfile_buffer_t *b = lf->bufs.head->data; + if (b->len + 2 <= b->size) + logfileAppend(lf, "F\n", 2); + } + /* Ok, schedule a write-event */ + commSetSelect(lf->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); +} + +static void +logfileAppend(Logfile * lf, const char *buf, int len) +{ + logfile_buffer_t *b; + int s; + + /* Is there a buffer? If not, create one */ + if (lf->bufs.head == NULL) { + logfileNewBuffer(lf); + } + debug(50, 3) ("logfileAppend: %s: appending %d bytes\n", lf->path, len); + /* Copy what can be copied */ + while (len > 0) { + b = lf->bufs.tail->data; + debug(50, 3) ("logfileAppend: current buffer has %d of %d bytes before append\n", b->len, b->size); + s = XMIN(len, (b->size - b->len)); + xmemcpy(b->buf + b->len, buf, s); + len = len - s; + buf = buf + s; + b->len = b->len + s; + assert(b->len <= LOGFILE_BUFSZ); + assert(len >= 0); + if (len > 0) { + logfileNewBuffer(lf); + } + } +} + +/* + * only schedule a flush (write) if one isn't scheduled. + */ +static void +logfileFlushEvent(void *data) +{ + Logfile *lf = (Logfile *) data; + + /* + * This might work better if we keep track of when we wrote last and only + * schedule a write if we haven't done so in the last second or two. + */ + logfileQueueWrite(lf); + eventAdd("logfileFlush", logfileFlushEvent, lf, 1.0, 1); +} + + +/* External code */ + +int +logfile_mod_daemon_open(Logfile *lf, const char *path, size_t bufsz, int fatal_flag) +{ + const char *args[5]; + char *tmpbuf; + + cbdataLock(lf); + debug(50, 1) ("Logfile Daemon: opening log %s\n", path); + lf->eol = 1; + { + args[0] = "(logfile-daemon)"; + args[1] = path; + args[2] = NULL; + lf->pid = ipcCreate(IPC_STREAM, Config.Program.logfile_daemon, args, "logfile-daemon", &lf->rfd, &lf->wfd); + if (lf->pid < 0) + fatal("Couldn't start logfile helper"); + } + lf->nbufs = 0; + + /* Queue the initial control data */ + 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); + + /* Start the flush event */ + eventAdd("logfileFlush", logfileFlushEvent, lf, 1.0, 1); + + lf->f_close = logfile_mod_daemon_close; + lf->f_linewrite = logfile_mod_daemon_writeline; + lf->f_linestart = logfile_mod_daemon_linestart; + lf->f_lineend = logfile_mod_daemon_lineend; + lf->f_flush = logfile_mod_daemon_flush; + lf->f_rotate = logfile_mod_daemon_rotate; + + return 1; +} + +static void +logfile_mod_daemon_close(Logfile * lf) +{ + debug(50, 1) ("Logfile Daemon: closing log %s\n", lf->path); + logfileFlush(lf); + fd_close(lf->rfd); + fd_close(lf->wfd); + kill(lf->pid, SIGTERM); + eventDelete(logfileFlushEvent, lf); + cbdataUnlock(lf); +} + +static void +logfile_mod_daemon_rotate(Logfile * lf) +{ + char tb[3]; + debug(50, 1) ("logfileRotate: %s\n", lf->path); + tb[0] = 'R'; + tb[1] = '\n'; + tb[2] = '\0'; + logfileAppend(lf, tb, 2); +} + +/* + * This routine assumes that up to one line is written. Don't try to + * call this routine with more than one line or subsequent lines + * won't be prefixed with the command type and confuse the logging + * daemon somewhat. + */ +static void +logfile_mod_daemon_writeline(Logfile * lf, const char *buf, size_t len) +{ + /* Make sure the logfile buffer isn't too large */ + if (lf->nbufs > LOGFILE_MAXBUFS) { + if (lf->last_warned < squid_curtime - LOGFILE_WARN_TIME) { + lf->last_warned = squid_curtime; + debug(50, 1) ("Logfile: %s: queue is too large; some log messages have been lost.\n", lf->path); + } + return; + } + /* Append this data to the end buffer; create a new one if needed */ + /* Are we eol? If so, prefix with our logfile command byte */ + logfileAppend(lf, buf, len); +} + +static void +logfile_mod_daemon_linestart(Logfile * lf) +{ + char tb[2]; + assert(lf->eol == 1); + lf->eol = 0; + tb[0] = 'L'; + tb[1] = '\0'; + logfileAppend(lf, tb, 1); +} + +static void +logfile_mod_daemon_lineend(Logfile * lf) +{ + logfile_buffer_t *b; + assert(lf->eol == 0); + lf->eol = 1; + /* Kick a write off if the head buffer is -full- */ + if (lf->bufs.head != NULL) { + b = lf->bufs.head->data; + if (b->node.next != NULL || !Config.onoff.buffered_logs) + logfileQueueWrite(lf); + } +} + +static void +logfile_mod_daemon_flush(Logfile * lf) +{ + if (commUnsetNonBlocking(lf->wfd)) { + debug(50, 1) ("Logfile Daemon: Couldn't set the pipe blocking for flush! You're now missing some log entries.\n"); + return; + } + while (lf->bufs.head != NULL) { + logfileHandleWrite(lf->wfd, lf); + } + if (commSetNonBlocking(lf->wfd)) { + fatalf("Logfile Daemon: %s: Couldn't set the pipe non-blocking for flush!\n", lf->path); + return; + } +} Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.118.2.4 retrieving revision 1.118.2.5 diff -u -r1.118.2.4 -r1.118.2.5 --- squid/src/protos.h 2 Sep 2006 14:28:30 -0000 1.118.2.4 +++ squid/src/protos.h 4 Sep 2006 15:50:46 -0000 1.118.2.5 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.118.2.4 2006/09/02 14:28:30 hno Exp $ + * $Id: protos.h,v 1.118.2.5 2006/09/04 15:50:46 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1318,7 +1318,7 @@ #endif /* logfile.c */ -extern Logfile *logfileOpen(const char *path, size_t bufsz, int); +extern Logfile *logfileOpen(const char *path, const char *type, size_t bufsz, int); extern void logfileClose(Logfile * lf); extern void logfileRotate(Logfile * lf); extern void logfileWrite(Logfile * lf, char *buf, size_t len); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.126.2.6 retrieving revision 1.126.2.7 diff -u -r1.126.2.6 -r1.126.2.7 --- squid/src/structs.h 2 Sep 2006 14:28:32 -0000 1.126.2.6 +++ squid/src/structs.h 4 Sep 2006 15:50:46 -0000 1.126.2.7 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.126.2.6 2006/09/02 14:28:32 hno Exp $ + * $Id: structs.h,v 1.126.2.7 2006/09/04 15:50:46 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2440,6 +2440,13 @@ } flags; int syslog_priority; int flush_pending; + + LOGLINESTART * f_linestart; + LOGWRITE * f_linewrite; + LOGLINEEND * f_lineend; + LOGFLUSH * f_flush; + LOGROTATE * f_rotate; + LOGCLOSE * f_close; }; struct _logformat { Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.39.2.1 retrieving revision 1.39.2.2 diff -u -r1.39.2.1 -r1.39.2.2 --- squid/src/typedefs.h 7 Aug 2006 09:30:54 -0000 1.39.2.1 +++ squid/src/typedefs.h 4 Sep 2006 15:50:46 -0000 1.39.2.2 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.39.2.1 2006/08/07 09:30:54 adri Exp $ + * $Id: typedefs.h,v 1.39.2.2 2006/09/04 15:50:46 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -406,4 +406,12 @@ typedef struct _VaryData VaryData; typedef void STLVCB(VaryData * vary, void *cbdata); + +typedef void LOGLINESTART(Logfile *); +typedef void LOGWRITE(Logfile *, const char *, size_t len); +typedef void LOGLINEEND(Logfile *); +typedef void LOGFLUSH(Logfile *); +typedef void LOGROTATE(Logfile *); +typedef void LOGCLOSE(Logfile *); + #endif /* SQUID_TYPEDEFS_H */