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;
|
||||
|
||||
// "this" is passed as a cookie for the event
|
||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL,
|
||||
a ? a->GetID() : 0, timer_mgr, this);
|
||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0, this);
|
||||
}
|
||||
|
||||
void Connection::ConnectionEventFast(EventHandlerPtr f, analyzer::Analyzer* a, val_list vl)
|
||||
{
|
||||
// "this" is passed as a cookie for the event
|
||||
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)
|
||||
|
@ -520,8 +519,7 @@ void Connection::EnqueueEvent(EventHandlerPtr f, analyzer::Analyzer* a,
|
|||
zeek::Args args)
|
||||
{
|
||||
// "this" is passed as a cookie for the event
|
||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0,
|
||||
timer_mgr, this);
|
||||
mgr.Enqueue(f, std::move(args), SOURCE_LOCAL, a ? a->GetID() : 0, this);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Event::Event(EventHandlerPtr arg_handler, zeek::Args arg_args,
|
||||
SourceID arg_src, analyzer::ID arg_aid, TimerMgr* arg_mgr,
|
||||
BroObj* arg_obj)
|
||||
SourceID arg_src, analyzer::ID arg_aid, BroObj* arg_obj)
|
||||
: handler(arg_handler),
|
||||
args(std::move(arg_args)),
|
||||
src(arg_src),
|
||||
aid(arg_aid),
|
||||
mgr(arg_mgr ? arg_mgr : timer_mgr),
|
||||
obj(arg_obj),
|
||||
next_event(nullptr)
|
||||
{
|
||||
|
@ -80,7 +78,6 @@ EventMgr::EventMgr()
|
|||
{
|
||||
head = tail = 0;
|
||||
current_src = SOURCE_LOCAL;
|
||||
current_mgr = timer_mgr;
|
||||
current_aid = 0;
|
||||
src_val = 0;
|
||||
draining = 0;
|
||||
|
@ -102,7 +99,7 @@ void EventMgr::QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
|||
SourceID src, analyzer::ID aid, TimerMgr* mgr,
|
||||
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,
|
||||
|
@ -112,7 +109,7 @@ void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
|||
auto args = zeek::val_list_to_args(&vl);
|
||||
|
||||
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,
|
||||
|
@ -123,14 +120,13 @@ void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
|||
delete vl;
|
||||
|
||||
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,
|
||||
SourceID src, analyzer::ID aid,
|
||||
TimerMgr* mgr, BroObj* obj)
|
||||
SourceID src, analyzer::ID aid, 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)
|
||||
|
@ -190,7 +186,6 @@ void EventMgr::Drain()
|
|||
Event* next = current->NextEvent();
|
||||
|
||||
current_src = current->Source();
|
||||
current_mgr = current->Mgr();
|
||||
current_aid = current->Analyzer();
|
||||
current->Dispatch();
|
||||
Unref(current);
|
||||
|
|
10
src/Event.h
10
src/Event.h
|
@ -17,14 +17,13 @@ class Event : public BroObj {
|
|||
public:
|
||||
Event(EventHandlerPtr handler, zeek::Args args,
|
||||
SourceID src = SOURCE_LOCAL, analyzer::ID aid = 0,
|
||||
TimerMgr* mgr = nullptr, BroObj* obj = nullptr);
|
||||
BroObj* obj = nullptr);
|
||||
|
||||
void SetNext(Event* n) { next_event = n; }
|
||||
Event* NextEvent() const { return next_event; }
|
||||
|
||||
SourceID Source() const { return src; }
|
||||
analyzer::ID Analyzer() const { return aid; }
|
||||
TimerMgr* Mgr() const { return mgr; }
|
||||
EventHandlerPtr Handler() const { return handler; }
|
||||
const zeek::Args& Args() const { return args; }
|
||||
|
||||
|
@ -41,7 +40,6 @@ protected:
|
|||
zeek::Args args;
|
||||
SourceID src;
|
||||
analyzer::ID aid;
|
||||
TimerMgr* mgr;
|
||||
BroObj* obj;
|
||||
Event* next_event;
|
||||
};
|
||||
|
@ -101,7 +99,7 @@ public:
|
|||
*/
|
||||
void Enqueue(const EventHandlerPtr& h, zeek::Args vl,
|
||||
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.
|
||||
|
@ -127,9 +125,6 @@ public:
|
|||
// non-analyzer event.
|
||||
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
|
||||
{ return num_events_queued - num_events_dispatched; }
|
||||
|
||||
|
@ -147,7 +142,6 @@ protected:
|
|||
Event* tail;
|
||||
SourceID current_src;
|
||||
analyzer::ID current_aid;
|
||||
TimerMgr* current_mgr;
|
||||
RecordVal* src_val;
|
||||
bool draining;
|
||||
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,
|
||||
double t, TimerMgr* arg_tmgr)
|
||||
double t)
|
||||
: 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 */)
|
||||
{
|
||||
if ( event )
|
||||
mgr.Enqueue(event, std::move(args), SOURCE_LOCAL, 0, tmgr);
|
||||
mgr.Enqueue(event, std::move(args));
|
||||
}
|
||||
|
||||
ScheduleExpr::ScheduleExpr(IntrusivePtr<Expr> arg_when,
|
||||
|
@ -3940,14 +3940,7 @@ IntrusivePtr<Val> ScheduleExpr::Eval(Frame* f) const
|
|||
auto args = eval_list(f, event->Args());
|
||||
|
||||
if ( args )
|
||||
{
|
||||
TimerMgr* tmgr = mgr.CurrentTimerMgr();
|
||||
|
||||
if ( ! tmgr )
|
||||
tmgr = timer_mgr;
|
||||
|
||||
tmgr->Add(new ScheduleTimer(event->Handler(), std::move(*args), dt, tmgr));
|
||||
}
|
||||
timer_mgr->Add(new ScheduleTimer(event->Handler(), std::move(*args), dt));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -740,8 +740,7 @@ protected:
|
|||
|
||||
class ScheduleTimer : public Timer {
|
||||
public:
|
||||
ScheduleTimer(EventHandlerPtr event, zeek::Args args,
|
||||
double t, TimerMgr* tmgr);
|
||||
ScheduleTimer(EventHandlerPtr event, zeek::Args args, double t);
|
||||
~ScheduleTimer() override;
|
||||
|
||||
void Dispatch(double t, int is_expire) override;
|
||||
|
@ -749,7 +748,6 @@ public:
|
|||
protected:
|
||||
EventHandlerPtr event;
|
||||
zeek::Args args;
|
||||
TimerMgr* tmgr;
|
||||
};
|
||||
|
||||
class ScheduleExpr : public Expr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue