コード例 #1
0
ファイル: cfg.c プロジェクト: tiltti/syslog-ng-3.4
gboolean
cfg_init(GlobalConfig *cfg)
{
  gint regerr;
  
  if (cfg->file_template_name && !(cfg->file_template = cfg_tree_lookup_template(&cfg->tree, cfg->file_template_name)))
    msg_error("Error resolving file template",
               evt_tag_str("name", cfg->file_template_name),
               NULL);
  if (cfg->proto_template_name && !(cfg->proto_template = cfg_tree_lookup_template(&cfg->tree, cfg->proto_template_name)))
    msg_error("Error resolving protocol template",
               evt_tag_str("name", cfg->proto_template_name),
               NULL);
  stats_reinit(cfg);

  if (cfg->bad_hostname_re)
    {
      if ((regerr = regcomp(&cfg->bad_hostname, cfg->bad_hostname_re, REG_NOSUB | REG_EXTENDED)) != 0)
        {
          gchar buf[256];
          
          regerror(regerr, &cfg->bad_hostname, buf, sizeof(buf));
          msg_error("Error compiling bad_hostname regexp",
                    evt_tag_str("error", buf),
                    NULL);
        }
      else
        { 
          cfg->bad_hostname_compiled = TRUE;
        }
    }
  dns_cache_set_params(cfg->dns_cache_size, cfg->dns_cache_expire, cfg->dns_cache_expire_failed, cfg->dns_cache_hosts);
  return cfg_tree_start(&cfg->tree);
}
コード例 #2
0
static void
assert_almighty_always_pipe (gboolean always_pipe_value,
                             gboolean tree_start_expected,
                             gboolean tree_stop_expected,
                             gboolean was_init_called,
                             gboolean was_deinit_called)
{
  CfgTree tree;
  AlmightyAlwaysPipe *pipe;

  cfg_tree_init_instance (&tree, NULL);

  pipe = create_and_attach_almighty_pipe (&tree, always_pipe_value);

  assert_gboolean (cfg_tree_start (&tree), tree_start_expected,
                   "cfg_tree_start() did not return the expected value");
  assert_gboolean (cfg_tree_stop (&tree), tree_stop_expected,
                   "cfg_tree_stop() did not return the epxected value");

  assert_gboolean (pipe->init_called, was_init_called,
                   "->init was called state");
  assert_gboolean (pipe->deinit_called, was_deinit_called,
                   "->deinit was called state");

  cfg_tree_free_instance (&tree);
}
コード例 #3
0
ファイル: cfg.c プロジェクト: Amey-Jain/syslog-ng
gboolean
cfg_init(GlobalConfig *cfg)
{
  gint regerr;
  
  if (cfg->file_template_name && !(cfg->file_template = cfg_tree_lookup_template(&cfg->tree, cfg->file_template_name)))
    msg_error("Error resolving file template",
               evt_tag_str("name", cfg->file_template_name),
               NULL);
  if (cfg->proto_template_name && !(cfg->proto_template = cfg_tree_lookup_template(&cfg->tree, cfg->proto_template_name)))
    msg_error("Error resolving protocol template",
               evt_tag_str("name", cfg->proto_template_name),
               NULL);

  if (cfg->bad_hostname_re)
    {
      if ((regerr = regcomp(&cfg->bad_hostname, cfg->bad_hostname_re, REG_NOSUB | REG_EXTENDED)) != 0)
        {
          gchar buf[256];
          
          regerror(regerr, &cfg->bad_hostname, buf, sizeof(buf));
          msg_error("Error compiling bad_hostname regexp",
                    evt_tag_str("error", buf),
                    NULL);
        }
      else
        { 
          cfg->bad_hostname_compiled = TRUE;
        }
    }

  if (!rcptid_init(cfg->state, cfg->use_uniqid))
    return FALSE;

  stats_reinit(&cfg->stats_options);
  log_tags_reinit_stats(cfg);

  dns_caching_update_options(&cfg->dns_cache_options);
  hostname_reinit(cfg->custom_domain);
  host_resolve_options_init(&cfg->host_resolve_options, cfg);
  log_template_options_init(&cfg->template_options, cfg);
  if (!cfg_init_modules(cfg))
    return FALSE;
  return cfg_tree_start(&cfg->tree);
}
コード例 #4
0
static void
test_pipe_init_multi_success (void)
{
  CfgTree tree;

  testcase_begin ("A pipe of all good nodes will start & stop properly");

  cfg_tree_init_instance (&tree, NULL);

  create_and_attach_almighty_pipe (&tree, TRUE);
  create_and_attach_almighty_pipe (&tree, TRUE);
  create_and_attach_almighty_pipe (&tree, TRUE);

  assert_true (cfg_tree_start (&tree),
               "Starting a tree of all-good nodes works");
  assert_true (cfg_tree_stop (&tree),
               "Stopping a tree of all-good nodes works");

  cfg_tree_free_instance (&tree);

  testcase_end ();
}
コード例 #5
0
static void
test_pipe_init_multi_with_bad_node (void)
{
  AlmightyAlwaysPipe *pipe1, *pipe2, *pipe3;
  CfgTree tree;

  testcase_begin ("A pipe of some bad nodes will not start, but cleans up nicely.");

  cfg_tree_init_instance (&tree, NULL);

  pipe1 = create_and_attach_almighty_pipe (&tree, TRUE);
  pipe2 = create_and_attach_almighty_pipe (&tree, FALSE);
  pipe3 = create_and_attach_almighty_pipe (&tree, TRUE);

  assert_false (cfg_tree_start (&tree),
               "Starting a tree of all-good nodes works");
  assert_true (cfg_tree_stop (&tree),
               "Stopping a tree of all-good nodes works");

  assert_true (pipe1->init_called,
               "The initializer of the first good pipe is called");
  assert_true (pipe2->init_called,
               "The initializer of the bad pipe is called");
  assert_false (pipe3->init_called,
                "The initializer of the second good pipe is NOT called");

  assert_true (pipe1->deinit_called,
               "The deinitializer of the first good pipe is called");
  assert_false (pipe2->deinit_called,
               "The deinitializer of the bad pipe is NOT called");
  assert_false (pipe3->deinit_called,
               "The deinitializer of the second good pipe is NOT called");

  cfg_tree_free_instance (&tree);

  testcase_end ();
}