mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Update Supervisor code for the new IOSource API
This commit is contained in:
parent
6ddcc87c48
commit
0cfb115c1b
3 changed files with 20 additions and 12 deletions
|
@ -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);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <cstdarg>
|
||||
#include <sstream>
|
||||
|
||||
#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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue