]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
optionally debug to stderr
authorwessels <>
Fri, 16 May 1997 05:33:43 +0000 (05:33 +0000)
committerwessels <>
Fri, 16 May 1997 05:33:43 +0000 (05:33 +0000)
src/debug.cc
src/main.cc

index 33b29557d5ec38820307f6a7b2fbbf99b5230e17..9525f82dbb86c29bb6ab40566b36d35c5790a829 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: debug.cc,v 1.43 1997/05/15 01:18:43 wessels Exp $
+ * $Id: debug.cc,v 1.44 1997/05/15 23:33:43 wessels Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
@@ -112,6 +112,7 @@ static char *debug_log_file = NULL;
 static int debugLevels[MAX_DEBUG_SECTIONS];
 
 static char *accessLogTime _PARAMS((time_t));
+extern int opt_debug_stderr;
 
 #ifdef __STDC__
 void
@@ -166,6 +167,8 @@ _db_print(va_alist)
     vfprintf(debug_log, f, args);
     if (unbuffered_logs)
        fflush(debug_log);
+    if (opt_debug_stderr)
+       vfprintf(stderr, f, args);
     va_end(args);
 }
 
index 7beec0601f2f6536684b1573c0a7eb5eb7cd6689..c62ce35bc6550fcc1711f7c944061669fcfce1fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.cc,v 1.146 1997/05/15 06:55:46 wessels Exp $
+ * $Id: main.cc,v 1.147 1997/05/15 23:33:43 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -124,6 +124,7 @@ int opt_udp_hit_obj = 0;    /* ask for HIT_OBJ's */
 int opt_mem_pools = 1;
 int opt_forwarded_for = 1;
 int opt_accel_uses_host = 0;
+int opt_debug_stderr = 0;
 int vhost_mode = 0;
 int Squid_MaxFD = SQUID_MAXFD;
 int Biggest_FD = -1;
@@ -169,6 +170,7 @@ usage(void)
        "Usage: %s [-hsvzCDFRUVY] [-f config-file] [-[au] port] [-k signal]\n"
        "       -a port   Specify ASCII port number (default: %d).\n"
        "       -b        Buffer log output (default is unbuffered).\n"
+       "       -d        Write debugging to stderr also.\n"
        "       -f file   Use given config-file instead of\n"
        "                 %s\n"
        "       -h        Print help message.\n"
@@ -196,7 +198,7 @@ mainParseOptions(int argc, char *argv[])
     extern char *optarg;
     int c;
 
-    while ((c = getopt(argc, argv, "CDFRVYXa:bf:hik:m:su:vz?")) != -1) {
+    while ((c = getopt(argc, argv, "CDFRVYXa:bdf:hik:m:su:vz?")) != -1) {
        switch (c) {
        case 'C':
            opt_catch_signals = 0;
@@ -226,6 +228,9 @@ mainParseOptions(int argc, char *argv[])
        case 'b':
            unbuffered_logs = 0;
            break;
+       case 'd':
+           opt_debug_stderr = 1;
+           break;
        case 'f':
            xfree(ConfigFile);
            ConfigFile = xstrdup(optarg);
@@ -337,21 +342,21 @@ serverConnectionsOpen(void)
     int len;
     int x;
     int fd;
-    for (x = 0; x< Config.Port.n_http; x++) {
-        enter_suid();
-        fd = comm_open(SOCK_STREAM,
+    for (x = 0; x < Config.Port.n_http; x++) {
+       enter_suid();
+       fd = comm_open(SOCK_STREAM,
            0,
            Config.Addrs.tcp_incoming,
            Config.Port.http[x],
            COMM_NONBLOCKING,
            "HTTP Socket");
-        leave_suid();
+       leave_suid();
        if (fd < 0)
-               continue;
-        comm_listen(fd);
-        commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
-        debug(1, 1, "Accepting HTTP connections on port %d, FD %d.\n",
-           (int) Config.Port.http[x], fd);
+           continue;
+       comm_listen(fd);
+       commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
+       debug(1, 1, "Accepting HTTP connections on port %d, FD %d.\n",
+           (int) Config.Port.http[x], fd);
        HttpSockets[NHttpSockets++] = fd;
     }
     if (NHttpSockets < 1)
@@ -392,8 +397,8 @@ serverConnectionsOpen(void)
                    COMM_SELECT_READ,
                    icpHandleUdp,
                    NULL, 0);
-               debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n",
-                       (int) port, theInIcpConnection);
+               debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n",
+                   (int) port, theInIcpConnection);
                fd_note(theOutIcpConnection, "Outgoing ICP socket");
                fd_note(theInIcpConnection, "Incoming ICP socket");
            } else {
@@ -468,18 +473,14 @@ serverConnectionsClose(void)
     /* NOTE, this function will be called repeatedly while shutdown
      * is pending */
     int i;
-    for (i=0; i<NHttpSockets; i++) {
-        if (HttpSockets[i] >= 0) {
+    for (i = 0; i < NHttpSockets; i++) {
+       if (HttpSockets[i] >= 0) {
            debug(1, 1, "FD %d Closing HTTP connection\n", HttpSockets[i]);
            comm_close(HttpSockets[i]);
-           commSetSelect(HttpSockets[i],
-               COMM_SELECT_READ,
-               NULL,
-               NULL, 0);
            HttpSockets[i] = -1;
        }
-       NHttpSockets = 0;
     }
+    NHttpSockets = 0;
     if (theInIcpConnection >= 0) {
        /* NOTE, don't close outgoing ICP connection, we need to write to
         * it during shutdown */