current errlog.c,1.128,1.129
Fabian Keil <[email protected]> Mon, 29 May 2017 10:06:59 +0000
| Newsgroups | gmane.comp.web.privoxy.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28433
Modified Files:
errlog.c
Log Message:
log_error(): Reduce the mutex-protected area
... by not using a heap-allocated buffer that is
shared between all threads.
This increases performance and reduces the latency
with verbose debug settings and multiple concurrent
connections.
Sponsored by: Robert Klemme
Index: errlog.c
===================================================================
RCS file: /cvsroot/ijbswa/current/errlog.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -C2 -d -r1.128 -r1.129
*** errlog.c 29 May 2017 10:06:09 -0000 1.128
--- errlog.c 29 May 2017 10:06:57 -0000 1.129
***************
*** 675,680 ****
{
va_list ap;
! char *outbuf = NULL;
! static char *outbuf_save = NULL;
char tempbuf[LOG_BUFFER_SIZE];
size_t length = 0;
--- 675,679 ----
{
va_list ap;
! char outbuf[LOG_BUFFER_SIZE+1];
char tempbuf[LOG_BUFFER_SIZE];
size_t length = 0;
***************
*** 682,690 ****
long thread_id;
char timestamp[30];
- /*
- * XXX: Make this a config option,
- * why else do we allocate instead of using
- * an array?
- */
const size_t log_buffer_size = LOG_BUFFER_SIZE;
--- 681,684 ----
***************
*** 729,746 ****
get_log_timestamp(timestamp, sizeof(timestamp));
- /* protect the whole function because of the static buffer (outbuf) */
- lock_logfile();
-
- if (NULL == outbuf_save)
- {
- outbuf_save = zalloc_or_die(log_buffer_size + 1); /* +1 for paranoia */
- }
- outbuf = outbuf_save;
-
/*
* Memsetting the whole buffer to zero (in theory)
* makes things easier later on.
*/
! memset(outbuf, 0, log_buffer_size);
/* Add prefix for everything but Common Log Format messages */
--- 723,731 ----
get_log_timestamp(timestamp, sizeof(timestamp));
/*
* Memsetting the whole buffer to zero (in theory)
* makes things easier later on.
*/
! memset(outbuf, 0, sizeof(outbuf));
/* Add prefix for everything but Common Log Format messages */
***************
*** 956,967 ****
#endif
if (loglevel == LOG_LEVEL_FATAL)
{
! fatal_error(outbuf_save);
/* Never get here */
}
if (logfp != NULL)
{
! fputs(outbuf_save, logfp);
}
--- 941,954 ----
#endif
+ lock_logfile();
+
if (loglevel == LOG_LEVEL_FATAL)
{
! fatal_error(outbuf);
/* Never get here */
}
if (logfp != NULL)
{
! fputs(outbuf, logfp);
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot