]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Log: Do not open logfiles when parse-and-exit option is active
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 31 May 2020 11:21:55 +0000 (13:21 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 3 Jun 2020 12:59:20 +0000 (14:59 +0200)
This is a quick workaround for an issue where configured logfiles are
opened/created during parsing of a config file even when parse-and-exit
option is active. We should later refactor the logging code to avoid
opening log during parsing altogether.

sysdep/unix/config.Y
sysdep/unix/main.c
sysdep/unix/unix.h

index af82e5bdd77532111bfffd5b5a9a55f4d2f0eef3..5c4b5beff936cb4b2509e13575d445b0b64f14f8 100644 (file)
@@ -50,9 +50,12 @@ log_limit:
 
 log_file:
    text log_limit {
-     this_log->rf = rf_open(new_config->pool, $1, "a");
-     if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
-     this_log->fh = rf_file(this_log->rf);
+     if (!parse_and_exit)
+     {
+       this_log->rf = rf_open(new_config->pool, $1, "a");
+       if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
+       this_log->fh = rf_file(this_log->rf);
+     }
      this_log->pos = -1;
      this_log->filename = $1;
    }
@@ -88,9 +91,12 @@ conf: mrtdump_base ;
 mrtdump_base:
    MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
  | MRTDUMP text ';' {
-     struct rfile *f = rf_open(new_config->pool, $2, "a");
-     if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
-     new_config->mrtdump_file = rf_fileno(f);
+     if (!parse_and_exit)
+     {
+       struct rfile *f = rf_open(new_config->pool, $2, "a");
+       if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
+       new_config->mrtdump_file = rf_fileno(f);
+     }
    }
  ;
 
index 1d258f4c7a81e6d549b9bd752e21997d8b0f490e..2c7e3ceff6321568c37795c12e994f94973466c9 100644 (file)
@@ -658,7 +658,7 @@ signal_init(void)
  */
 
 static char *opt_list = "bc:dD:ps:P:u:g:flRh";
-static int parse_and_exit;
+int parse_and_exit;
 char *bird_name;
 static char *use_user;
 static char *use_group;
index 8244fc86a8e712ebff666fd17174d6fd3ae5f9e1..0f2973f0e485b950335b319abd982ef59659fc5a 100644 (file)
@@ -20,6 +20,7 @@ struct rfile;
 /* main.c */
 
 extern char *bird_name;
+extern int parse_and_exit;
 void async_config(void);
 void async_dump(void);
 void async_shutdown(void);