]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 5036: capital 'L's in logs when daemon queue overflows (#576)
authorDrDaveD <2129743+DrDaveD@users.noreply.github.com>
Thu, 2 Apr 2020 17:58:10 +0000 (17:58 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Mon, 13 Apr 2020 13:53:58 +0000 (01:53 +1200)
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.

src/log/ModDaemon.cc

index 774440ab87e458f810a33c7039c6d5f8950fb6e1..8679a096cf825c1e4e9de09d13bdf8a19440be48 100644 (file)
@@ -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<l_daemon_t *>(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<l_daemon_t *>(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) {