Initial structure for supervisor-mode

The full process hierarchy isn't set up yet, but these changes
help prepare by doing two things:

- Add a -j option to enable supervisor-mode.  Currently, just a single
  "stem" process gets forked early on to be used as the basis for
  further forking into real cluster nodes.

- Separates the parsing of command-line options from their consumption.
  i.e. need to parse whether we're in -j supervisor-mode before
  modifying any global state since that would taint the "stem" process.
  The new intermediate structure containing the parsed options may
  also serve as a way to pass configuration info from "stem" to its
  descendent cluster node processes.
This commit is contained in:
Jon Siwek 2019-09-27 18:53:07 -07:00
parent d97d625bc3
commit 4959d438fa
18 changed files with 751 additions and 366 deletions

View file

@ -145,40 +145,39 @@ void net_update_time(double new_network_time)
PLUGIN_HOOK_VOID(HOOK_UPDATE_NETWORK_TIME, HookUpdateNetworkTime(new_network_time));
}
void net_init(name_list& interfaces, name_list& readfiles,
const char* writefile, int do_watchdog)
void net_init(const std::vector<std::string>& interfaces,
const std::vector<std::string>& pcap_input_files,
const std::string& pcap_output_file, bool do_watchdog)
{
if ( readfiles.length() > 0 )
if ( ! pcap_input_files.empty() )
{
reading_live = pseudo_realtime > 0.0;
reading_traces = 1;
for ( int i = 0; i < readfiles.length(); ++i )
for ( const auto& pif : pcap_input_files )
{
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(readfiles[i], false);
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(pif, false);
assert(ps);
if ( ! ps->IsOpen() )
reporter->FatalError("problem with trace file %s (%s)",
readfiles[i],
ps->ErrorMsg());
pif.data(), ps->ErrorMsg());
}
}
else if ( interfaces.length() > 0 )
else if ( ! interfaces.empty() )
{
reading_live = 1;
reading_traces = 0;
for ( int i = 0; i < interfaces.length(); ++i )
for ( const auto& iface : interfaces )
{
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(interfaces[i], true);
iosource::PktSrc* ps = iosource_mgr->OpenPktSrc(iface, true);
assert(ps);
if ( ! ps->IsOpen() )
reporter->FatalError("problem with interface %s (%s)",
interfaces[i],
ps->ErrorMsg());
iface.data(), ps->ErrorMsg());
}
}
@ -189,8 +188,9 @@ void net_init(name_list& interfaces, name_list& readfiles,
// a timer.
reading_traces = reading_live = 0;
if ( writefile )
if ( ! pcap_output_file.empty() )
{
const char* writefile = pcap_output_file.data();
pkt_dumper = iosource_mgr->OpenPktDumper(writefile, false);
assert(pkt_dumper);