mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move Timer and PriorityQueue classes to namespaces
This commit is contained in:
parent
910aa77d95
commit
1c17700c48
33 changed files with 206 additions and 140 deletions
|
@ -23,5 +23,5 @@ using type_list = zeek::PList<zeek::Type>;
|
||||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
||||||
using attr_list = zeek::PList<zeek::detail::Attr>;
|
using attr_list = zeek::PList<zeek::detail::Attr>;
|
||||||
|
|
||||||
class Timer;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Timer, zeek::detail);
|
||||||
using timer_list = zeek::PList<Timer, zeek::ListOrder::UNORDERED>;
|
using timer_list = zeek::PList<zeek::detail::Timer, zeek::ListOrder::UNORDERED>;
|
||||||
|
|
29
src/Conn.cc
29
src/Conn.cc
|
@ -220,7 +220,7 @@ void Connection::NextPacket(double t, bool is_orig,
|
||||||
void Connection::SetLifetime(double lifetime)
|
void Connection::SetLifetime(double lifetime)
|
||||||
{
|
{
|
||||||
ADD_TIMER(&Connection::DeleteTimer, network_time + lifetime, 0,
|
ADD_TIMER(&Connection::DeleteTimer, network_time + lifetime, 0,
|
||||||
TIMER_CONN_DELETE);
|
zeek::detail::TIMER_CONN_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::IsReuse(double t, const u_char* pkt)
|
bool Connection::IsReuse(double t, const u_char* pkt)
|
||||||
|
@ -289,7 +289,8 @@ void Connection::InactivityTimer(double t)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ADD_TIMER(&Connection::InactivityTimer,
|
ADD_TIMER(&Connection::InactivityTimer,
|
||||||
last_time + inactivity_timeout, 0, TIMER_CONN_INACTIVITY);
|
last_time + inactivity_timeout, 0,
|
||||||
|
zeek::detail::TIMER_CONN_INACTIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::RemoveConnectionTimer(double t)
|
void Connection::RemoveConnectionTimer(double t)
|
||||||
|
@ -305,15 +306,15 @@ void Connection::SetInactivityTimeout(double timeout)
|
||||||
|
|
||||||
// First cancel and remove any existing inactivity timer.
|
// First cancel and remove any existing inactivity timer.
|
||||||
for ( const auto& timer : timers )
|
for ( const auto& timer : timers )
|
||||||
if ( timer->Type() == TIMER_CONN_INACTIVITY )
|
if ( timer->Type() == zeek::detail::TIMER_CONN_INACTIVITY )
|
||||||
{
|
{
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( timeout )
|
if ( timeout )
|
||||||
ADD_TIMER(&Connection::InactivityTimer,
|
ADD_TIMER(&Connection::InactivityTimer,
|
||||||
last_time + timeout, 0, TIMER_CONN_INACTIVITY);
|
last_time + timeout, 0, zeek::detail::TIMER_CONN_INACTIVITY);
|
||||||
|
|
||||||
inactivity_timeout = timeout;
|
inactivity_timeout = timeout;
|
||||||
}
|
}
|
||||||
|
@ -323,8 +324,8 @@ void Connection::EnableStatusUpdateTimer()
|
||||||
if ( connection_status_update && connection_status_update_interval )
|
if ( connection_status_update && connection_status_update_interval )
|
||||||
{
|
{
|
||||||
ADD_TIMER(&Connection::StatusUpdateTimer,
|
ADD_TIMER(&Connection::StatusUpdateTimer,
|
||||||
network_time + connection_status_update_interval, 0,
|
network_time + connection_status_update_interval, 0,
|
||||||
TIMER_CONN_STATUS_UPDATE);
|
zeek::detail::TIMER_CONN_STATUS_UPDATE);
|
||||||
installed_status_timer = 1;
|
installed_status_timer = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,8 +334,8 @@ void Connection::StatusUpdateTimer(double t)
|
||||||
{
|
{
|
||||||
EnqueueEvent(connection_status_update, nullptr, ConnVal());
|
EnqueueEvent(connection_status_update, nullptr, ConnVal());
|
||||||
ADD_TIMER(&Connection::StatusUpdateTimer,
|
ADD_TIMER(&Connection::StatusUpdateTimer,
|
||||||
network_time + connection_status_update_interval, 0,
|
network_time + connection_status_update_interval, 0,
|
||||||
TIMER_CONN_STATUS_UPDATE);
|
zeek::detail::TIMER_CONN_STATUS_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
zeek::RecordVal* Connection::BuildConnVal()
|
zeek::RecordVal* Connection::BuildConnVal()
|
||||||
|
@ -539,7 +540,7 @@ void Connection::Weird(const char* name, const char* addl)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::AddTimer(timer_func timer, double t, bool do_expire,
|
void Connection::AddTimer(timer_func timer, double t, bool do_expire,
|
||||||
TimerType type)
|
zeek::detail::TimerType type)
|
||||||
{
|
{
|
||||||
if ( timers_canceled )
|
if ( timers_canceled )
|
||||||
return;
|
return;
|
||||||
|
@ -550,12 +551,12 @@ void Connection::AddTimer(timer_func timer, double t, bool do_expire,
|
||||||
if ( ! key_valid )
|
if ( ! key_valid )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Timer* conn_timer = new ConnectionTimer(this, timer, t, do_expire, type);
|
zeek::detail::Timer* conn_timer = new ConnectionTimer(this, timer, t, do_expire, type);
|
||||||
timer_mgr->Add(conn_timer);
|
zeek::detail::timer_mgr->Add(conn_timer);
|
||||||
timers.push_back(conn_timer);
|
timers.push_back(conn_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::RemoveTimer(Timer* t)
|
void Connection::RemoveTimer(zeek::detail::Timer* t)
|
||||||
{
|
{
|
||||||
timers.remove(t);
|
timers.remove(t);
|
||||||
}
|
}
|
||||||
|
@ -570,7 +571,7 @@ void Connection::CancelTimers()
|
||||||
std::copy(timers.begin(), timers.end(), std::back_inserter(tmp));
|
std::copy(timers.begin(), timers.end(), std::back_inserter(tmp));
|
||||||
|
|
||||||
for ( const auto& timer : tmp )
|
for ( const auto& timer : tmp )
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
|
|
||||||
timers_canceled = 1;
|
timers_canceled = 1;
|
||||||
timers.clear();
|
timers.clear();
|
||||||
|
|
10
src/Conn.h
10
src/Conn.h
|
@ -332,9 +332,9 @@ protected:
|
||||||
// is true, then the timer is also evaluated when Bro terminates,
|
// is true, then the timer is also evaluated when Bro terminates,
|
||||||
// otherwise not.
|
// otherwise not.
|
||||||
void AddTimer(timer_func timer, double t, bool do_expire,
|
void AddTimer(timer_func timer, double t, bool do_expire,
|
||||||
TimerType type);
|
zeek::detail::TimerType type);
|
||||||
|
|
||||||
void RemoveTimer(Timer* t);
|
void RemoveTimer(zeek::detail::Timer* t);
|
||||||
|
|
||||||
// Allow other classes to access pointers to these:
|
// Allow other classes to access pointers to these:
|
||||||
friend class ConnectionTimer;
|
friend class ConnectionTimer;
|
||||||
|
@ -389,11 +389,11 @@ protected:
|
||||||
WeirdStateMap weird_state;
|
WeirdStateMap weird_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConnectionTimer final : public Timer {
|
class ConnectionTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
ConnectionTimer(Connection* arg_conn, timer_func arg_timer,
|
ConnectionTimer(Connection* arg_conn, timer_func arg_timer,
|
||||||
double arg_t, bool arg_do_expire, TimerType arg_type)
|
double arg_t, bool arg_do_expire, zeek::detail::TimerType arg_type)
|
||||||
: Timer(arg_t, arg_type)
|
: zeek::detail::Timer(arg_t, arg_type)
|
||||||
{ Init(arg_conn, arg_timer, arg_do_expire); }
|
{ Init(arg_conn, arg_timer, arg_do_expire); }
|
||||||
~ConnectionTimer() override;
|
~ConnectionTimer() override;
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ EventMgr::~EventMgr()
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
void EventMgr::QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
||||||
SourceID src, analyzer::ID aid, TimerMgr* mgr,
|
SourceID src, analyzer::ID aid, zeek::detail::TimerMgr* mgr,
|
||||||
Obj* obj)
|
Obj* obj)
|
||||||
{
|
{
|
||||||
QueueEvent(new Event(h, zeek::val_list_to_args(vl), src, aid, obj));
|
QueueEvent(new Event(h, zeek::val_list_to_args(vl), src, aid, obj));
|
||||||
|
@ -102,7 +102,7 @@ void EventMgr::QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
||||||
|
|
||||||
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
||||||
SourceID src, analyzer::ID aid,
|
SourceID src, analyzer::ID aid,
|
||||||
TimerMgr* mgr, Obj* obj)
|
zeek::detail::TimerMgr* mgr, Obj* obj)
|
||||||
{
|
{
|
||||||
auto args = zeek::val_list_to_args(vl);
|
auto args = zeek::val_list_to_args(vl);
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list vl,
|
||||||
|
|
||||||
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
void EventMgr::QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
||||||
SourceID src, analyzer::ID aid,
|
SourceID src, analyzer::ID aid,
|
||||||
TimerMgr* mgr, Obj* obj)
|
zeek::detail::TimerMgr* mgr, Obj* obj)
|
||||||
{
|
{
|
||||||
auto args = zeek::val_list_to_args(*vl);
|
auto args = zeek::val_list_to_args(*vl);
|
||||||
delete vl;
|
delete vl;
|
||||||
|
|
12
src/Event.h
12
src/Event.h
|
@ -63,8 +63,8 @@ public:
|
||||||
// arguments when there's no handlers to consume them).
|
// arguments when there's no handlers to consume them).
|
||||||
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
||||||
void QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
void QueueEventFast(const EventHandlerPtr &h, val_list vl,
|
||||||
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
||||||
TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
||||||
|
|
||||||
// Queues an event if there's an event handler (or remote consumer). This
|
// Queues an event if there's an event handler (or remote consumer). This
|
||||||
// function always takes ownership of decrementing the reference count of
|
// function always takes ownership of decrementing the reference count of
|
||||||
|
@ -74,8 +74,8 @@ public:
|
||||||
// existence check.
|
// existence check.
|
||||||
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
||||||
void QueueEvent(const EventHandlerPtr &h, val_list vl,
|
void QueueEvent(const EventHandlerPtr &h, val_list vl,
|
||||||
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
||||||
TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
||||||
|
|
||||||
// Same as QueueEvent, except taking the event's argument list via a
|
// Same as QueueEvent, except taking the event's argument list via a
|
||||||
// pointer instead of by value. This function takes ownership of the
|
// pointer instead of by value. This function takes ownership of the
|
||||||
|
@ -83,8 +83,8 @@ public:
|
||||||
// each of its elements.
|
// each of its elements.
|
||||||
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
[[deprecated("Remove in v4.1. Use Enqueue() instead.")]]
|
||||||
void QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
void QueueEvent(const EventHandlerPtr &h, val_list* vl,
|
||||||
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0,
|
||||||
TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an event to the queue. If no handler is found for the event
|
* Adds an event to the queue. If no handler is found for the event
|
||||||
|
|
|
@ -56,7 +56,7 @@ FragReassembler::FragReassembler(NetSessions* arg_s,
|
||||||
if ( frag_timeout != 0.0 )
|
if ( frag_timeout != 0.0 )
|
||||||
{
|
{
|
||||||
expire_timer = new FragTimer(this, t + frag_timeout);
|
expire_timer = new FragTimer(this, t + frag_timeout);
|
||||||
timer_mgr->Add(expire_timer);
|
zeek::detail::timer_mgr->Add(expire_timer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
expire_timer = nullptr;
|
expire_timer = nullptr;
|
||||||
|
@ -328,7 +328,7 @@ void FragReassembler::DeleteTimer()
|
||||||
if ( expire_timer )
|
if ( expire_timer )
|
||||||
{
|
{
|
||||||
expire_timer->ClearReassembler();
|
expire_timer->ClearReassembler();
|
||||||
timer_mgr->Cancel(expire_timer);
|
zeek::detail::timer_mgr->Cancel(expire_timer);
|
||||||
expire_timer = nullptr; // timer manager will delete it
|
expire_timer = nullptr; // timer manager will delete it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,10 @@ protected:
|
||||||
FragTimer* expire_timer;
|
FragTimer* expire_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FragTimer final : public Timer {
|
class FragTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
FragTimer(FragReassembler* arg_f, double arg_t)
|
FragTimer(FragReassembler* arg_f, double arg_t)
|
||||||
: Timer(arg_t, TIMER_FRAG)
|
: zeek::detail::Timer(arg_t, zeek::detail::TIMER_FRAG)
|
||||||
{ f = arg_f; }
|
{ f = arg_f; }
|
||||||
~FragTimer() override;
|
~FragTimer() override;
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ void expire_timers(iosource::PktSrc* src_ps)
|
||||||
SegmentProfiler prof(segment_logger, "expiring-timers");
|
SegmentProfiler prof(segment_logger, "expiring-timers");
|
||||||
|
|
||||||
current_dispatched +=
|
current_dispatched +=
|
||||||
timer_mgr->Advance(network_time,
|
zeek::detail::timer_mgr->Advance(network_time,
|
||||||
max_timer_expires - current_dispatched);
|
max_timer_expires - current_dispatched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void net_packet_dispatch(double t, const Packet* pkt, iosource::PktSrc* src_ps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// network_time never goes back.
|
// network_time never goes back.
|
||||||
net_update_time(timer_mgr->Time() < t ? t : timer_mgr->Time());
|
net_update_time(zeek::detail::timer_mgr->Time() < t ? t : zeek::detail::timer_mgr->Time());
|
||||||
|
|
||||||
current_pktsrc = src_ps;
|
current_pktsrc = src_ps;
|
||||||
current_iosrc = src_ps;
|
current_iosrc = src_ps;
|
||||||
|
@ -342,7 +342,7 @@ void net_run()
|
||||||
if ( ! reading_traces )
|
if ( ! reading_traces )
|
||||||
// Check whether we have timers scheduled for
|
// Check whether we have timers scheduled for
|
||||||
// the future on which we need to wait.
|
// the future on which we need to wait.
|
||||||
have_pending_timers = timer_mgr->Size() > 0;
|
have_pending_timers = zeek::detail::timer_mgr->Size() > 0;
|
||||||
|
|
||||||
if ( pseudo_realtime && communication_enabled )
|
if ( pseudo_realtime && communication_enabled )
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
PriorityQueue::PriorityQueue(int initial_size) : max_heap_size(initial_size)
|
PriorityQueue::PriorityQueue(int initial_size) : max_heap_size(initial_size)
|
||||||
{
|
{
|
||||||
heap = new PQ_Element*[max_heap_size];
|
heap = new PQ_Element*[max_heap_size];
|
||||||
|
@ -135,3 +137,5 @@ void PriorityQueue::BubbleDown(int bin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "zeek-config.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
class PriorityQueue;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(PriorityQueue, zeek::detail);
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
class PQ_Element {
|
class PQ_Element {
|
||||||
public:
|
public:
|
||||||
|
@ -95,3 +99,8 @@ protected:
|
||||||
int max_heap_size = 0;
|
int max_heap_size = 0;
|
||||||
uint64_t cumulative_num = 0;
|
uint64_t cumulative_num = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
||||||
|
|
||||||
|
using PQ_Element [[deprecated("Remove in v4.1. Use zeek::detail::PQ_Element.")]] = zeek::detail::PQ_Element;
|
||||||
|
using PriorityQueue [[deprecated("Remove in v4.1. Use zeek::detail::PriorityQueue.")]] = zeek::detail::PriorityQueue;
|
||||||
|
|
|
@ -249,10 +249,11 @@ void Reporter::UpdateWeirdStats(const char* name)
|
||||||
++weird_count_by_type[name];
|
++weird_count_by_type[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
class NetWeirdTimer final : public Timer {
|
class NetWeirdTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
NetWeirdTimer(double t, const char* name, double timeout)
|
NetWeirdTimer(double t, const char* name, double timeout)
|
||||||
: Timer(t + timeout, TIMER_NET_WEIRD_EXPIRE), weird_name(name)
|
: zeek::detail::Timer(t + timeout, zeek::detail::TIMER_NET_WEIRD_EXPIRE),
|
||||||
|
weird_name(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Dispatch(double t, bool is_expire) override
|
void Dispatch(double t, bool is_expire) override
|
||||||
|
@ -261,12 +262,13 @@ public:
|
||||||
std::string weird_name;
|
std::string weird_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlowWeirdTimer final : public Timer {
|
class FlowWeirdTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
using IPPair = std::pair<zeek::IPAddr, zeek::IPAddr>;
|
using IPPair = std::pair<zeek::IPAddr, zeek::IPAddr>;
|
||||||
|
|
||||||
FlowWeirdTimer(double t, IPPair p, double timeout)
|
FlowWeirdTimer(double t, IPPair p, double timeout)
|
||||||
: Timer(t + timeout, TIMER_FLOW_WEIRD_EXPIRE), endpoints(std::move(p))
|
: zeek::detail::Timer(t + timeout, zeek::detail::TIMER_FLOW_WEIRD_EXPIRE),
|
||||||
|
endpoints(std::move(p))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Dispatch(double t, bool is_expire) override
|
void Dispatch(double t, bool is_expire) override
|
||||||
|
@ -275,12 +277,12 @@ public:
|
||||||
IPPair endpoints;
|
IPPair endpoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConnTupleWeirdTimer final : public Timer {
|
class ConnTupleWeirdTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
using ConnTuple = Reporter::ConnTuple;
|
using ConnTuple = Reporter::ConnTuple;
|
||||||
|
|
||||||
ConnTupleWeirdTimer(double t, ConnTuple id, double timeout)
|
ConnTupleWeirdTimer(double t, ConnTuple id, double timeout)
|
||||||
: Timer(t + timeout, TIMER_CONN_TUPLE_WEIRD_EXPIRE),
|
: zeek::detail::Timer(t + timeout, zeek::detail::TIMER_CONN_TUPLE_WEIRD_EXPIRE),
|
||||||
conn_id(std::move(id))
|
conn_id(std::move(id))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -311,8 +313,8 @@ bool Reporter::PermitNetWeird(const char* name)
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if ( count == 1 )
|
if ( count == 1 )
|
||||||
timer_mgr->Add(new NetWeirdTimer(network_time, name,
|
zeek::detail::timer_mgr->Add(new NetWeirdTimer(network_time, name,
|
||||||
weird_sampling_duration));
|
weird_sampling_duration));
|
||||||
|
|
||||||
if ( count <= weird_sampling_threshold )
|
if ( count <= weird_sampling_threshold )
|
||||||
return true;
|
return true;
|
||||||
|
@ -331,8 +333,8 @@ bool Reporter::PermitFlowWeird(const char* name,
|
||||||
auto& map = flow_weird_state[endpoints];
|
auto& map = flow_weird_state[endpoints];
|
||||||
|
|
||||||
if ( map.empty() )
|
if ( map.empty() )
|
||||||
timer_mgr->Add(new FlowWeirdTimer(network_time, endpoints,
|
zeek::detail::timer_mgr->Add(new FlowWeirdTimer(network_time, endpoints,
|
||||||
weird_sampling_duration));
|
weird_sampling_duration));
|
||||||
|
|
||||||
auto& count = map[name];
|
auto& count = map[name];
|
||||||
++count;
|
++count;
|
||||||
|
@ -358,9 +360,9 @@ bool Reporter::PermitExpiredConnWeird(const char* name, const zeek::RecordVal& c
|
||||||
auto& map = expired_conn_weird_state[conn_tuple];
|
auto& map = expired_conn_weird_state[conn_tuple];
|
||||||
|
|
||||||
if ( map.empty() )
|
if ( map.empty() )
|
||||||
timer_mgr->Add(new ConnTupleWeirdTimer(network_time,
|
zeek::detail::timer_mgr->Add(new ConnTupleWeirdTimer(network_time,
|
||||||
std::move(conn_tuple),
|
std::move(conn_tuple),
|
||||||
weird_sampling_duration));
|
weird_sampling_duration));
|
||||||
|
|
||||||
auto& count = map[name];
|
auto& count = map[name];
|
||||||
++count;
|
++count;
|
||||||
|
|
|
@ -60,7 +60,7 @@ void IPTunnelTimer::Dispatch(double t, bool is_expire)
|
||||||
|
|
||||||
else if ( ! is_expire )
|
else if ( ! is_expire )
|
||||||
// tunnel activity didn't timeout, schedule another timer
|
// tunnel activity didn't timeout, schedule another timer
|
||||||
timer_mgr->Add(new IPTunnelTimer(t, tunnel_idx));
|
zeek::detail::timer_mgr->Add(new IPTunnelTimer(t, tunnel_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetSessions::NetSessions()
|
NetSessions::NetSessions()
|
||||||
|
@ -627,7 +627,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const zeek::IP_Hdr*
|
||||||
EncapsulatingConn ec(ip_hdr->SrcAddr(), ip_hdr->DstAddr(),
|
EncapsulatingConn ec(ip_hdr->SrcAddr(), ip_hdr->DstAddr(),
|
||||||
tunnel_type);
|
tunnel_type);
|
||||||
ip_tunnels[tunnel_idx] = TunnelActivity(ec, network_time);
|
ip_tunnels[tunnel_idx] = TunnelActivity(ec, network_time);
|
||||||
timer_mgr->Add(new IPTunnelTimer(network_time, tunnel_idx));
|
zeek::detail::timer_mgr->Add(new IPTunnelTimer(network_time, tunnel_idx));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
it->second.second = network_time;
|
it->second.second = network_time;
|
||||||
|
|
|
@ -240,11 +240,11 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class IPTunnelTimer final : public Timer {
|
class IPTunnelTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
IPTunnelTimer(double t, NetSessions::IPPair p)
|
IPTunnelTimer(double t, NetSessions::IPPair p)
|
||||||
: Timer(t + zeek::BifConst::Tunnel::ip_tunnel_timeout,
|
: zeek::detail::Timer(t + zeek::BifConst::Tunnel::ip_tunnel_timeout,
|
||||||
TIMER_IP_TUNNEL_INACTIVITY), tunnel_idx(p) {}
|
zeek::detail::TIMER_IP_TUNNEL_INACTIVITY), tunnel_idx(p) {}
|
||||||
|
|
||||||
~IPTunnelTimer() override {}
|
~IPTunnelTimer() override {}
|
||||||
|
|
||||||
|
|
24
src/Stats.cc
24
src/Stats.cc
|
@ -23,10 +23,10 @@ uint64_t tot_gap_events = 0;
|
||||||
uint64_t tot_gap_bytes = 0;
|
uint64_t tot_gap_bytes = 0;
|
||||||
|
|
||||||
|
|
||||||
class ProfileTimer final : public Timer {
|
class ProfileTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
ProfileTimer(double t, ProfileLogger* l, double i)
|
ProfileTimer(double t, ProfileLogger* l, double i)
|
||||||
: Timer(t, TIMER_PROFILE)
|
: zeek::detail::Timer(t, zeek::detail::TIMER_PROFILE)
|
||||||
{
|
{
|
||||||
logger = l;
|
logger = l;
|
||||||
interval = i;
|
interval = i;
|
||||||
|
@ -45,8 +45,8 @@ void ProfileTimer::Dispatch(double t, bool is_expire)
|
||||||
|
|
||||||
// Reinstall timer.
|
// Reinstall timer.
|
||||||
if ( ! is_expire )
|
if ( ! is_expire )
|
||||||
timer_mgr->Add(new ProfileTimer(network_time + interval,
|
zeek::detail::timer_mgr->Add(new ProfileTimer(network_time + interval,
|
||||||
logger, interval));
|
logger, interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ ProfileLogger::ProfileLogger(zeek::File* arg_file, double interval)
|
||||||
{
|
{
|
||||||
file = arg_file;
|
file = arg_file;
|
||||||
log_count = 0;
|
log_count = 0;
|
||||||
timer_mgr->Add(new ProfileTimer(1, this, interval));
|
zeek::detail::timer_mgr->Add(new ProfileTimer(1, this, interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileLogger::~ProfileLogger()
|
ProfileLogger::~ProfileLogger()
|
||||||
|
@ -179,9 +179,9 @@ void ProfileLogger::Log()
|
||||||
}
|
}
|
||||||
|
|
||||||
file->Write(fmt("%.06f Timers: current=%d max=%d lag=%.2fs\n",
|
file->Write(fmt("%.06f Timers: current=%d max=%d lag=%.2fs\n",
|
||||||
network_time,
|
network_time,
|
||||||
timer_mgr->Size(), timer_mgr->PeakSize(),
|
zeek::detail::timer_mgr->Size(), zeek::detail::timer_mgr->PeakSize(),
|
||||||
network_time - timer_mgr->LastTimestamp()));
|
network_time - zeek::detail::timer_mgr->LastTimestamp()));
|
||||||
|
|
||||||
zeek::detail::DNS_Mgr::Stats dstats;
|
zeek::detail::DNS_Mgr::Stats dstats;
|
||||||
zeek::detail::dns_mgr->GetStats(&dstats);
|
zeek::detail::dns_mgr->GetStats(&dstats);
|
||||||
|
@ -196,13 +196,13 @@ void ProfileLogger::Log()
|
||||||
|
|
||||||
file->Write(fmt("%.06f Triggers: total=%lu pending=%lu\n", network_time, tstats.total, tstats.pending));
|
file->Write(fmt("%.06f Triggers: total=%lu pending=%lu\n", network_time, tstats.total, tstats.pending));
|
||||||
|
|
||||||
unsigned int* current_timers = TimerMgr::CurrentTimers();
|
unsigned int* current_timers = zeek::detail::TimerMgr::CurrentTimers();
|
||||||
for ( int i = 0; i < NUM_TIMER_TYPES; ++i )
|
for ( int i = 0; i < zeek::detail::NUM_TIMER_TYPES; ++i )
|
||||||
{
|
{
|
||||||
if ( current_timers[i] )
|
if ( current_timers[i] )
|
||||||
file->Write(fmt("%.06f %s = %d\n", network_time,
|
file->Write(fmt("%.06f %s = %d\n", network_time,
|
||||||
timer_type_to_string((TimerType) i),
|
zeek::detail::timer_type_to_string(static_cast<zeek::detail::TimerType>(i)),
|
||||||
current_timers[i]));
|
current_timers[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
file->Write(fmt("%0.6f Threads: current=%d\n", network_time, thread_mgr->NumThreads()));
|
file->Write(fmt("%0.6f Threads: current=%d\n", network_time, thread_mgr->NumThreads()));
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "iosource/Manager.h"
|
#include "iosource/Manager.h"
|
||||||
#include "iosource/PktSrc.h"
|
#include "iosource/PktSrc.h"
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
// Names of timers in same order than in TimerType.
|
// Names of timers in same order than in TimerType.
|
||||||
const char* TimerNames[] = {
|
const char* TimerNames[] = {
|
||||||
"BackdoorTimer",
|
"BackdoorTimer",
|
||||||
|
@ -108,7 +110,6 @@ void TimerMgr::InitPostScript()
|
||||||
iosource_mgr->Register(this, true);
|
iosource_mgr->Register(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PQ_TimerMgr::PQ_TimerMgr() : TimerMgr()
|
PQ_TimerMgr::PQ_TimerMgr() : TimerMgr()
|
||||||
{
|
{
|
||||||
q = new PriorityQueue;
|
q = new PriorityQueue;
|
||||||
|
@ -188,3 +189,5 @@ double PQ_TimerMgr::GetNextTimeout()
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
||||||
|
|
56
src/Timer.h
56
src/Timer.h
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class ODesc;
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
// If you add a timer here, adjust TimerNames in Timer.cc.
|
// If you add a timer here, adjust TimerNames in Timer.cc.
|
||||||
enum TimerType : uint8_t {
|
enum TimerType : uint8_t {
|
||||||
TIMER_BACKDOOR,
|
TIMER_BACKDOOR,
|
||||||
|
@ -42,15 +46,13 @@ enum TimerType : uint8_t {
|
||||||
TIMER_TIMERMGR_EXPIRE,
|
TIMER_TIMERMGR_EXPIRE,
|
||||||
TIMER_THREAD_HEARTBEAT,
|
TIMER_THREAD_HEARTBEAT,
|
||||||
};
|
};
|
||||||
const int NUM_TIMER_TYPES = int(TIMER_THREAD_HEARTBEAT) + 1;
|
constexpr int NUM_TIMER_TYPES = int(TIMER_THREAD_HEARTBEAT) + 1;
|
||||||
|
|
||||||
extern const char* timer_type_to_string(TimerType type);
|
extern const char* timer_type_to_string(TimerType type);
|
||||||
|
|
||||||
class ODesc;
|
class Timer : public zeek::detail::PQ_Element {
|
||||||
|
|
||||||
class Timer : public PQ_Element {
|
|
||||||
public:
|
public:
|
||||||
Timer(double t, TimerType arg_type) : PQ_Element(t), type(arg_type) {}
|
Timer(double t, TimerType arg_type) : zeek::detail::PQ_Element(t), type(arg_type) {}
|
||||||
~Timer() override { }
|
~Timer() override { }
|
||||||
|
|
||||||
TimerType Type() const { return type; }
|
TimerType Type() const { return type; }
|
||||||
|
@ -165,7 +167,49 @@ protected:
|
||||||
Timer* Remove() { return (Timer*) q->Remove(); }
|
Timer* Remove() { return (Timer*) q->Remove(); }
|
||||||
Timer* Top() { return (Timer*) q->Top(); }
|
Timer* Top() { return (Timer*) q->Top(); }
|
||||||
|
|
||||||
PriorityQueue* q;
|
zeek::detail::PriorityQueue* q;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TimerMgr* timer_mgr;
|
extern TimerMgr* timer_mgr;
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
||||||
|
|
||||||
|
using TimerType [[deprecated("Remove in v4.1. Use zeek::detail::TimerType.")]] = zeek::detail::TimerType;
|
||||||
|
using Timer [[deprecated("Remove in v4.1. Use zeek::detail::Timer.")]] = zeek::detail::Timer;
|
||||||
|
using TimerMgr [[deprecated("Remove in v4.1. Use zeek::detail::TimerMgr.")]] = zeek::detail::TimerMgr;
|
||||||
|
using PQ_TimerMgr [[deprecated("Remove in v4.1. Use zeek::detail::PQ_TimerMgr.")]] = zeek::detail::PQ_TimerMgr;
|
||||||
|
extern zeek::detail::TimerMgr*& timer_mgr [[deprecated("Remove in v4.1. Use zeek::detail::timer_mgr.")]];
|
||||||
|
|
||||||
|
constexpr auto TIMER_BACKDOOR [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_BACKDOOR.")]] = zeek::detail::TIMER_BACKDOOR;
|
||||||
|
constexpr auto TIMER_BREAKPOINT [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_BREAKPOINT.")]] = zeek::detail::TIMER_BREAKPOINT;
|
||||||
|
constexpr auto TIMER_CONN_DELETE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_CONN_DELETE.")]] = zeek::detail::TIMER_CONN_DELETE;
|
||||||
|
constexpr auto TIMER_CONN_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_CONN_EXPIRE.")]] = zeek::detail::TIMER_CONN_EXPIRE;
|
||||||
|
constexpr auto TIMER_CONN_INACTIVITY [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_CONN_INACTIVITY.")]] = zeek::detail::TIMER_CONN_INACTIVITY;
|
||||||
|
constexpr auto TIMER_CONN_STATUS_UPDATE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_CONN_STATUS_UPDATE.")]] = zeek::detail::TIMER_CONN_STATUS_UPDATE;
|
||||||
|
constexpr auto TIMER_CONN_TUPLE_WEIRD_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_CONN_TUPLE_WEIRD_EXPIRE.")]] = zeek::detail::TIMER_CONN_TUPLE_WEIRD_EXPIRE;
|
||||||
|
constexpr auto TIMER_DNS_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_DNS_EXPIRE.")]] = zeek::detail::TIMER_DNS_EXPIRE;
|
||||||
|
constexpr auto TIMER_FILE_ANALYSIS_INACTIVITY [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_FILE_ANALYSIS_INACTIVITY.")]] = zeek::detail::TIMER_FILE_ANALYSIS_INACTIVITY;
|
||||||
|
constexpr auto TIMER_FLOW_WEIRD_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_FLOW_WEIRD_EXPIRE.")]] = zeek::detail::TIMER_FLOW_WEIRD_EXPIRE;
|
||||||
|
constexpr auto TIMER_FRAG [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_FRAG.")]] = zeek::detail::TIMER_FRAG;
|
||||||
|
constexpr auto TIMER_INTERCONN [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_INTERCONN.")]] = zeek::detail::TIMER_INTERCONN;
|
||||||
|
constexpr auto TIMER_IP_TUNNEL_INACTIVITY [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_IP_TUNNEL_INACTIVITY.")]] = zeek::detail::TIMER_IP_TUNNEL_INACTIVITY;
|
||||||
|
constexpr auto TIMER_NB_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_NB_EXPIRE.")]] = zeek::detail::TIMER_NB_EXPIRE;
|
||||||
|
constexpr auto TIMER_NET_WEIRD_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_NET_WEIRD_EXPIRE.")]] = zeek::detail::TIMER_NET_WEIRD_EXPIRE;
|
||||||
|
constexpr auto TIMER_NETWORK [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_NETWORK.")]] = zeek::detail::TIMER_NETWORK;
|
||||||
|
constexpr auto TIMER_NTP_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_NTP_EXPIRE.")]] = zeek::detail::TIMER_NTP_EXPIRE;
|
||||||
|
constexpr auto TIMER_PROFILE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_PROFILE.")]] = zeek::detail::TIMER_PROFILE;
|
||||||
|
constexpr auto TIMER_ROTATE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_ROTATE.")]] = zeek::detail::TIMER_ROTATE;
|
||||||
|
constexpr auto TIMER_REMOVE_CONNECTION [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_REMOVE_CONNECTION.")]] = zeek::detail::TIMER_REMOVE_CONNECTION;
|
||||||
|
constexpr auto TIMER_RPC_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_RPC_EXPIRE.")]] = zeek::detail::TIMER_RPC_EXPIRE;
|
||||||
|
constexpr auto TIMER_SCHEDULE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_SCHEDULE.")]] = zeek::detail::TIMER_SCHEDULE;
|
||||||
|
constexpr auto TIMER_TABLE_VAL [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TABLE_VAL.")]] = zeek::detail::TIMER_TABLE_VAL;
|
||||||
|
constexpr auto TIMER_TCP_ATTEMPT [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TCP_ATTEMPT.")]] = zeek::detail::TIMER_TCP_ATTEMPT;
|
||||||
|
constexpr auto TIMER_TCP_DELETE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TCP_DELETE.")]] = zeek::detail::TIMER_TCP_DELETE;
|
||||||
|
constexpr auto TIMER_TCP_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TCP_EXPIRE.")]] = zeek::detail::TIMER_TCP_EXPIRE;
|
||||||
|
constexpr auto TIMER_TCP_PARTIAL_CLOSE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TCP_PARTIAL_CLOSE.")]] = zeek::detail::TIMER_TCP_PARTIAL_CLOSE;
|
||||||
|
constexpr auto TIMER_TCP_RESET [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TCP_RESET.")]] = zeek::detail::TIMER_TCP_RESET;
|
||||||
|
constexpr auto TIMER_TRIGGER [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TRIGGER.")]] = zeek::detail::TIMER_TRIGGER;
|
||||||
|
constexpr auto TIMER_PPID_CHECK [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_PPID_CHECK.")]] = zeek::detail::TIMER_PPID_CHECK;
|
||||||
|
constexpr auto TIMER_TIMERMGR_EXPIRE [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_TIMERMGR_EXPIRE.")]] = zeek::detail::TIMER_TIMERMGR_EXPIRE;
|
||||||
|
constexpr auto TIMER_THREAD_HEARTBEAT [[deprecated("Remove in v4.1. Use zeek::detail::TIMER_THREAD_HEARTBEAT.")]] = zeek::detail::TIMER_THREAD_HEARTBEAT;
|
||||||
|
constexpr auto NUM_TIMER_TYPES [[deprecated("Remove in v4.1. Use zeek::detail::NUM_TIMER_TYPES.")]] = zeek::detail::NUM_TIMER_TYPES;
|
||||||
|
|
14
src/Val.cc
14
src/Val.cc
|
@ -1345,7 +1345,7 @@ TableEntryVal* TableEntryVal::Clone(Val::CloneState* state)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
TableValTimer::TableValTimer(TableVal* val, double t) : Timer(t, TIMER_TABLE_VAL)
|
TableValTimer::TableValTimer(TableVal* val, double t) : zeek::detail::Timer(t, zeek::detail::TIMER_TABLE_VAL)
|
||||||
{
|
{
|
||||||
table = val;
|
table = val;
|
||||||
}
|
}
|
||||||
|
@ -1452,7 +1452,7 @@ void TableVal::Init(TableTypePtr t)
|
||||||
TableVal::~TableVal()
|
TableVal::~TableVal()
|
||||||
{
|
{
|
||||||
if ( timer )
|
if ( timer )
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
|
|
||||||
delete table_hash;
|
delete table_hash;
|
||||||
delete AsTable();
|
delete AsTable();
|
||||||
|
@ -1542,12 +1542,12 @@ void TableVal::CheckExpireAttr(detail::AttrTag at)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( timer )
|
if ( timer )
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
|
|
||||||
// As network_time is not necessarily initialized yet,
|
// As network_time is not necessarily initialized yet,
|
||||||
// we set a timer which fires immediately.
|
// we set a timer which fires immediately.
|
||||||
timer = new TableValTimer(this, 1);
|
timer = new TableValTimer(this, 1);
|
||||||
timer_mgr->Add(timer);
|
zeek::detail::timer_mgr->Add(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2532,7 +2532,7 @@ void TableVal::InitDefaultFunc(zeek::detail::Frame* f)
|
||||||
void TableVal::InitTimer(double delay)
|
void TableVal::InitTimer(double delay)
|
||||||
{
|
{
|
||||||
timer = new TableValTimer(this, network_time + delay);
|
timer = new TableValTimer(this, network_time + delay);
|
||||||
timer_mgr->Add(timer);
|
zeek::detail::timer_mgr->Add(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableVal::DoExpire(double t)
|
void TableVal::DoExpire(double t)
|
||||||
|
@ -2664,7 +2664,7 @@ double TableVal::GetExpireTime()
|
||||||
expire_time = nullptr;
|
expire_time = nullptr;
|
||||||
|
|
||||||
if ( timer )
|
if ( timer )
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2765,7 +2765,7 @@ ValPtr TableVal::DoClone(CloneState* state)
|
||||||
// As network_time is not necessarily initialized yet, we set
|
// As network_time is not necessarily initialized yet, we set
|
||||||
// a timer which fires immediately.
|
// a timer which fires immediately.
|
||||||
timer = new TableValTimer(this, 1);
|
timer = new TableValTimer(this, 1);
|
||||||
timer_mgr->Add(timer);
|
zeek::detail::timer_mgr->Add(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( expire_func )
|
if ( expire_func )
|
||||||
|
|
|
@ -759,7 +759,7 @@ protected:
|
||||||
int expire_access_time;
|
int expire_access_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TableValTimer final : public Timer {
|
class TableValTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
TableValTimer(TableVal* val, double t);
|
TableValTimer(TableVal* val, double t);
|
||||||
~TableValTimer() override;
|
~TableValTimer() override;
|
||||||
|
@ -997,7 +997,7 @@ public:
|
||||||
|
|
||||||
unsigned int MemoryAllocation() const override;
|
unsigned int MemoryAllocation() const override;
|
||||||
|
|
||||||
void ClearTimer(Timer* t)
|
void ClearTimer(zeek::detail::Timer* t)
|
||||||
{
|
{
|
||||||
if ( timer == t )
|
if ( timer == t )
|
||||||
timer = nullptr;
|
timer = nullptr;
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
|
|
||||||
namespace zeek::analyzer {
|
namespace zeek::analyzer {
|
||||||
|
|
||||||
class AnalyzerTimer final : public Timer {
|
class AnalyzerTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
AnalyzerTimer(Analyzer* arg_analyzer, analyzer_timer_func arg_timer,
|
AnalyzerTimer(Analyzer* arg_analyzer, analyzer_timer_func arg_timer,
|
||||||
double arg_t, int arg_do_expire, TimerType arg_type);
|
double arg_t, int arg_do_expire, zeek::detail::TimerType arg_type);
|
||||||
|
|
||||||
virtual ~AnalyzerTimer();
|
virtual ~AnalyzerTimer();
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ protected:
|
||||||
using namespace zeek::analyzer;
|
using namespace zeek::analyzer;
|
||||||
|
|
||||||
AnalyzerTimer::AnalyzerTimer(Analyzer* arg_analyzer, analyzer_timer_func arg_timer,
|
AnalyzerTimer::AnalyzerTimer(Analyzer* arg_analyzer, analyzer_timer_func arg_timer,
|
||||||
double arg_t, int arg_do_expire, TimerType arg_type)
|
double arg_t, int arg_do_expire, zeek::detail::TimerType arg_type)
|
||||||
: Timer(arg_t, arg_type)
|
: Timer(arg_t, arg_type)
|
||||||
{
|
{
|
||||||
Init(arg_analyzer, arg_timer, arg_do_expire);
|
Init(arg_analyzer, arg_timer, arg_do_expire);
|
||||||
|
@ -728,16 +728,16 @@ void Analyzer::ProtocolViolation(const char* reason, const char* data, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::AddTimer(analyzer_timer_func timer, double t,
|
void Analyzer::AddTimer(analyzer_timer_func timer, double t,
|
||||||
bool do_expire, TimerType type)
|
bool do_expire, zeek::detail::TimerType type)
|
||||||
{
|
{
|
||||||
Timer* analyzer_timer = new
|
zeek::detail::Timer* analyzer_timer = new
|
||||||
AnalyzerTimer(this, timer, t, do_expire, type);
|
AnalyzerTimer(this, timer, t, do_expire, type);
|
||||||
|
|
||||||
timer_mgr->Add(analyzer_timer);
|
zeek::detail::timer_mgr->Add(analyzer_timer);
|
||||||
timers.push_back(analyzer_timer);
|
timers.push_back(analyzer_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::RemoveTimer(Timer* t)
|
void Analyzer::RemoveTimer(zeek::detail::Timer* t)
|
||||||
{
|
{
|
||||||
timers.remove(t);
|
timers.remove(t);
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ void Analyzer::CancelTimers()
|
||||||
|
|
||||||
// TODO: could be a for_each
|
// TODO: could be a for_each
|
||||||
for ( auto timer : tmp )
|
for ( auto timer : tmp )
|
||||||
timer_mgr->Cancel(timer);
|
zeek::detail::timer_mgr->Cancel(timer);
|
||||||
|
|
||||||
timers_canceled = true;
|
timers_canceled = true;
|
||||||
timers.clear();
|
timers.clear();
|
||||||
|
|
|
@ -664,7 +664,7 @@ protected:
|
||||||
* @param type The timer's type.
|
* @param type The timer's type.
|
||||||
*/
|
*/
|
||||||
void AddTimer(analyzer_timer_func timer, double t, bool do_expire,
|
void AddTimer(analyzer_timer_func timer, double t, bool do_expire,
|
||||||
TimerType type);
|
detail::TimerType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels all timers added previously via AddTimer().
|
* Cancels all timers added previously via AddTimer().
|
||||||
|
@ -675,7 +675,7 @@ protected:
|
||||||
* Removes a given timer. This is an internal method and shouldn't be
|
* Removes a given timer. This is an internal method and shouldn't be
|
||||||
* used by derived class. It does not cancel the timer.
|
* used by derived class. It does not cancel the timer.
|
||||||
*/
|
*/
|
||||||
void RemoveTimer(Timer* t);
|
void RemoveTimer(detail::Timer* t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the analyzer has associated an SupportAnalyzer of a given type.
|
* Returns true if the analyzer has associated an SupportAnalyzer of a given type.
|
||||||
|
|
|
@ -1807,8 +1807,8 @@ DNS_Analyzer::DNS_Analyzer(Connection* conn)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer,
|
||||||
network_time + dns_session_timeout, true,
|
network_time + dns_session_timeout, true,
|
||||||
TIMER_DNS_EXPIRE);
|
zeek::detail::TIMER_DNS_EXPIRE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1861,5 +1861,6 @@ void DNS_Analyzer::ExpireTimer(double t)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer,
|
||||||
t + dns_session_timeout, true, TIMER_DNS_EXPIRE);
|
t + dns_session_timeout, true,
|
||||||
|
zeek::detail::TIMER_DNS_EXPIRE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,8 +471,8 @@ NetbiosSSN_Analyzer::NetbiosSSN_Analyzer(Connection* conn)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer,
|
||||||
network_time + netbios_ssn_session_timeout, true,
|
network_time + netbios_ssn_session_timeout, true,
|
||||||
TIMER_NB_EXPIRE);
|
zeek::detail::TIMER_NB_EXPIRE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,6 +535,6 @@ void NetbiosSSN_Analyzer::ExpireTimer(double t)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer,
|
||||||
t + netbios_ssn_session_timeout,
|
t + netbios_ssn_session_timeout,
|
||||||
true, TIMER_NB_EXPIRE);
|
true, zeek::detail::TIMER_NB_EXPIRE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,7 +727,8 @@ RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn,
|
||||||
{
|
{
|
||||||
if ( Conn()->ConnTransport() == TRANSPORT_UDP )
|
if ( Conn()->ConnTransport() == TRANSPORT_UDP )
|
||||||
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer,
|
||||||
network_time + rpc_timeout, true, TIMER_RPC_EXPIRE);
|
network_time + rpc_timeout, true,
|
||||||
|
zeek::detail::TIMER_RPC_EXPIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
RPC_Analyzer::~RPC_Analyzer()
|
RPC_Analyzer::~RPC_Analyzer()
|
||||||
|
|
|
@ -128,8 +128,8 @@ TCP_Analyzer::TCP_Analyzer(Connection* conn)
|
||||||
{
|
{
|
||||||
// Set a timer to eventually time out this connection.
|
// Set a timer to eventually time out this connection.
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer,
|
||||||
network_time + tcp_SYN_timeout, false,
|
network_time + tcp_SYN_timeout, false,
|
||||||
TIMER_TCP_EXPIRE);
|
zeek::detail::TIMER_TCP_EXPIRE);
|
||||||
|
|
||||||
deferred_gen_event = close_deferred = 0;
|
deferred_gen_event = close_deferred = 0;
|
||||||
|
|
||||||
|
@ -496,8 +496,8 @@ void TCP_Analyzer::UpdateInactiveState(double t,
|
||||||
|
|
||||||
if ( tcp_attempt_delay )
|
if ( tcp_attempt_delay )
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::AttemptTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::AttemptTimer,
|
||||||
t + tcp_attempt_delay, true,
|
t + tcp_attempt_delay, true,
|
||||||
TIMER_TCP_ATTEMPT);
|
zeek::detail::TIMER_TCP_ATTEMPT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -726,8 +726,8 @@ void TCP_Analyzer::UpdateClosedState(double t, TCP_Endpoint* endpoint,
|
||||||
|
|
||||||
if ( connection_reset )
|
if ( connection_reset )
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::ResetTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::ResetTimer,
|
||||||
t + tcp_reset_delay, true,
|
t + tcp_reset_delay, true,
|
||||||
TIMER_TCP_RESET);
|
zeek::detail::TIMER_TCP_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1560,7 +1560,7 @@ void TCP_Analyzer::ExpireTimer(double t)
|
||||||
// ### if PQ_Element's were Obj's, could just Ref the timer
|
// ### if PQ_Element's were Obj's, could just Ref the timer
|
||||||
// and adjust its value here, instead of creating a new timer.
|
// and adjust its value here, instead of creating a new timer.
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer, t + tcp_session_timer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer, t + tcp_session_timer,
|
||||||
false, TIMER_TCP_EXPIRE);
|
false, zeek::detail::TIMER_TCP_EXPIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCP_Analyzer::ResetTimer(double /* t */)
|
void TCP_Analyzer::ResetTimer(double /* t */)
|
||||||
|
@ -1700,11 +1700,11 @@ void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer,
|
||||||
// deleted out from under us.
|
// deleted out from under us.
|
||||||
if ( tcp_close_delay != 0.0 )
|
if ( tcp_close_delay != 0.0 )
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::ConnDeleteTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::ConnDeleteTimer,
|
||||||
Conn()->LastTime() + tcp_close_delay, false,
|
Conn()->LastTime() + tcp_close_delay, false,
|
||||||
TIMER_CONN_DELETE);
|
zeek::detail::TIMER_CONN_DELETE);
|
||||||
else
|
else
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::DeleteTimer, Conn()->LastTime(), false,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::DeleteTimer, Conn()->LastTime(), false,
|
||||||
TIMER_TCP_DELETE);
|
zeek::detail::TIMER_TCP_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1713,8 +1713,8 @@ void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer,
|
||||||
{ // First time we've seen anything from this side.
|
{ // First time we've seen anything from this side.
|
||||||
if ( connection_partial_close )
|
if ( connection_partial_close )
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::PartialCloseTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::PartialCloseTimer,
|
||||||
Conn()->LastTime() + tcp_partial_close_delay, false,
|
Conn()->LastTime() + tcp_partial_close_delay, false,
|
||||||
TIMER_TCP_PARTIAL_CLOSE );
|
zeek::detail::TIMER_TCP_PARTIAL_CLOSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1722,8 +1722,8 @@ void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer,
|
||||||
// Create a timer to look for the other side closing,
|
// Create a timer to look for the other side closing,
|
||||||
// too.
|
// too.
|
||||||
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer,
|
||||||
Conn()->LastTime() + tcp_session_timer, false,
|
Conn()->LastTime() + tcp_session_timer, false,
|
||||||
TIMER_TCP_EXPIRE);
|
zeek::detail::TIMER_TCP_EXPIRE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ bool File::IsComplete() const
|
||||||
|
|
||||||
void File::ScheduleInactivityTimer() const
|
void File::ScheduleInactivityTimer() const
|
||||||
{
|
{
|
||||||
timer_mgr->Add(new FileTimer(network_time, id, GetTimeoutInterval()));
|
zeek::detail::timer_mgr->Add(new FileTimer(network_time, id, GetTimeoutInterval()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::AddAnalyzer(file_analysis::Tag tag, zeek::RecordVal* args)
|
bool File::AddAnalyzer(file_analysis::Tag tag, zeek::RecordVal* args)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
using namespace file_analysis;
|
using namespace file_analysis;
|
||||||
|
|
||||||
FileTimer::FileTimer(double t, const std::string& id, double interval)
|
FileTimer::FileTimer(double t, const std::string& id, double interval)
|
||||||
: Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id)
|
: zeek::detail::Timer(t + interval, zeek::detail::TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id)
|
||||||
{
|
{
|
||||||
DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s",
|
DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s",
|
||||||
interval, file_id.c_str());
|
interval, file_id.c_str());
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace file_analysis {
|
||||||
/**
|
/**
|
||||||
* Timer to periodically check if file analysis for a given file is inactive.
|
* Timer to periodically check if file analysis for a given file is inactive.
|
||||||
*/
|
*/
|
||||||
class FileTimer final : public Timer {
|
class FileTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct Manager::Filter {
|
||||||
struct Manager::WriterInfo {
|
struct Manager::WriterInfo {
|
||||||
zeek::EnumVal* type;
|
zeek::EnumVal* type;
|
||||||
double open_time;
|
double open_time;
|
||||||
Timer* rotation_timer;
|
zeek::detail::Timer* rotation_timer;
|
||||||
double interval;
|
double interval;
|
||||||
zeek::Func* postprocessor;
|
zeek::Func* postprocessor;
|
||||||
WriterFrontend* writer;
|
WriterFrontend* writer;
|
||||||
|
@ -118,7 +118,7 @@ Manager::Stream::~Stream()
|
||||||
WriterInfo* winfo = i->second;
|
WriterInfo* winfo = i->second;
|
||||||
|
|
||||||
if ( winfo->rotation_timer )
|
if ( winfo->rotation_timer )
|
||||||
timer_mgr->Cancel(winfo->rotation_timer);
|
zeek::detail::timer_mgr->Cancel(winfo->rotation_timer);
|
||||||
|
|
||||||
Unref(winfo->type);
|
Unref(winfo->type);
|
||||||
delete winfo->writer;
|
delete winfo->writer;
|
||||||
|
@ -1408,10 +1408,10 @@ zeek::RecordType* Manager::StreamColumns(zeek::EnumVal* stream_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timer which on dispatching rotates the filter.
|
// Timer which on dispatching rotates the filter.
|
||||||
class RotationTimer final : public Timer {
|
class RotationTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
RotationTimer(double t, Manager::WriterInfo* arg_winfo, bool arg_rotate)
|
RotationTimer(double t, Manager::WriterInfo* arg_winfo, bool arg_rotate)
|
||||||
: Timer(t, TIMER_ROTATE)
|
: zeek::detail::Timer(t, zeek::detail::TIMER_ROTATE)
|
||||||
{
|
{
|
||||||
winfo = arg_winfo;
|
winfo = arg_winfo;
|
||||||
rotate = arg_rotate;
|
rotate = arg_rotate;
|
||||||
|
@ -1453,7 +1453,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
|
||||||
|
|
||||||
if ( winfo->rotation_timer )
|
if ( winfo->rotation_timer )
|
||||||
{
|
{
|
||||||
timer_mgr->Cancel(winfo->rotation_timer);
|
zeek::detail::timer_mgr->Cancel(winfo->rotation_timer);
|
||||||
winfo->rotation_timer = nullptr;
|
winfo->rotation_timer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1482,7 +1482,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
|
||||||
new RotationTimer(network_time + delta_t, winfo, true);
|
new RotationTimer(network_time + delta_t, winfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_mgr->Add(winfo->rotation_timer);
|
zeek::detail::timer_mgr->Add(winfo->rotation_timer);
|
||||||
|
|
||||||
DBG_LOG(DBG_LOGGING, "Scheduled rotation timer for %s to %.6f",
|
DBG_LOG(DBG_LOGGING, "Scheduled rotation timer for %s to %.6f",
|
||||||
winfo->writer->Name(), winfo->rotation_timer->Time());
|
winfo->writer->Name(), winfo->rotation_timer->Time());
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( zeek::Supervisor::ThisNode() )
|
if ( zeek::Supervisor::ThisNode() )
|
||||||
timer_mgr->Add(new zeek::detail::ParentProcessCheckTimer(1, 1));
|
zeek::detail::timer_mgr->Add(new zeek::detail::ParentProcessCheckTimer(1, 1));
|
||||||
|
|
||||||
double time_net_start = current_time(true);;
|
double time_net_start = current_time(true);;
|
||||||
|
|
||||||
|
|
|
@ -283,9 +283,9 @@ function get_timer_stats%(%): TimerStats
|
||||||
auto r = zeek::make_intrusive<zeek::RecordVal>(TimerStats);
|
auto r = zeek::make_intrusive<zeek::RecordVal>(TimerStats);
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
r->Assign(n++, zeek::val_mgr->Count(unsigned(timer_mgr->Size())));
|
r->Assign(n++, zeek::val_mgr->Count(unsigned(zeek::detail::timer_mgr->Size())));
|
||||||
r->Assign(n++, zeek::val_mgr->Count(unsigned(timer_mgr->PeakSize())));
|
r->Assign(n++, zeek::val_mgr->Count(unsigned(zeek::detail::timer_mgr->PeakSize())));
|
||||||
r->Assign(n++, zeek::val_mgr->Count(timer_mgr->CumulativeNum()));
|
r->Assign(n++, zeek::val_mgr->Count(zeek::detail::timer_mgr->CumulativeNum()));
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -127,7 +127,7 @@ void Manager::SendHeartbeats()
|
||||||
void Manager::StartHeartbeatTimer()
|
void Manager::StartHeartbeatTimer()
|
||||||
{
|
{
|
||||||
heartbeat_timer_running = true;
|
heartbeat_timer_running = true;
|
||||||
timer_mgr->Add(new HeartbeatTimer(network_time + zeek::BifConst::Threading::heartbeat_interval));
|
zeek::detail::timer_mgr->Add(new HeartbeatTimer(network_time + zeek::BifConst::Threading::heartbeat_interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raise everything in here as warnings so it is passed to scriptland without
|
// Raise everything in here as warnings so it is passed to scriptland without
|
||||||
|
@ -250,7 +250,7 @@ void Manager::Flush()
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf(stderr, "P %.6f %.6f do_beat=%d did_process=%d next_next=%.6f\n", network_time, timer_mgr->Time(), do_beat, (int)did_process, next_beat);
|
// fprintf(stderr, "P %.6f %.6f do_beat=%d did_process=%d next_next=%.6f\n", network_time, zeek::detail::timer_mgr->Time(), do_beat, (int)did_process, next_beat);
|
||||||
}
|
}
|
||||||
|
|
||||||
const threading::Manager::msg_stats_list& threading::Manager::GetMsgThreadStats()
|
const threading::Manager::msg_stats_list& threading::Manager::GetMsgThreadStats()
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
namespace threading {
|
namespace threading {
|
||||||
|
|
||||||
class HeartbeatTimer final : public Timer {
|
class HeartbeatTimer final : public zeek::detail::Timer {
|
||||||
public:
|
public:
|
||||||
HeartbeatTimer(double t) : Timer(t, TIMER_THREAD_HEARTBEAT) {}
|
HeartbeatTimer(double t) : zeek::detail::Timer(t, zeek::detail::TIMER_THREAD_HEARTBEAT) {}
|
||||||
virtual ~HeartbeatTimer() {}
|
virtual ~HeartbeatTimer() {}
|
||||||
|
|
||||||
void Dispatch(double t, bool is_expire) override;
|
void Dispatch(double t, bool is_expire) override;
|
||||||
|
|
|
@ -99,7 +99,8 @@ zeek::detail::RuleMatcher*& rule_matcher = zeek::detail::rule_matcher;
|
||||||
zeek::detail::DNS_Mgr* zeek::detail::dns_mgr = nullptr;
|
zeek::detail::DNS_Mgr* zeek::detail::dns_mgr = nullptr;
|
||||||
zeek::detail::DNS_Mgr*& dns_mgr = zeek::detail::dns_mgr;
|
zeek::detail::DNS_Mgr*& dns_mgr = zeek::detail::dns_mgr;
|
||||||
|
|
||||||
TimerMgr* timer_mgr;
|
zeek::detail::TimerMgr* zeek::detail::timer_mgr = nullptr;
|
||||||
|
zeek::detail::TimerMgr*& timer_mgr = zeek::detail::timer_mgr;
|
||||||
|
|
||||||
logging::Manager* log_mgr = nullptr;
|
logging::Manager* log_mgr = nullptr;
|
||||||
threading::Manager* thread_mgr = nullptr;
|
threading::Manager* thread_mgr = nullptr;
|
||||||
|
@ -230,7 +231,7 @@ void done_with_network()
|
||||||
mgr.Drain();
|
mgr.Drain();
|
||||||
// Don't propagate this event to remote clients.
|
// Don't propagate this event to remote clients.
|
||||||
mgr.Dispatch(new Event(net_done,
|
mgr.Dispatch(new Event(net_done,
|
||||||
{zeek::make_intrusive<zeek::TimeVal>(timer_mgr->Time())}),
|
{zeek::make_intrusive<zeek::TimeVal>(zeek::detail::timer_mgr->Time())}),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +241,7 @@ void done_with_network()
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
zeek::analyzer_mgr->Done();
|
zeek::analyzer_mgr->Done();
|
||||||
timer_mgr->Expire();
|
zeek::detail::timer_mgr->Expire();
|
||||||
zeek::detail::dns_mgr->Flush();
|
zeek::detail::dns_mgr->Flush();
|
||||||
mgr.Drain();
|
mgr.Drain();
|
||||||
mgr.Drain();
|
mgr.Drain();
|
||||||
|
@ -282,7 +283,7 @@ void terminate_bro()
|
||||||
if ( zeek_done )
|
if ( zeek_done )
|
||||||
mgr.Enqueue(zeek_done, zeek::Args{});
|
mgr.Enqueue(zeek_done, zeek::Args{});
|
||||||
|
|
||||||
timer_mgr->Expire();
|
zeek::detail::timer_mgr->Expire();
|
||||||
mgr.Drain();
|
mgr.Drain();
|
||||||
|
|
||||||
if ( profiling_logger )
|
if ( profiling_logger )
|
||||||
|
@ -532,7 +533,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
createCurrentDoc("1.0"); // Set a global XML document
|
createCurrentDoc("1.0"); // Set a global XML document
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timer_mgr = new PQ_TimerMgr();
|
zeek::detail::timer_mgr = new zeek::detail::PQ_TimerMgr();
|
||||||
|
|
||||||
auto zeekygen_cfg = options.zeekygen_config_file.value_or("");
|
auto zeekygen_cfg = options.zeekygen_config_file.value_or("");
|
||||||
zeekygen_mgr = new zeekygen::Manager(zeekygen_cfg, bro_argv[0]);
|
zeekygen_mgr = new zeekygen::Manager(zeekygen_cfg, bro_argv[0]);
|
||||||
|
@ -656,7 +657,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
zeek::plugin_mgr->InitPostScript();
|
zeek::plugin_mgr->InitPostScript();
|
||||||
zeekygen_mgr->InitPostScript();
|
zeekygen_mgr->InitPostScript();
|
||||||
broker_mgr->InitPostScript();
|
broker_mgr->InitPostScript();
|
||||||
timer_mgr->InitPostScript();
|
zeek::detail::timer_mgr->InitPostScript();
|
||||||
mgr.InitPostScript();
|
mgr.InitPostScript();
|
||||||
|
|
||||||
if ( zeek::supervisor_mgr )
|
if ( zeek::supervisor_mgr )
|
||||||
|
@ -870,7 +871,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
zeek::reporter->ZeekInitDone();
|
zeek::reporter->ZeekInitDone();
|
||||||
zeek::analyzer_mgr->DumpDebug();
|
zeek::analyzer_mgr->DumpDebug();
|
||||||
|
|
||||||
have_pending_timers = ! reading_traces && timer_mgr->Size() > 0;
|
have_pending_timers = ! reading_traces && zeek::detail::timer_mgr->Size() > 0;
|
||||||
|
|
||||||
return {0, std::move(options)};
|
return {0, std::move(options)};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue