]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Patch from Dag-Erling Smorgrav that implements feature, unbound -dd
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 29 Jul 2014 11:48:43 +0000 (11:48 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 29 Jul 2014 11:48:43 +0000 (11:48 +0000)
  does not fork in the background and also logs to stderr.

git-svn-id: file:///svn/unbound/trunk@3197 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/unbound.c
doc/Changelog
doc/unbound.8.in

index 64fa8b9772f7b4fa50a2a689ebec3637c2c1eede..a53fe954db265b3e6a48bd08b842a5ef9d453271 100644 (file)
@@ -269,8 +269,6 @@ checkrlimits(struct config_file* cfg)
 #ifdef HAVE_SETRLIMIT
                if(setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
                        log_warn("setrlimit: %s", strerror(errno));
-#else
-               if(1) {
 #endif
                        log_warn("cannot increase max open fds from %u to %u",
                                (unsigned)avail, (unsigned)total+10);
@@ -286,7 +284,9 @@ checkrlimits(struct config_file* cfg)
                        log_warn("increase ulimit or decrease threads, "
                                "ports in config to remove this warning");
                        return;
+#ifdef HAVE_SETRLIMIT
                }
+#endif
                log_warn("increased limit(open files) from %u to %u",
                        (unsigned)avail, (unsigned)total+10);
        }
@@ -299,10 +299,14 @@ checkrlimits(struct config_file* cfg)
 /** set verbosity, check rlimits, cache settings */
 static void
 apply_settings(struct daemon* daemon, struct config_file* cfg, 
-       int cmdline_verbose)
+       int cmdline_verbose, int debug_mode)
 {
        /* apply if they have changed */
        verbosity = cmdline_verbose + cfg->verbosity;
+       if (debug_mode > 1) {
+               cfg->use_syslog = 0;
+               cfg->logfile = NULL;
+       }
        daemon_apply_cfg(daemon, cfg);
        checkrlimits(cfg);
 }
@@ -661,7 +665,7 @@ run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode)
                                        cfgfile);
                        log_warn("Continuing with default config settings");
                }
-               apply_settings(daemon, cfg, cmdline_verbose);
+               apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
        
                /* prepare */
                if(!daemon_open_shared_ports(daemon))
@@ -741,7 +745,7 @@ main(int argc, char* argv[])
                        verbosity++;
                        break;
                case 'd':
-                       debug_mode = 1;
+                       debug_mode++;
                        break;
                case 'w':
                        winopt = optarg;
index 1c364d44129a093de84ebeef0b16685e2cb82dc8..8ae8ee30f21885ee3e42c10e91f214af521a66f6 100644 (file)
@@ -1,3 +1,7 @@
+29 July 2014: Wouter
+       - Patch from Dag-Erling Smorgrav that implements feature, unbound -dd
+         does not fork in the background and also logs to stderr.
+
 21 July 2014: Wouter
        - Fix endian.h include for OpenBSD.
 
index f268a6c723ad074f9ed2608d5112cf6e6f9c75e4..c801bfd0dddfc0d72e59c66c2a7ca49ac0b3806f 100644 (file)
@@ -36,9 +36,11 @@ file at the default location, @ub_conf_file@. The syntax is
 described in \fIunbound.conf\fR(5).
 .TP
 .B \-d
-Debug flag, do not fork into the background, but stay attached to the
-console. This flag will also delay writing to the logfile until the
-thread\-spawn time. So that most config and setup errors appear on stderr.
+Debug flag: do not fork into the background, but stay attached to
+the console.  This flag will also delay writing to the log file until
+the thread\-spawn time, so that most config and setup errors appear on
+stderr. If given twice or more, logging does not switch to the log file
+or to syslog, but the log messages are printed to stderr all the time.
 .TP
 .B \-v
 Increase verbosity. If given multiple times, more information is logged.