void
Driver::send_notifications (void)
{
  int const nhandlers = 16;
  One_Shot_Handler * handlers[nhandlers];
  initialize_handlers(nhandlers, handlers);

  for (int i = 0; i != notifications_curr_; ++i)
  {
    notify_handlers(nhandlers, handlers);
  }
}
Пример #2
0
void
YamlConfiguration::fam_event(const char *filename, unsigned int mask)
{
  MutexLocker lock(mutex);
  try {
    std::string host_file = "";
    std::list<std::string> files, dirs;
    YamlConfigurationNode *root, *host_root;
    read_yaml_config(config_file_, host_file, root, host_root, files, dirs);

    std::list<std::string> changes = YamlConfigurationNode::diff(root_, root);

    if (! changes.empty()) {
      YamlConfigurationNode *old_root = root_;
      YamlConfigurationNode *old_host_root = host_root_;
      root_ = root;
      host_root_ = host_root;
      host_file_ = host_file;
      delete old_root;
      delete old_host_root;

      std::list<std::string>::iterator c;
      for (c = changes.begin(); c != changes.end(); ++c) {
        notify_handlers(c->c_str());
      }
    }

    // includes might have changed to include a new empty file
    // so even though no value changes were seen, we might very
    // well have new files we need to watch (or files we do no
    // longer have to watch, so always reset and re-add.
    RefPtr<FileAlterationMonitor> fam = fam_thread_->get_fam();
    fam->reset();
    std::list<std::string>::iterator f;
    for (f = files.begin(); f != files.end(); ++f) {
      fam->watch_file(f->c_str());
    }
    for (f = dirs.begin(); f != dirs.end(); ++f) {
      fam->watch_dir(f->c_str());
    }

  } catch (Exception &e) {
    LibLogger::log_warn("YamlConfiguration",
                        "Failed to reload changed config, exception follows");
    LibLogger::log_warn("YamlConfiguration", e);
  }
}