Squid logging bug fix

From: John Dilley <jad@dont-contact.us>
Date: Fri, 21 Aug 1998 09:27:20 -0700

Squid-lovers,

        Enclosed below is information on a defect found and fixed by our
summer student, Godfrey Tan from UCB, in the Squid 1.1.20 and 1.2.beta22
releases. The fix was implemented and tested in both versions on HP-UX.

        Godfrey is heading back to school; if there are any followup
questions or comments, drop me a line. Regards,

                             -- jad --
                          John Dilley <jad@hpl.hp.com>

/*
 * A Bug Fix to the storeLog Function of Squid
 * Godfrey Tan
 * @GT
 */

        In both versions of Squid, 1.2.20 and 1.2.beta22, the storeLog
method failed to record the information of released objects properly. An
object released by the storeRelease method was recorded in store.log
only if the object had not been purged from memory. In case the object
was purged from the memory (storePurgeMem) before storeRelease was
called, "mem" field of the storeEntry structure of that object would be
set to NULL. As a result, the storeLog function would not record any
information since it required information from "mem" field of the
storeEntry structure. A fix was made to the storeLog function in both
versions of Squid. The correctness of the bug fix was only verified in
Squid 1.1.20 (in Squid 1.2.beta22 the swap.log file is binary but the
store.log looked correct).

A Fix to Squid 1.1.20
        The following code must be added to "storeLog" in store.c.

if (mem == NULL) { /* Line 462 in the original copy of store.c. */
        if (tag == STORE_LOG_RELEASE) { /* BUG_FIX */
                sprintf(logmsg, "%9d.%03d %-7s %4d %9d %9d %9d %s %d/%d %s %s\n",
                 (int) current_time.tv_sec,
                (int) current_time.tv_usec / 1000,
                storeLogTags[tag],
                -1,
                 -1,
                 -1,
                 -1,
                 "unknown_content_type",
                -1,
                -1,
                RequestMethodStr[e->method],
                 e->url);
                file_write(storelog_fd,
                xstrdup(logmsg),
                 strlen(logmsg),
                 NULL,
                 NULL,
                 xfree); /* End of BUG_FIX */
        }
        return;
}

A Fix to Squid 1.2.beta22
        The following code must be added to "storeLog" in store_log.c.

if (mem == NULL) { /* Line 22 in the original copy of store_log.c. */
               if (tag == STORE_LOG_RELEASE) { /*BUG_FIX */
                 memBufDefInit(&mb);
                 memBufPrintf(&mb, "%9d.%03d %-7s %08X %4d %9d %9d %9d %s %d/%d %s %s\n",
                      (int) current_time.tv_sec,
                      (int) current_time.tv_usec / 1000,
                      storeLogTags[tag],
                      e->swap_file_number,
                      -1,
                      -1,
                      -1,
                      -1,
                      "unknown_content_type",
                      -1,
                      -1,
                      "unknown_method",
                      "unknown_url");
                 file_write_mbuf(storelog_fd, -1, mb, NULL, NULL);
               }
        return;
}
Received on Tue Jul 29 2003 - 13:15:52 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:51 MST