--------------------- PatchSet 8503 Date: 2006/08/16 03:39:30 Author: adri Branch: s26_logfile_daemon Tag: (none) Log: Similarly provide a larger buffer for logfile writing; cutting down on this: * read(stdin, ..) = 64k * write(logfile, ..) = 4k * write(logfile, ..) = 4k * write(logfile, ..) = 4k ... Members: src/logfile-daemon.c:1.1.2.4->1.1.2.5 Index: squid/src/logfile-daemon.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/logfile-daemon.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/logfile-daemon.c 16 Aug 2006 03:34:31 -0000 1.1.2.4 +++ squid/src/logfile-daemon.c 16 Aug 2006 03:39:30 -0000 1.1.2.5 @@ -11,9 +11,12 @@ /* parse buffer - ie, length of longest expected line */ #define LOGFILE_BUF_LEN 65536 -/* stdio read buffer */ +/* stdio read buffer - this should match its sister definition at the top of logfile.c */ #define LOGFILE_BUFSIZ 65536 +/* stdio write buffer */ +#define LOGFILE_W_BUFSIZ 65536 + int do_flush = 0; void @@ -69,7 +72,7 @@ int rotate_count = 10; int do_buffer = 0; char * readbuf; - + char * writebuf; /* Try flushing to disk every second */ signal(SIGALRM, signal_alarm); @@ -90,8 +93,16 @@ if (readbuf == NULL) { fprintf(stderr, "%s: Couldn't malloc read buffer: %s\n", argv[1], strerror(errno)); } else if (setvbuf(stdin, readbuf, _IOFBF, LOGFILE_BUFSIZ) != 0) { - fprintf(stderr, "%s: Couldn't call setvbuf: %s\n", argv[1], strerror(errno)); + fprintf(stderr, "%s: Couldn't call read setvbuf: %s\n", argv[1], strerror(errno)); + } + + writebuf = calloc(1, LOGFILE_W_BUFSIZ); + if (readbuf == NULL) { + fprintf(stderr, "%s: Couldn't malloc write buffer: %s\n", argv[1], strerror(errno)); + } else if (setvbuf(fp, readbuf, _IOFBF, LOGFILE_BUFSIZ) != 0) { + fprintf(stderr, "%s: Couldn't call write setvbuf: %s\n", argv[1], strerror(errno)); } + setbuf(stdout, NULL); close(2); t = open("/dev/null", O_RDWR); @@ -114,6 +125,10 @@ perror("fopen"); exit(1); } + 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)); + } break; case 'T': break;