From: DrDaveD <2129743+DrDaveD@users.noreply.github.com> Date: Thu, 2 Apr 2020 17:58:10 +0000 (+0000) Subject: Bug 5036: capital 'L's in logs when daemon queue overflows (#576) X-Git-Tag: SQUID_5_0_2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07e717b1ddd4bbf92bb24ea84a257fd265fd15a0;p=thirdparty%2Fsquid.git Bug 5036: capital 'L's in logs when daemon queue overflows (#576) Varying number of capital 'L's have been observed in access logs written by the daemon module. The 'L's corresponded with the cache log message: "queue is too large; some log messages have been lost." This was caused by the fact that the 'L' command byte was buffered even when the queue was too large to accept messages. Deferring buffering the command byte until just before the message itself is buffered. --- diff --git a/src/log/ModDaemon.cc b/src/log/ModDaemon.cc index 774440ab87..8679a096cf 100644 --- a/src/log/ModDaemon.cc +++ b/src/log/ModDaemon.cc @@ -298,8 +298,14 @@ logfile_mod_daemon_writeline(Logfile * lf, const char *buf, size_t len) } 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 */ + if (ll->eol == 1) { + logfile_mod_daemon_append(lf, "L", 1); + ll->eol = 0; + } + + /* Append this data to the end buffer; create a new one if needed */ logfile_mod_daemon_append(lf, buf, len); } @@ -307,12 +313,8 @@ static void logfile_mod_daemon_linestart(Logfile * lf) { l_daemon_t *ll = static_cast(lf->data); - char tb[2]; assert(ll->eol == 1); - ll->eol = 0; - tb[0] = 'L'; - tb[1] = '\0'; - logfile_mod_daemon_append(lf, tb, 1); + // logfile_mod_daemon_writeline() sends the starting command } static void @@ -320,7 +322,8 @@ logfile_mod_daemon_lineend(Logfile * lf) { l_daemon_t *ll = static_cast(lf->data); logfile_buffer_t *b; - assert(ll->eol == 0); + if (ll->eol == 1) // logfile_mod_daemon_writeline() wrote nothing + return; ll->eol = 1; /* Kick a write off if the head buffer is -full- */ if (ll->bufs.head != NULL) {