]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Detatch debugs() from many of its dependencies
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 5 Jun 2009 23:21:59 +0000 (11:21 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 5 Jun 2009 23:21:59 +0000 (11:21 +1200)
 - makes cache.log independent of the other logging systems
 - adds debug_options rotate=N setting to override logfile_rotate
 - moves debug-specific globals and types into Debug::

TODO:
  remove remaining dependancy on shutdown flag
  polish up namespace etc for libdebug

18 files changed:
configure.in
doc/release-notes/release-3.1.sgml
src/ClientInfo.h [new file with mode: 0644]
src/Debug.h
src/Makefile.am
src/cache_cf.cc
src/cf.data.pre
src/client_db.cc
src/debug.cc
src/globals.h
src/ipc.cc
src/ipc_win32.cc
src/main.cc
src/mem.cc
src/snmp_agent.cc
src/structs.h
src/tools.cc
src/typedefs.h

index 238e774641d641089e2c1582b88b34692d8fb7e2..1258e5eb9e51f0186234558acd5cc43a05a54466 100644 (file)
@@ -2242,6 +2242,7 @@ AC_CHECK_HEADERS( \
        assert.h \
        bstring.h \
        crypt.h \
+       cstring \
        ctype.h \
        errno.h \
        execinfo.h \
index f074b9baf5db09b4cce15bc91c4007c25f6d0b9c..6e9d5e7e2a40451aed0936705ce4db7dbfbd6645 100644 (file)
@@ -879,6 +879,10 @@ NOCOMMENT_START
                  on error pages if used.
        </verb>
 
+       <tag>debug_options rotate=</tag>
+       <p>New parameter rotate=N to control number of cache.log rotations independent of other logs.
+
+
         <tag>external_acl_type</tag>
         <p>New options 'ipv4' and 'ipv6' are added to set the IPv4/v6 protocol between squid and its helpers.
            Please be aware of some limits to these options. These options only affet the transport protocol used
@@ -957,6 +961,9 @@ NOCOMMENT_START
        <tag>https_port intercept sslbump connection-auth[=on|off]</tag>
        <p>New port options. see http_port.
 
+       <tag>logfile_rotate</tag>
+       <p>No longer controls cache.log rotation. Use debug_options rotate=N instead.
+
        <tag>maximum_object_size_in_memory</tag>
        <p>Default size limit increased to 512KB.
 
@@ -1024,7 +1031,6 @@ refresh_pattern .                    0   20%     4320
        <p>Method names now accepted. Replacing the old magic numbers.
           '1' becomes 'gre' and '2' becomes 'l2'
 
-
 </descrip>
 
 
diff --git a/src/ClientInfo.h b/src/ClientInfo.h
new file mode 100644 (file)
index 0000000..c0d728e
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SQUID__SRC_CLIENTINFO_H
+#define SQUID__SRC_CLIENTINFO_H
+
+#include "ip/IpAddress.h"
+#include "hash.h"
+#include "enums.h"
+#include "typedefs.h"
+
+class ClientInfo {
+public:
+    hash_link hash;             /* must be first */
+
+    IpAddress addr;
+
+    struct {
+        int result_hist[LOG_TYPE_MAX];
+        int n_requests;
+        kb_t kbytes_in;
+        kb_t kbytes_out;
+        kb_t hit_kbytes_out;
+    } Http, Icp;
+
+    struct {
+        time_t time;
+        int n_req;
+        int n_denied;
+    } cutoff;
+    int n_established;          /* number of current established connections */
+    time_t last_seen;
+};
+
+#endif
index 96a78355e9aa28929571f5e0117865c6f55dc8d5..c77184cbc7a18326a0e2a98c84ab5b7b993c4ab5 100644 (file)
@@ -51,6 +51,9 @@
 #define assert(EX)  ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
 #endif
 
+/* context-based debugging, the actual type is subject to change */
+typedef int Ctx;
+
 /* defined debug section limits */
 #define MAX_DEBUG_SECTIONS 100
 
@@ -64,8 +67,15 @@ class Debug
 {
 
 public:
+    static char *debugOptions;
+    static char *cache_log;
+    static int rotateNumber;
     static int Levels[MAX_DEBUG_SECTIONS];
     static int level;
+    static int override_X;
+    static int log_stderr;
+    static bool log_syslog;
+
     static std::ostream &getDebugOut();
     static void finishDebug();
     static void parseOptions(char const *);
index 53d25e0f38601ebe636395eadeca9283bbb46add..ee0eecf2b6da6f93d5c4605ce6a8281630ee16a7 100644 (file)
@@ -313,8 +313,10 @@ squid_SOURCES = \
        client_side_reply.h \
        client_side_request.cc \
        client_side_request.h \
+       ClientInfo.h \
        BodyPipe.cc \
        BodyPipe.h \
+       ClientInfo.h \
        ClientRequestContext.h \
        clientStream.cc \
        clientStream.h \
@@ -581,7 +583,9 @@ recv_announce_SOURCES = recv-announce.cc SquidNew.cc
 ## SwapDir wants ConfigOption
 ## tools.cc wants ip/libip.la
 ## client_side.cc wants ip/libip.la
+## mem.cc wants ClientInfo.h
 ufsdump_SOURCES = \
+       ClientInfo.h \
        debug.cc \
        int.cc \
        mem.cc \
@@ -884,7 +888,7 @@ tests_testAuth_SOURCES = \
        ConfigParser.cc \
        tests/stub_acl.cc tests/stub_cache_cf.cc \
        tests/stub_helper.cc cbdata.cc String.cc \
-       tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc mem.cc \
+       tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc mem.cc ClientInfo.h \
        MemBuf.cc HttpHdrContRange.cc Packer.cc HttpHdrCc.cc HttpHdrSc.cc \
        HttpHdrScTarget.cc url.cc \
        StatHist.cc HttpHdrRange.cc ETag.cc tests/stub_errorpage.cc \
@@ -939,6 +943,7 @@ tests_testAuth_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
 ##     String.cc \
 tests_testACLMaxUserIP_SOURCES= \
        cbdata.cc \
+       ClientInfo.h \
        ConfigParser.cc \
        ETag.cc \
        HttpHeader.cc \
@@ -1022,6 +1027,7 @@ tests_testCacheManager_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
@@ -1191,6 +1197,7 @@ tests_testEvent_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
@@ -1338,6 +1345,7 @@ tests_testEventLoop_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
@@ -1473,6 +1481,7 @@ tests_test_http_range_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
@@ -1626,6 +1635,7 @@ tests_testHttpRequest_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
@@ -1772,7 +1782,7 @@ STORE_TEST_SOURCES=\
        mem_node.cc \
        stmem.cc \
        tests/stub_mime.cc \
-       HttpHeaderTools.cc HttpHeader.cc mem.cc \
+       HttpHeaderTools.cc HttpHeader.cc mem.cc  ClientInfo.h \
        MemBuf.cc HttpHdrContRange.cc Packer.cc HttpHdrCc.cc HttpHdrSc.cc \
        HttpHdrScTarget.cc url.cc \
        StatHist.cc HttpHdrRange.cc ETag.cc tests/stub_errorpage.cc \
@@ -1825,9 +1835,11 @@ tests_testStore_LDFLAGS = $(LIBADD_DL)
 tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
        @SQUID_CPPUNIT_LA@
 
-# string needs mem.cc.
-# libsquid pulls in SquidConfig and children. stub them.
+## string needs mem.cc.
+## mem.cc needs ClientInfo.h
+## libsquid pulls in SquidConfig and children. stub them.
 tests_testString_SOURCES = \
+       ClientInfo.h \
        mem.cc \
        String.cc \
        tests/testMain.cc \
@@ -1975,6 +1987,7 @@ tests_testURL_SOURCES = \
        client_side.cc \
        client_side_reply.cc \
        client_side_request.cc \
+       ClientInfo.h \
        clientStream.cc \
        $(squid_COMMSOURCES) \
        ConfigOption.cc \
index db5eeb5ddd9c7e523f18e8e9c30f3938858fa05c..d08e93708b6ada6b6839f62d6b223f3395295610 100644 (file)
@@ -403,7 +403,7 @@ parseConfigFile(const char *file_name)
     if (!Config.chroot_dir) {
         leave_suid();
         setUmask(Config.umask);
-        _db_init(Config.Log.log, Config.debugOptions);
+        _db_init(Debug::cache_log, Debug::debugOptions);
         enter_suid();
     }
 
@@ -426,6 +426,10 @@ configDoConfigure(void)
     memConfigure();
     /* Sanity checks */
 
+    if (Debug::rotateNumber < 0) {
+        Debug::rotateNumber = Config.Log.rotateNumber;
+    }
+
 #if SIZEOF_OFF_T <= 4
     if (Config.Store.maxObjectSize > 0x7FFF0000) {
         debugs(3, 0, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
@@ -494,9 +498,6 @@ configDoConfigure(void)
     else
         Config.appendDomainLen = 0;
 
-    safe_free(debug_options)
-    debug_options = xstrdup(Config.debugOptions);
-
     if (Config.retry.maxtries > 10)
         fatal("maximum_single_addr_tries cannot be larger than 10");
 
index d5c93dfd8dfdf4c304cdae99f205d8126e558a8f..167636e35b2ff4681f3976a6b1b085fc76b07506 100644 (file)
@@ -2396,17 +2396,6 @@ DOC_START
        logging will also not be accounted for in performance counters.
 DOC_END
 
-NAME: cache_log
-TYPE: string
-DEFAULT: none
-DEFAULT_IF_NONE: @DEFAULT_CACHE_LOG@
-LOC: Config.Log.log
-DOC_START
-       Cache logging file. This is where general information about
-       your cache's behavior goes. You can increase the amount of data
-       logged to this file with the "debug_options" tag below.
-DOC_END
-
 NAME: cache_store_log
 TYPE: string
 DEFAULT: none
@@ -2474,6 +2463,9 @@ DOC_START
        purposes, so -k rotate uses another signal.  It is best to get
        in the habit of using 'squid -k rotate' instead of 'kill -USR1
        <pid>'.
+
+       Note, from Squid-3.1 this option has no effect on the cache.log,
+       that log can be rotated separately by using debug_options
 DOC_END
 
 NAME: emulate_httpd_log
@@ -2555,19 +2547,6 @@ DOC_START
        A filename to write the process-id to.  To disable, enter "none".
 DOC_END
 
-NAME: debug_options
-TYPE: eol
-DEFAULT: ALL,1
-LOC: Config.debugOptions
-DOC_START
-       Logging options are set as section,level where each source file
-       is assigned a unique section.  Lower levels result in less
-       output,  Full debugging (level 9) can result in a very large
-       log file, so be careful.  The magic word "ALL" sets debugging
-       levels for all sections.  We recommend normally running with
-       "ALL,1".
-DOC_END
-
 NAME: log_fqdn
 COMMENT: on|off
 TYPE: onoff
@@ -2635,6 +2614,59 @@ DOC_START
        To disable, enter "none".
 DOC_END
 
+COMMENT_START
+ OPTIONS FOR TROUBLESHOOTING
+ -----------------------------------------------------------------------------
+COMMENT_END
+
+NAME: cache_log
+TYPE: string
+DEFAULT: none
+DEFAULT_IF_NONE: @DEFAULT_CACHE_LOG@
+LOC: Debug::cache_log
+DOC_START
+       Cache logging file. This is where general information about
+       your cache's behavior goes. You can increase the amount of data
+       logged to this file and how often its rotated with "debug_options"
+DOC_END
+
+NAME: debug_options
+TYPE: eol
+DEFAULT: ALL,1
+LOC: Debug::debugOptions
+DOC_START
+       Logging options are set as section,level where each source file
+       is assigned a unique section.  Lower levels result in less
+       output,  Full debugging (level 9) can result in a very large
+       log file, so be careful.
+
+       The magic word "ALL" sets debugging levels for all sections.
+       We recommend normally running with "ALL,1".
+
+       The rotate=N option can be used to keep more or less of these logs
+       than would otherwise be kept by logfile_rotate.
+       For most uses a single log should be enough to monitor current
+       events affecting Squid.
+DOC_END
+
+NAME: coredump_dir
+TYPE: string
+LOC: Config.coredump_dir
+DEFAULT: none
+DEFAULT_IF_NONE: none
+DOC_START
+       By default Squid leaves core files in the directory from where
+       it was started. If you set 'coredump_dir' to a directory
+       that exists, Squid will chdir() to that directory at startup
+       and coredump files will be left there.
+
+NOCOMMENT_START
+# Leave coredumps in the first cache dir
+coredump_dir @DEFAULT_SWAP_DIR@
+NOCOMMENT_END
+DOC_END
+
+
 COMMENT_START
  OPTIONS FOR FTP GATEWAYING
  -----------------------------------------------------------------------------
@@ -5961,23 +5993,6 @@ DOC_START
                violation.
 DOC_END
 
-NAME: coredump_dir
-TYPE: string
-LOC: Config.coredump_dir
-DEFAULT: none
-DEFAULT_IF_NONE: none
-DOC_START
-       By default Squid leaves core files in the directory from where
-       it was started. If you set 'coredump_dir' to a directory
-       that exists, Squid will chdir() to that directory at startup
-       and coredump files will be left there.
-
-NOCOMMENT_START
-# Leave coredumps in the first cache dir
-coredump_dir @DEFAULT_SWAP_DIR@
-NOCOMMENT_END
-DOC_END
-
 NAME: chroot
 TYPE: string
 LOC: Config.chroot_dir
index 954ccb3fe973ef1257d419ce8663bada240a2331..855ae0db68d6de45cdac1deff4b554fb247784f6 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id$
  *
@@ -36,6 +35,7 @@
 #include "squid.h"
 #include "event.h"
 #include "CacheManager.h"
+#include "ClientInfo.h"
 #include "SquidTime.h"
 #include "Store.h"
 
index fa471a400c62e63476530aca3d34d0dce718d5bc..b06daca1c10d957966f05e7ff63012e72f04edb1 100644 (file)
 #include "config.h"
 #include "Debug.h"
 #include "SquidTime.h"
+#include "util.h"
 
-/* for Config */
-#include "structs.h"
+/* for shutting_down flag in xassert() */
+#include "globals.h"
 
+/* cope with no squid.h */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 256
+#endif
+
+char *Debug::debugOptions = NULL;
+int Debug::override_X = 0;
+int Debug::log_stderr = -1;
+bool Debug::log_syslog = false;
 int Debug::Levels[MAX_DEBUG_SECTIONS];
 int Debug::level;
+char *Debug::cache_log = NULL;
+int Debug::rotateNumber = -1;
 FILE *debug_log = NULL;
 static char *debug_log_file = NULL;
 static int Ctx_Lock = 0;
@@ -62,7 +74,7 @@ typedef BOOL (WINAPI * PFInitializeCriticalSectionAndSpinCount) (LPCRITICAL_SECT
 void
 _db_print(const char *format,...)
 {
-    LOCAL_ARRAY(char, f, BUFSIZ);
+    char f[BUFSIZ]; f[0]='\0';
     va_list args1;
     va_list args2;
     va_list args3;
@@ -139,15 +151,13 @@ _db_print_file(const char *format, va_list args)
         ctx_print();
 
     vfprintf(debug_log, format, args);
-
-//*AYJ:*/    if (!Config.onoff.buffered_logs)
     fflush(debug_log);
 }
 
 static void
 _db_print_stderr(const char *format, va_list args)
 {
-    if (opt_debug_stderr < Debug::level)
+    if (Debug::log_stderr < Debug::level)
         return;
 
     if (debug_log == stderr)
@@ -160,15 +170,15 @@ _db_print_stderr(const char *format, va_list args)
 static void
 _db_print_syslog(const char *format, va_list args)
 {
-    LOCAL_ARRAY(char, tmpbuf, BUFSIZ);
     /* level 0,1 go to syslog */
 
     if (Debug::level > 1)
         return;
 
-    if (0 == opt_syslog_enable)
+    if (!Debug::log_syslog)
         return;
 
+    char tmpbuf[BUFSIZ];
     tmpbuf[0] = '\0';
 
     vsnprintf(tmpbuf, BUFSIZ, format, args);
@@ -177,7 +187,6 @@ _db_print_syslog(const char *format, va_list args)
 
     syslog(Debug::level == 0 ? LOG_WARNING : LOG_NOTICE, "%s", tmpbuf);
 }
-
 #endif /* HAVE_SYSLOG */
 
 static void
@@ -187,12 +196,15 @@ debugArg(const char *arg)
     int l = 0;
     int i;
 
-    if (!strncasecmp(arg, "ALL", 3)) {
+    if (!strncasecmp(arg, "rotate=", 7)) {
+        arg += 7;
+        Debug::rotateNumber = atoi(arg);
+        return;
+    } else if (!strncasecmp(arg, "ALL", 3)) {
         s = -1;
         arg += 4;
     } else {
         s = atoi(arg);
-
         while (*arg && *arg++ != ',');
     }
 
@@ -369,7 +381,8 @@ syslog_facility_names[] = {
 void
 _db_set_syslog(const char *facility)
 {
-    opt_syslog_enable = 1;
+    Debug::log_syslog = true;
+
 #ifdef LOG_LOCAL4
 #ifdef LOG_DAEMON
 
@@ -377,7 +390,7 @@ _db_set_syslog(const char *facility)
 #else
 
     syslog_facility = LOG_LOCAL4;
-#endif
+#endif /* LOG_DAEMON */
 
     if (facility) {
 
@@ -398,7 +411,7 @@ _db_set_syslog(const char *facility)
     if (facility)
         fprintf(stderr, "syslog facility type not supported on your system\n");
 
-#endif
+#endif /* LOG_LOCAL4 */
 }
 
 #endif
@@ -410,7 +423,7 @@ Debug::parseOptions(char const *options)
     char *p = NULL;
     char *s = NULL;
 
-    if (Config.onoff.debug_override_X) {
+    if (override_X) {
         debugs(0, 9, "command-line -X overrides: " << options);
         return;
     }
@@ -437,7 +450,7 @@ _db_init(const char *logfile, const char *options)
 
 #if HAVE_SYSLOG && defined(LOG_LOCAL4)
 
-    if (opt_syslog_enable)
+    if (Debug::log_syslog)
         openlog(APP_SHORTNAME, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility);
 
 #endif /* HAVE_SYSLOG */
@@ -449,42 +462,36 @@ _db_init(const char *logfile, const char *options)
 void
 _db_rotate_log(void)
 {
-    int i;
-    LOCAL_ARRAY(char, from, MAXPATHLEN);
-    LOCAL_ARRAY(char, to, MAXPATHLEN);
-#ifdef S_ISREG
-
-    struct stat sb;
-#endif
-
     if (debug_log_file == NULL)
         return;
 
 #ifdef S_ISREG
-
+    struct stat sb;
     if (stat(debug_log_file, &sb) == 0)
         if (S_ISREG(sb.st_mode) == 0)
             return;
-
 #endif
 
+    char from[MAXPATHLEN];
+    from[0] = '\0';
+
+    char to[MAXPATHLEN];
+    to[0] = '\0';
+
     /*
      * NOTE: we cannot use xrename here without having it in a
      * separate file -- tools.c has too many dependencies to be
      * used everywhere debug.c is used.
      */
     /* Rotate numbers 0 through N up one */
-    for (i = Config.Log.rotateNumber; i > 1;) {
+    for (int i = Debug::rotateNumber; i > 1;) {
         i--;
         snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1);
         snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i);
 #ifdef _SQUID_MSWIN_
-
         remove
         (to);
-
 #endif
-
         rename(from, to);
     }
 
@@ -495,25 +502,21 @@ _db_rotate_log(void)
 #ifdef _SQUID_MSWIN_
     if (debug_log != stderr)
         fclose(debug_log);
-
 #endif
     /* Rotate the current log to .0 */
-    if (Config.Log.rotateNumber > 0) {
+    if (Debug::rotateNumber > 0) {
         snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0);
 #ifdef _SQUID_MSWIN_
-
         remove
         (to);
-
 #endif
-
         rename(debug_log_file, to);
     }
 
     /* Close and reopen the log.  It may have been renamed "manually"
      * before HUP'ing us. */
     if (debug_log != stderr)
-        debugOpenLog(Config.Log.log);
+        debugOpenLog(Debug::cache_log);
 }
 
 static const char *
index 2e679e9f4f2a4605c1f06b171e2401a6f2399554..7ed98b6ac10346616ef489356102c22bfbe06343 100644 (file)
@@ -58,7 +58,6 @@ extern "C"
     extern const char *dns_error_message;      /* NULL */
     extern const char *log_tags[];
     extern char tmp_error_buf[ERROR_BUF_SZ];
-    extern char *volatile debug_options;       /* NULL */
     extern char ThisCache[RFC2181_MAXHOSTNAMELEN << 1];
     extern char ThisCache2[RFC2181_MAXHOSTNAMELEN << 1];
     extern char config_input_line[BUFSIZ];
@@ -93,14 +92,9 @@ extern "C"
 //DEAD    extern int icmp_sock;                /* -1 */
     extern int neighbors_do_private_keys;      /* 1 */
     extern int opt_catch_signals;      /* 1 */
-    extern int opt_debug_stderr;       /* -1 */
     extern int opt_foreground_rebuild; /* 0 */
     extern char *opt_forwarded_for;    /* NULL */
     extern int opt_reload_hit_only;    /* 0 */
-#if HAVE_SYSLOG
-
-    extern int opt_syslog_enable;      /* 0 */
-#endif
 
     extern int opt_udp_hit_obj;        /* 0 */
     extern int opt_create_swap_dirs;   /* 0 */
index aa699cd6b903e620e3d446bf4aebd1acae6db4d5..ca658978a0b967eba495b6524ece407bc0846175 100644 (file)
@@ -65,8 +65,8 @@ PutEnvironment()
 #if HAVE_PUTENV
     char *env_str;
     int tmp_s;
-    env_str = (char *)xcalloc((tmp_s = strlen(Config.debugOptions) + 32), 1);
-    snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Config.debugOptions);
+    env_str = (char *)xcalloc((tmp_s = strlen(Debug::debugOptions) + 32), 1);
+    snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Debug::debugOptions);
     putenv(env_str);
 #endif
 }
index bec30bf8c77bbf636cea8f701e5b9dec6167ac18..77a354a293df0fd0e4b1bc6459afa74f13342376 100644 (file)
@@ -98,8 +98,8 @@ PutEnvironment()
 #if HAVE_PUTENV
     char *env_str;
     int tmp_s;
-    env_str = (char *)xcalloc((tmp_s = strlen(Config.debugOptions) + 32), 1);
-    snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Config.debugOptions);
+    env_str = (char *)xcalloc((tmp_s = strlen(Debug::debugOptions) + 32), 1);
+    snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", Debug::debugOptions);
     putenv(env_str);
 #endif
 }
index 37ee8016ec4ff98b88ec9fbcf0dd2c9d3303b8e8..f044b0be4170d37643d1f96487db2a4e7d1d3356 100644 (file)
@@ -329,8 +329,8 @@ mainParseOptions(int argc, char *argv[])
         case 'X':
             /** \par X
              * Force full debugging */
-            Debug::parseOptions("debug_options ALL,9");
-            Config.onoff.debug_override_X = 1;
+            Debug::parseOptions("rotate=0 ALL,9");
+            Debug::override_X = 1;
             sigusr2_handle(SIGUSR2);
             break;
 
@@ -357,8 +357,8 @@ mainParseOptions(int argc, char *argv[])
 
         case 'd':
             /** \par d
-             * Set global option opt_debug_stderr to the number given follwoign the option */
-            opt_debug_stderr = atoi(optarg);
+             * Set global option Debug::log_stderr to the number given follwoign the option */
+            Debug::log_stderr = atoi(optarg);
             break;
 
         case 'f':
@@ -525,11 +525,9 @@ mainParseOptions(int argc, char *argv[])
 
         case 'z':
             /** \par z
-             * Set global option opt_debug_stderr and opt_create_swap_dirs */
-            opt_debug_stderr = 1;
-
+             * Set global option Debug::log_stderr and opt_create_swap_dirs */
+            Debug::log_stderr = 1;
             opt_create_swap_dirs = 1;
-
             break;
 
         case 'h':
@@ -715,7 +713,7 @@ mainReconfigureFinish(void *)
     setUmask(Config.umask);
     Mem::Report();
     setEffectiveUser();
-    _db_init(Config.Log.log, Config.debugOptions);
+    _db_init(Debug::cache_log, Debug::debugOptions);
     ipcache_restart();         /* clear stuck entries */
     authenticateUserCacheRestart();    /* clear stuck ACL entries */
     fqdncache_restart();       /* sigh, fqdncache too */
@@ -871,9 +869,9 @@ mainInitialize(void)
     if (icpPortNumOverride != 1)
         Config.Port.icp = (u_short) icpPortNumOverride;
 
-    _db_init(Config.Log.log, Config.debugOptions);
+    _db_init(Debug::cache_log, Debug::debugOptions);
 
-    fd_open(fileno(debug_log), FD_LOG, Config.Log.log);
+    fd_open(fileno(debug_log), FD_LOG, Debug::cache_log);
 
 #if MEM_GEN_TRACE
 
@@ -1548,7 +1546,7 @@ watch_child(char *argv[])
 
     dup2(nullfd, 0);
 
-    if (opt_debug_stderr < 0) {
+    if (Debug::log_stderr < 0) {
         dup2(nullfd, 1);
         dup2(nullfd, 2);
     }
index 5d2797ac89ed95709236bc27a53b443b8bb50812..34c462c54780cbd867403525ab8c29c9b761ed0b 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id$
  *
@@ -40,6 +39,7 @@
 
 #include "event.h"
 #include "CacheManager.h"
+#include "ClientInfo.h"
 #include "Mem.h"
 #include "memMeter.h"
 #include "Store.h"
index dfa4265e4aa3985b295ed435fab57f25476fc234..eea994aed5ea2e4cb44df4e2e28e9c8324d4ab69 100644 (file)
@@ -156,7 +156,7 @@ snmp_confFn(variable_list * Var, snint * ErrP)
     case CONF_LOG_FAC:
         Answer = snmp_var_new(Var->name, Var->name_length);
 
-        if (!(cp = Config.debugOptions))
+        if (!(cp = Debug::debugOptions))
             cp = "None";
 
         Answer->type = ASN_OCTET_STR;
index 30f8813a011297d0faf8816d21a2d437d9701607..e81dfdcfe46cbbf6224525f8ed501f0815262916 100644 (file)
@@ -248,7 +248,6 @@ struct SquidConfig {
     char *as_whois_server;
 
     struct {
-        char *log;
         char *store;
         char *swap;
 #if USE_USERAGENT_LOG
@@ -314,7 +313,6 @@ struct SquidConfig {
     } Accel;
     char *appendDomain;
     size_t appendDomainLen;
-    char *debugOptions;
     char *pidFilename;
     char *netdbFilename;
     char *mimeTablePathname;
@@ -436,7 +434,6 @@ struct SquidConfig {
         int httpd_suppress_version_string;
         int global_internal_static;
         int dns_require_A;
-        int debug_override_X;
 
 #if FOLLOW_X_FORWARDED_FOR
         int acl_uses_indirect_client;
@@ -1262,28 +1259,6 @@ struct _HttpHeaderStat {
 };
 
 
-struct _ClientInfo {
-    hash_link hash;            /* must be first */
-
-    IpAddress addr;
-
-    struct {
-        int result_hist[LOG_TYPE_MAX];
-        int n_requests;
-        kb_t kbytes_in;
-        kb_t kbytes_out;
-        kb_t hit_kbytes_out;
-    } Http, Icp;
-
-    struct {
-        time_t time;
-        int n_req;
-        int n_denied;
-    } cutoff;
-    int n_established;         /* number of current established connections */
-    time_t last_seen;
-};
-
 struct _CacheDigest {
     /* public, read-only */
     char *mask;                        /* bit mask */
index 85d3fa24c9c20123df57a975e9b89eb9799cb8b3..e83e5159a49c0ee5fb9ee2bedbc98274708fc145 100644 (file)
@@ -419,7 +419,7 @@ sigusr2_handle(int sig)
         state = 1;
     } else {
 #ifndef MEM_GEN_TRACE
-        Debug::parseOptions(Config.debugOptions);
+        Debug::parseOptions(Debug::debugOptions);
 #else
 
         log_trace_init("/tmp/squid.alloc");
@@ -444,7 +444,7 @@ fatal_common(const char *message)
 
     fprintf(debug_log, "FATAL: %s\n", message);
 
-    if (opt_debug_stderr > 0 && debug_log != stderr)
+    if (Debug::log_stderr > 0 && debug_log != stderr)
         fprintf(stderr, "FATAL: %s\n", message);
 
     fprintf(debug_log, "Squid Cache (Version %s): Terminated abnormally.\n",
index d191c3904000059fc0e2d907bfcc8404a9f4231e..474864f278685780542eebed4a3d8874ac6a76fa 100644 (file)
@@ -165,8 +165,6 @@ typedef struct _storeSwapLogData storeSwapLogData;
 
 typedef struct _StatHist StatHist;
 
-typedef struct _ClientInfo ClientInfo;
-
 typedef struct _cd_guess_stats cd_guess_stats;
 
 typedef struct _CacheDigest CacheDigest;
@@ -235,9 +233,6 @@ typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, i
 /* MD5 cache keys */
 typedef unsigned char cache_key;
 
-/* context-based debugging, the actual type is subject to change */
-typedef int Ctx;
-
 /* in case we want to change it later */
 typedef ssize_t mb_size_t;