mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Remove TimerMgr arg from event queuing/scheduling methods
It's not useful for anything since there's only ever a single TimerMgr.
This commit is contained in:
parent
5e496e43b7
commit
54bc3bd5c6
6 changed files with 17 additions and 39 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 3fefee1630269b96ea4f39021bf387b9d0abfd80
|
Subproject commit 92377e064d925389b1732d105a674f2f761615e6
|
|
@ -496,15 +496,14 @@ void Connection::ConnectionEvent(EventHandlerPtr f, analyzer::Analyzer* a, val_l
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// "this" is passed as a cookie for the event
|
// "this" is passed as a cookie for the event
|
||||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL,
|
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0, this);
|
||||||
a ? a->GetID() : 0, timer_mgr, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::ConnectionEventFast(EventHandlerPtr f, analyzer::Analyzer* a, val_list vl)
|
void Connection::ConnectionEventFast(EventHandlerPtr f, analyzer::Analyzer* a, val_list vl)
|
||||||
{
|
{
|
||||||
// "this" is passed as a cookie for the event
|
// "this" is passed as a cookie for the event
|
||||||
mgr.Enqueue(f, zeek::val_list_to_args(&vl), SOURCE_LOCAL,
|
mgr.Enqueue(f, zeek::val_list_to_args(&vl), SOURCE_LOCAL,
|
||||||
a ? a->GetID() : 0, timer_mgr, this);
|
a ? a->GetID() : 0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::ConnectionEvent(EventHandlerPtr f, analyzer::Analyzer* a, val_list* vl)
|
void Connection::ConnectionEvent(EventHandlerPtr f, analyzer::Analyzer* a, val_list* vl)
|
||||||
|
@ -520,8 +519,7 @@ void Connection::EnqueueEvent(EventHandlerPtr f, analyzer::Analyzer* a,
|
||||||
zeek::Args args)
|
zeek::Args args)
|
||||||
{
|
{
|
||||||
// "this" is passed as a cookie for the event
|
// "this" is passed as a cookie for the event
|
||||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0,
|
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0, this);
|
||||||
timer_mgr, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::Weird(const char* name, const char* addl)
|
void Connection::Weird(const char* name, const char* addl)
|
||||||
|
|
17
src/Event.cc
17
src/Event.cc
|
@ -19,13 +19,11 @@ uint64_t num_events_queued = 0;
|
||||||
uint64_t num_events_dispatched = 0;
|
uint64_t num_events_dispatched = 0;
|
||||||
|
|
||||||
Event::Event(EventHandlerPtr arg_handler, zeek::Args arg_args,
|
Event::Event(EventHandlerPtr arg_handler, zeek::Args arg_args,
|
||||||
SourceID arg_src, analyzer::ID arg_aid, TimerMgr* arg_mgr,
|
SourceID arg_src, analyzer::ID arg_aid, BroObj* arg_obj)
|
||||||
BroObj* arg_obj)
|
|
||||||
: handler(arg_handler),
|
: handler(arg_handler),
|
||||||
args(std::move(arg_args)),
|
args(std::move(arg_args)),
|
||||||
src(arg_src),
|
src(arg_src),
|
||||||
aid(arg_aid),
|
aid(arg_aid),
|
||||||
mgr(arg_mgr ? arg_mgr : timer_mgr),
|
|
||||||
obj(arg_obj),
|
obj(arg_obj),
|
||||||
next_event(nullptr)
|
next_event(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +78,6 @@ EventMgr::EventMgr()
|
||||||
{
|
{
|
||||||
head = tail = 0;
|
head = tail = 0;
|
||||||
current_src = SOURCE_LOCAL;
|
current_src = SOURCE_LOCAL;
|
||||||
current_mgr = timer_mgr;
|
|
||||||
current_aid = 0;
|
current_aid = 0;
|
||||||
src_val = 0;
|
src_val = 0;
|
||||||
draining = 0;
|
draining = 0;
|
||||||
|
@ -102,7 +99,7 @@ void EventMgr::QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
||||||
SourceID src, analyzer::ID aid, TimerMgr* mgr,
|
SourceID src, analyzer::ID aid, TimerMgr* mgr,
|
||||||
BroObj* obj)
|
BroObj* obj)
|
||||||
{
|
{
|
||||||
QueueEvent(new Event(h, zeek::val_list_to_args(&vl), src, aid, mgr, obj));
|
QueueEvent(new Event(h, zeek::val_list_to_args(&vl), src, aid, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
||||||
|
@ -112,7 +109,7 @@ void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
||||||
auto args = zeek::val_list_to_args(&vl);
|
auto args = zeek::val_list_to_args(&vl);
|
||||||
|
|
||||||
if ( h )
|
if ( h )
|
||||||
Enqueue(h, std::move(args), src, aid, mgr, obj);
|
Enqueue(h, std::move(args), src, aid, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
||||||
|
@ -123,14 +120,13 @@ void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
||||||
delete vl;
|
delete vl;
|
||||||
|
|
||||||
if ( h )
|
if ( h )
|
||||||
Enqueue(h, std::move(args), src, aid, mgr, obj);
|
Enqueue(h, std::move(args), src, aid, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::Enqueue(const EventHandlerPtr& h, zeek::Args vl,
|
void EventMgr::Enqueue(const EventHandlerPtr& h, zeek::Args vl,
|
||||||
SourceID src, analyzer::ID aid,
|
SourceID src, analyzer::ID aid, BroObj* obj)
|
||||||
TimerMgr* mgr, BroObj* obj)
|
|
||||||
{
|
{
|
||||||
QueueEvent(new Event(h, std::move(vl), src, aid, mgr, obj));
|
QueueEvent(new Event(h, std::move(vl), src, aid, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::QueueEvent(Event* event)
|
void EventMgr::QueueEvent(Event* event)
|
||||||
|
@ -190,7 +186,6 @@ void EventMgr::Drain()
|
||||||
Event* next = current->NextEvent();
|
Event* next = current->NextEvent();
|
||||||
|
|
||||||
current_src = current->Source();
|
current_src = current->Source();
|
||||||
current_mgr = current->Mgr();
|
|
||||||
current_aid = current->Analyzer();
|
current_aid = current->Analyzer();
|
||||||
current->Dispatch();
|
current->Dispatch();
|
||||||
Unref(current);
|
Unref(current);
|
||||||
|
|
10
src/Event.h
10
src/Event.h
|
@ -17,14 +17,13 @@ class Event : public BroObj {
|
||||||
public:
|
public:
|
||||||
Event(EventHandlerPtr handler, zeek::Args args,
|
Event(EventHandlerPtr handler, zeek::Args args,
|
||||||
SourceID src = SOURCE_LOCAL, analyzer::ID aid = 0,
|
SourceID src = SOURCE_LOCAL, analyzer::ID aid = 0,
|
||||||
TimerMgr* mgr = nullptr, BroObj* obj = nullptr);
|
BroObj* obj = nullptr);
|
||||||
|
|
||||||
void SetNext(Event* n) { next_event = n; }
|
void SetNext(Event* n) { next_event = n; }
|
||||||
Event* NextEvent() const { return next_event; }
|
Event* NextEvent() const { return next_event; }
|
||||||
|
|
||||||
SourceID Source() const { return src; }
|
SourceID Source() const { return src; }
|
||||||
analyzer::ID Analyzer() const { return aid; }
|
analyzer::ID Analyzer() const { return aid; }
|
||||||
TimerMgr* Mgr() const { return mgr; }
|
|
||||||
EventHandlerPtr Handler() const { return handler; }
|
EventHandlerPtr Handler() const { return handler; }
|
||||||
const zeek::Args& Args() const { return args; }
|
const zeek::Args& Args() const { return args; }
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ protected:
|
||||||
zeek::Args args;
|
zeek::Args args;
|
||||||
SourceID src;
|
SourceID src;
|
||||||
analyzer::ID aid;
|
analyzer::ID aid;
|
||||||
TimerMgr* mgr;
|
|
||||||
BroObj* obj;
|
BroObj* obj;
|
||||||
Event* next_event;
|
Event* next_event;
|
||||||
};
|
};
|
||||||
|
@ -101,7 +99,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void Enqueue(const EventHandlerPtr& h, zeek::Args vl,
|
void Enqueue(const EventHandlerPtr& h, zeek::Args vl,
|
||||||
SourceID src = SOURCE_LOCAL, analyzer::ID aid = 0,
|
SourceID src = SOURCE_LOCAL, analyzer::ID aid = 0,
|
||||||
TimerMgr* mgr = nullptr, BroObj* obj = nullptr);
|
BroObj* obj = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A version of Enqueue() taking a variable number of arguments.
|
* A version of Enqueue() taking a variable number of arguments.
|
||||||
|
@ -127,9 +125,6 @@ public:
|
||||||
// non-analyzer event.
|
// non-analyzer event.
|
||||||
analyzer::ID CurrentAnalyzer() const { return current_aid; }
|
analyzer::ID CurrentAnalyzer() const { return current_aid; }
|
||||||
|
|
||||||
// Returns the timer mgr associated with the last raised event.
|
|
||||||
TimerMgr* CurrentTimerMgr() const { return current_mgr; }
|
|
||||||
|
|
||||||
int Size() const
|
int Size() const
|
||||||
{ return num_events_queued - num_events_dispatched; }
|
{ return num_events_queued - num_events_dispatched; }
|
||||||
|
|
||||||
|
@ -147,7 +142,6 @@ protected:
|
||||||
Event* tail;
|
Event* tail;
|
||||||
SourceID current_src;
|
SourceID current_src;
|
||||||
analyzer::ID current_aid;
|
analyzer::ID current_aid;
|
||||||
TimerMgr* current_mgr;
|
|
||||||
RecordVal* src_val;
|
RecordVal* src_val;
|
||||||
bool draining;
|
bool draining;
|
||||||
bro::Flare queue_flare;
|
bro::Flare queue_flare;
|
||||||
|
|
15
src/Expr.cc
15
src/Expr.cc
|
@ -3885,9 +3885,9 @@ IntrusivePtr<Val> FlattenExpr::Fold(Val* v) const
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleTimer::ScheduleTimer(EventHandlerPtr arg_event, zeek::Args arg_args,
|
ScheduleTimer::ScheduleTimer(EventHandlerPtr arg_event, zeek::Args arg_args,
|
||||||
double t, TimerMgr* arg_tmgr)
|
double t)
|
||||||
: Timer(t, TIMER_SCHEDULE),
|
: Timer(t, TIMER_SCHEDULE),
|
||||||
event(arg_event), args(std::move(arg_args)), tmgr(arg_tmgr)
|
event(arg_event), args(std::move(arg_args))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3898,7 +3898,7 @@ ScheduleTimer::~ScheduleTimer()
|
||||||
void ScheduleTimer::Dispatch(double /* t */, int /* is_expire */)
|
void ScheduleTimer::Dispatch(double /* t */, int /* is_expire */)
|
||||||
{
|
{
|
||||||
if ( event )
|
if ( event )
|
||||||
mgr.Enqueue(event, std::move(args), SOURCE_LOCAL, 0, tmgr);
|
mgr.Enqueue(event, std::move(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleExpr::ScheduleExpr(IntrusivePtr<Expr> arg_when,
|
ScheduleExpr::ScheduleExpr(IntrusivePtr<Expr> arg_when,
|
||||||
|
@ -3940,14 +3940,7 @@ IntrusivePtr<Val> ScheduleExpr::Eval(Frame* f) const
|
||||||
auto args = eval_list(f, event->Args());
|
auto args = eval_list(f, event->Args());
|
||||||
|
|
||||||
if ( args )
|
if ( args )
|
||||||
{
|
timer_mgr->Add(new ScheduleTimer(event->Handler(), std::move(*args), dt));
|
||||||
TimerMgr* tmgr = mgr.CurrentTimerMgr();
|
|
||||||
|
|
||||||
if ( ! tmgr )
|
|
||||||
tmgr = timer_mgr;
|
|
||||||
|
|
||||||
tmgr->Add(new ScheduleTimer(event->Handler(), std::move(*args), dt, tmgr));
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,8 +740,7 @@ protected:
|
||||||
|
|
||||||
class ScheduleTimer : public Timer {
|
class ScheduleTimer : public Timer {
|
||||||
public:
|
public:
|
||||||
ScheduleTimer(EventHandlerPtr event, zeek::Args args,
|
ScheduleTimer(EventHandlerPtr event, zeek::Args args, double t);
|
||||||
double t, TimerMgr* tmgr);
|
|
||||||
~ScheduleTimer() override;
|
~ScheduleTimer() override;
|
||||||
|
|
||||||
void Dispatch(double t, int is_expire) override;
|
void Dispatch(double t, int is_expire) override;
|
||||||
|
@ -749,7 +748,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
EventHandlerPtr event;
|
EventHandlerPtr event;
|
||||||
zeek::Args args;
|
zeek::Args args;
|
||||||
TimerMgr* tmgr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScheduleExpr : public Expr {
|
class ScheduleExpr : public Expr {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue