--------------------- PatchSet 8504 Date: 2006/08/16 04:44:41 Author: adri Branch: s26_logfile_daemon Tag: (none) Log: * remove unused entry in the logfile struct * add in explicit line start/end calls which kind of replicate what logfileFlush() used to do. * move the 'eol' line command escaping logic and the line write kick into these start/end calls * disable buffered reading in logfile-daemon.c for now. The behaviour is a bit .. unpredictable. Members: src/access_log.c:1.28.2.2->1.28.2.3 src/logfile-daemon.c:1.1.2.5->1.1.2.6 src/logfile.c:1.12.2.7->1.12.2.8 src/protos.h:1.118.2.1->1.118.2.2 src/store_log.c:1.8->1.8.32.1 src/structs.h:1.126.2.4->1.126.2.5 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/access_log.c,v retrieving revision 1.28.2.2 retrieving revision 1.28.2.3 diff -u -r1.28.2.2 -r1.28.2.3 --- squid/src/access_log.c 10 Aug 2006 06:44:21 -0000 1.28.2.2 +++ squid/src/access_log.c 16 Aug 2006 04:44:41 -0000 1.28.2.3 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.28.2.2 2006/08/10 06:44:21 adri Exp $ + * $Id: access_log.c,v 1.28.2.3 2006/08/16 04:44:41 adri 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; + logfileLineStart(log->logfile); switch (log->type) { case CLF_AUTO: if (Config.onoff.common_log) @@ -1138,6 +1139,7 @@ fatalf("Unknown log format %d\n", log->type); 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.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/logfile-daemon.c 16 Aug 2006 03:39:30 -0000 1.1.2.5 +++ squid/src/logfile-daemon.c 16 Aug 2006 04:44:42 -0000 1.1.2.6 @@ -89,6 +89,7 @@ exit(1); } +#if 0 readbuf = calloc(1, LOGFILE_BUFSIZ); if (readbuf == NULL) { fprintf(stderr, "%s: Couldn't malloc read buffer: %s\n", argv[1], strerror(errno)); @@ -102,7 +103,8 @@ } else if (setvbuf(fp, readbuf, _IOFBF, LOGFILE_BUFSIZ) != 0) { fprintf(stderr, "%s: Couldn't call write setvbuf: %s\n", argv[1], strerror(errno)); } - +#endif + setbuf(stdin, NULL); setbuf(stdout, NULL); close(2); t = open("/dev/null", O_RDWR); @@ -125,10 +127,12 @@ perror("fopen"); exit(1); } +#if 0 bzero(writebuf, LOGFILE_W_BUFSIZ); if (setvbuf(fp, readbuf, _IOFBF, LOGFILE_BUFSIZ) != 0) { fprintf(stderr, "%s: Couldn't call write setvbuf: %s\n", argv[1], strerror(errno)); } +#endif break; case 'T': break; Index: squid/src/logfile.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/logfile.c,v retrieving revision 1.12.2.7 retrieving revision 1.12.2.8 diff -u -r1.12.2.7 -r1.12.2.8 --- squid/src/logfile.c 16 Aug 2006 03:34:31 -0000 1.12.2.7 +++ squid/src/logfile.c 16 Aug 2006 04:44:42 -0000 1.12.2.8 @@ -247,12 +247,6 @@ logfileNewBuffer(lf); } } - /* 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) - logfileQueueWrite(lf); - } } /* @@ -355,15 +349,13 @@ /* * This routine assumes that up to one line is written. Don't try to - * call this routine with more than one line or 'eol' won't be set - * right; thusly breaking the data format which is being written out - * to the logfile daemon. + * 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) { - char tb[2]; - #if HAVE_SYSLOG if (lf->flags.syslog) { syslog(lf->syslog_priority, "%s", (char *) buf); @@ -382,18 +374,32 @@ /* Append this data to the end buffer; create a new one if needed */ /* Are we eol? If so, prefix with our logfile command byte */ - if (lf->eol == 1) { - lf->eol = 0; - tb[0] = 'L'; - tb[1] = '\0'; - logfileAppend(lf, tb, 1); - } logfileAppend(lf, buf, len); +} - /* If the last byte in buf is \n then set eol */ - if (len > 0 && buf[len - 1] == '\n') { - lf->eol = 1; - } +void +logfileLineStart(Logfile *lf) +{ + char tb[2]; + assert(lf->eol == 1); + lf->eol = 0; + tb[0] = 'L'; + tb[1] = '\0'; + logfileAppend(lf, tb, 1); +} + +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) + logfileQueueWrite(lf); + } } void Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.118.2.1 retrieving revision 1.118.2.2 diff -u -r1.118.2.1 -r1.118.2.2 --- squid/src/protos.h 7 Aug 2006 09:30:54 -0000 1.118.2.1 +++ squid/src/protos.h 16 Aug 2006 04:44:42 -0000 1.118.2.2 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.118.2.1 2006/08/07 09:30:54 adri Exp $ + * $Id: protos.h,v 1.118.2.2 2006/08/16 04:44:42 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1320,6 +1320,8 @@ extern void logfileRotate(Logfile * lf); extern void logfileWrite(Logfile * lf, char *buf, size_t len); extern void logfileFlush(Logfile * lf); +extern void logfileLineStart(Logfile *lf); +extern void logfileLineEnd(Logfile *lf); #if STDC_HEADERS extern void logfilePrintf(Logfile * lf, const char *fmt,...) PRINTF_FORMAT_ARG2; Index: squid/src/store_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_log.c,v retrieving revision 1.8 retrieving revision 1.8.32.1 diff -u -r1.8 -r1.8.32.1 --- squid/src/store_log.c 28 Apr 2006 11:10:53 -0000 1.8 +++ squid/src/store_log.c 16 Aug 2006 04:44:42 -0000 1.8.32.1 @@ -1,6 +1,6 @@ /* - * $Id: store_log.c,v 1.8 2006/04/28 11:10:53 squidadm Exp $ + * $Id: store_log.c,v 1.8.32.1 2006/08/16 04:44:42 adri Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -69,6 +69,7 @@ * Because if we print it before the swap file number, it'll break * the existing log format. */ + logfileLineStart(storelog); logfilePrintf(storelog, "%9ld.%03d %-7s %02d %08X %s %4d %9ld %9ld %9ld %s %" PRINTF_OFF_T "/%" PRINTF_OFF_T " %s %s\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, @@ -85,8 +86,10 @@ mem->inmem_hi - mem->reply->hdr_sz, RequestMethodStr[mem->method], mem->log_url); + logfileLineEnd(storelog); } else { /* no mem object. Most RELEASE cases */ + logfileLineStart(storelog); logfilePrintf(storelog, "%9ld.%03d %-7s %02d %08X %s ? ? ? ? ?/? ?/? ? ?\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, @@ -94,6 +97,7 @@ e->swap_dirn, e->swap_filen, storeKeyText(e->hash.key)); + logfileLineEnd(storelog); } } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.126.2.4 retrieving revision 1.126.2.5 diff -u -r1.126.2.4 -r1.126.2.5 --- squid/src/structs.h 8 Aug 2006 09:25:18 -0000 1.126.2.4 +++ squid/src/structs.h 16 Aug 2006 04:44:42 -0000 1.126.2.5 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.126.2.4 2006/08/08 09:25:18 adri Exp $ + * $Id: structs.h,v 1.126.2.5 2006/08/16 04:44:42 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2422,7 +2422,6 @@ int size; int len; int written_len; - int full; dlink_node node; };