delete h;
}
-void DataBus::add_mapped_module(const char*) {}
-void DataBus::clone(DataBus& ) {}
+void DataBus::clone(DataBus&, const char*) {}
void DataBus::subscribe(const char* key, DataHandler* h)
{
DB->_subscribe(key, h);
else
delete h;
}
-
- mapped_module.clear();
}
-void DataBus::add_mapped_module(const char* name)
-{
- if ( name )
- mapped_module.emplace(name);
-}
-
-void DataBus::clone(DataBus& from)
+void DataBus::clone(DataBus& from, const char* exclude_name)
{
for ( auto& p : from.map )
for ( auto* h : p.second )
- if ( mapped_module.count(h->module_name) == 0 )
+ if ( nullptr == exclude_name || 0 != strcmp(exclude_name, h->module_name) )
{
h->cloned = true;
_subscribe(p.first.c_str(), h);
{
DataList& v = map[key];
v.emplace_back(h);
-
- // Track fresh subscriptions to distinguish during cloning
- if ( !h->cloned )
- add_mapped_module(h->module_name);
}
void DataBus::_unsubscribe(const char* key, DataHandler* h)
// FIXIT-P evaluate perf; focus is on correctness
typedef std::vector<DataHandler*> DataList;
typedef std::unordered_map<std::string, DataList> DataMap;
-typedef std::unordered_set<const char*> DataModule;
class SO_PUBLIC DataBus
{
~DataBus();
// configure time methods - main thread only
- void clone(DataBus& from);
- void add_mapped_module(const char*);
+ void clone(DataBus& from, const char* exclude_name = nullptr);
// FIXIT-L ideally these would not be static or would take an inspection policy*
static void subscribe(const char* key, DataHandler*);
private:
DataMap map;
- DataModule mapped_module;
};
}
dbus.subscribe(PACKET_EVENT, new AltPktHandler);
}
-void InspectionPolicy::clone_dbus(SnortConfig* from, const char* exclude_module)
-{
- // Clone subscriptions from another config if they are not excluded
- // (e.g., reloading module) and not already subscribed
- dbus.add_mapped_module(exclude_module);
- dbus.clone(from->policy_map->get_inspection_policy()->dbus);
-}
-
//-------------------------------------------------------------------------
// detection policy
//-------------------------------------------------------------------------
~InspectionPolicy();
void configure();
- void clone_dbus(snort::SnortConfig*, const char*);
public:
PolicyId policy_id = 0;
reset_parse_errors();
SnortConfig* sc = new SnortConfig(other_conf);
+ sc->global_dbus->clone(*other_conf->global_dbus, iname);
if ( fname )
{
}
other_conf->cloned = true;
- sc->policy_map->get_inspection_policy()->clone_dbus(other_conf, iname);
- sc->global_dbus->add_mapped_module(iname);
- sc->global_dbus->clone(*other_conf->global_dbus);
InspectorManager::update_policy(sc);
reloading = false;
return sc;
reloading = true;
SnortConfig* sc = new SnortConfig(other_conf);
+ sc->global_dbus->clone(*other_conf->global_dbus, name);
if ( name )
{
}
other_conf->cloned = true;
- sc->policy_map->get_inspection_policy()->clone_dbus(other_conf, name);
- sc->global_dbus->add_mapped_module(name);
- sc->global_dbus->clone(*other_conf->global_dbus);
InspectorManager::update_policy(sc);
reloading = false;
return sc;
{
if ( cloned )
{
+ delete global_dbus;
policy_map->set_cloned(true);
delete policy_map;
return;
void SnortConfig::clone(const SnortConfig* const conf)
{
*this = *conf;
+ global_dbus = new DataBus();
if (conf->homenet.get_family() != 0)
memcpy(&homenet, &conf->homenet, sizeof(homenet));