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();
|
broker_mgr->InitPostScript();
|
||||||
timer_mgr->InitPostScript();
|
timer_mgr->InitPostScript();
|
||||||
|
|
||||||
|
if ( zeek::supervisor_mgr )
|
||||||
|
zeek::supervisor_mgr->InitPostScript();
|
||||||
|
|
||||||
if ( options.print_plugins )
|
if ( options.print_plugins )
|
||||||
{
|
{
|
||||||
bool success = show_plugins(options.print_plugins);
|
bool success = show_plugins(options.print_plugins);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "iosource/Manager.h"
|
||||||
#include "Supervisor.h"
|
#include "Supervisor.h"
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "DebugLogger.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);
|
DBG_LOG(DBG_SUPERVISOR, "forked stem process %d", stem_pid);
|
||||||
setsignal(SIGCHLD, supervisor_signal_handler);
|
setsignal(SIGCHLD, supervisor_signal_handler);
|
||||||
SetIdle(true);
|
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
auto res = waitpid(stem_pid, &status, WNOHANG);
|
auto res = waitpid(stem_pid, &status, WNOHANG);
|
||||||
|
@ -197,6 +197,9 @@ Supervisor::~Supervisor()
|
||||||
return;
|
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);
|
DBG_LOG(DBG_SUPERVISOR, "shutdown, killing stem process %d", stem_pid);
|
||||||
|
|
||||||
auto kill_res = kill(stem_pid, SIGTERM);
|
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,
|
void Supervisor::InitPostScript()
|
||||||
iosource::FD_Set* except)
|
|
||||||
{
|
{
|
||||||
read->Insert(signal_flare.FD());
|
iosource_mgr->Register(this);
|
||||||
read->Insert(stem_pipe->InFD());
|
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()
|
void Supervisor::Process()
|
||||||
|
|
|
@ -285,6 +285,12 @@ public:
|
||||||
*/
|
*/
|
||||||
~Supervisor();
|
~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.
|
* @return the process ID of the Stem.
|
||||||
*/
|
*/
|
||||||
|
@ -347,11 +353,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// IOSource interface overrides:
|
// IOSource interface overrides:
|
||||||
void GetFds(iosource::FD_Set* read, iosource::FD_Set* write,
|
double GetNextTimeout() override;
|
||||||
iosource::FD_Set* except) override;
|
|
||||||
|
|
||||||
double NextTimestamp(double* local_network_time) override;
|
|
||||||
|
|
||||||
void Process() override;
|
void Process() override;
|
||||||
|
|
||||||
size_t ProcessMessages();
|
size_t ProcessMessages();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue