diff --git a/src/main.cc b/src/main.cc index 0760c6b664..ffcce06bc3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -674,6 +674,9 @@ int main(int argc, char** argv) broker_mgr->InitPostScript(); timer_mgr->InitPostScript(); + if ( zeek::supervisor_mgr ) + zeek::supervisor_mgr->InitPostScript(); + if ( options.print_plugins ) { bool success = show_plugins(options.print_plugins); diff --git a/src/supervisor/Supervisor.cc b/src/supervisor/Supervisor.cc index b6e157c1a3..4ef342ffb7 100644 --- a/src/supervisor/Supervisor.cc +++ b/src/supervisor/Supervisor.cc @@ -10,6 +10,7 @@ #include #include +#include "iosource/Manager.h" #include "Supervisor.h" #include "Reporter.h" #include "DebugLogger.h" @@ -160,7 +161,6 @@ Supervisor::Supervisor(Supervisor::Config cfg, StemState ss) { DBG_LOG(DBG_SUPERVISOR, "forked stem process %d", stem_pid); setsignal(SIGCHLD, supervisor_signal_handler); - SetIdle(true); int status; auto res = waitpid(stem_pid, &status, WNOHANG); @@ -197,6 +197,9 @@ Supervisor::~Supervisor() return; } + iosource_mgr->UnregisterFd(signal_flare.FD(), this); + iosource_mgr->UnregisterFd(stem_pipe->InFD(), this); + DBG_LOG(DBG_SUPERVISOR, "shutdown, killing stem process %d", stem_pid); auto kill_res = kill(stem_pid, SIGTERM); @@ -352,16 +355,16 @@ void Supervisor::HandleChildSignal() } } -void Supervisor::GetFds(iosource::FD_Set* read, iosource::FD_Set* write, - iosource::FD_Set* except) +void Supervisor::InitPostScript() { - read->Insert(signal_flare.FD()); - read->Insert(stem_pipe->InFD()); + iosource_mgr->Register(this); + iosource_mgr->RegisterFd(signal_flare.FD(), this); + iosource_mgr->RegisterFd(stem_pipe->InFD(), this); } -double Supervisor::NextTimestamp(double* local_network_time) +double Supervisor::GetNextTimeout() { - return timer_mgr->Time(); + return -1; } void Supervisor::Process() diff --git a/src/supervisor/Supervisor.h b/src/supervisor/Supervisor.h index 32b07e5aff..36d00f1808 100644 --- a/src/supervisor/Supervisor.h +++ b/src/supervisor/Supervisor.h @@ -285,6 +285,12 @@ public: */ ~Supervisor(); + /** + * Perform some initialization that needs to happen after scripts are loaded + * and the IOSource manager is created. + */ + void InitPostScript(); + /** * @return the process ID of the Stem. */ @@ -347,11 +353,7 @@ public: private: // IOSource interface overrides: - void GetFds(iosource::FD_Set* read, iosource::FD_Set* write, - iosource::FD_Set* except) override; - - double NextTimestamp(double* local_network_time) override; - + double GetNextTimeout() override; void Process() override; size_t ProcessMessages();