diff --git a/src/BroList.h b/src/BroList.h index cd80531d4a..73b28a5426 100644 --- a/src/BroList.h +++ b/src/BroList.h @@ -23,5 +23,5 @@ using type_list = zeek::PList; ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail); using attr_list = zeek::PList; -class Timer; -using timer_list = zeek::PList; +ZEEK_FORWARD_DECLARE_NAMESPACED(Timer, zeek::detail); +using timer_list = zeek::PList; diff --git a/src/Conn.cc b/src/Conn.cc index a9939cce92..9a9b86f954 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -220,7 +220,7 @@ void Connection::NextPacket(double t, bool is_orig, void Connection::SetLifetime(double lifetime) { 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) @@ -289,7 +289,8 @@ void Connection::InactivityTimer(double t) } else 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) @@ -305,15 +306,15 @@ void Connection::SetInactivityTimeout(double timeout) // First cancel and remove any existing inactivity timer. 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; } if ( timeout ) ADD_TIMER(&Connection::InactivityTimer, - last_time + timeout, 0, TIMER_CONN_INACTIVITY); + last_time + timeout, 0, zeek::detail::TIMER_CONN_INACTIVITY); inactivity_timeout = timeout; } @@ -323,8 +324,8 @@ void Connection::EnableStatusUpdateTimer() if ( connection_status_update && connection_status_update_interval ) { ADD_TIMER(&Connection::StatusUpdateTimer, - network_time + connection_status_update_interval, 0, - TIMER_CONN_STATUS_UPDATE); + network_time + connection_status_update_interval, 0, + zeek::detail::TIMER_CONN_STATUS_UPDATE); installed_status_timer = 1; } } @@ -333,8 +334,8 @@ void Connection::StatusUpdateTimer(double t) { EnqueueEvent(connection_status_update, nullptr, ConnVal()); ADD_TIMER(&Connection::StatusUpdateTimer, - network_time + connection_status_update_interval, 0, - TIMER_CONN_STATUS_UPDATE); + network_time + connection_status_update_interval, 0, + zeek::detail::TIMER_CONN_STATUS_UPDATE); } 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, - TimerType type) + zeek::detail::TimerType type) { if ( timers_canceled ) return; @@ -550,12 +551,12 @@ void Connection::AddTimer(timer_func timer, double t, bool do_expire, if ( ! key_valid ) return; - Timer* conn_timer = new ConnectionTimer(this, timer, t, do_expire, type); - timer_mgr->Add(conn_timer); + zeek::detail::Timer* conn_timer = new ConnectionTimer(this, timer, t, do_expire, type); + zeek::detail::timer_mgr->Add(conn_timer); timers.push_back(conn_timer); } -void Connection::RemoveTimer(Timer* t) +void Connection::RemoveTimer(zeek::detail::Timer* t) { timers.remove(t); } @@ -570,7 +571,7 @@ void Connection::CancelTimers() std::copy(timers.begin(), timers.end(), std::back_inserter(tmp)); for ( const auto& timer : tmp ) - timer_mgr->Cancel(timer); + zeek::detail::timer_mgr->Cancel(timer); timers_canceled = 1; timers.clear(); diff --git a/src/Conn.h b/src/Conn.h index 11459984cf..0e973f5244 100644 --- a/src/Conn.h +++ b/src/Conn.h @@ -332,9 +332,9 @@ protected: // is true, then the timer is also evaluated when Bro terminates, // otherwise not. 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: friend class ConnectionTimer; @@ -389,11 +389,11 @@ protected: WeirdStateMap weird_state; }; -class ConnectionTimer final : public Timer { +class ConnectionTimer final : public zeek::detail::Timer { public: ConnectionTimer(Connection* arg_conn, timer_func arg_timer, - double arg_t, bool arg_do_expire, TimerType arg_type) - : Timer(arg_t, arg_type) + double arg_t, bool arg_do_expire, zeek::detail::TimerType arg_type) + : zeek::detail::Timer(arg_t, arg_type) { Init(arg_conn, arg_timer, arg_do_expire); } ~ConnectionTimer() override; diff --git a/src/Event.cc b/src/Event.cc index 54ffc082fb..759327917d 100644 --- a/src/Event.cc +++ b/src/Event.cc @@ -94,7 +94,7 @@ EventMgr::~EventMgr() } 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) { 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, SourceID src, analyzer::ID aid, - TimerMgr* mgr, Obj* obj) + zeek::detail::TimerMgr* mgr, Obj* obj) { 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, SourceID src, analyzer::ID aid, - TimerMgr* mgr, Obj* obj) + zeek::detail::TimerMgr* mgr, Obj* obj) { auto args = zeek::val_list_to_args(*vl); delete vl; diff --git a/src/Event.h b/src/Event.h index 5028c90029..d4c7268070 100644 --- a/src/Event.h +++ b/src/Event.h @@ -63,8 +63,8 @@ public: // arguments when there's no handlers to consume them). [[deprecated("Remove in v4.1. Use Enqueue() instead.")]] void QueueEventFast(const EventHandlerPtr &h, val_list vl, - SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, - TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); + SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, + zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); // Queues an event if there's an event handler (or remote consumer). This // function always takes ownership of decrementing the reference count of @@ -74,8 +74,8 @@ public: // existence check. [[deprecated("Remove in v4.1. Use Enqueue() instead.")]] void QueueEvent(const EventHandlerPtr &h, val_list vl, - SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, - TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); + SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, + zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); // Same as QueueEvent, except taking the event's argument list via a // pointer instead of by value. This function takes ownership of the @@ -83,8 +83,8 @@ public: // each of its elements. [[deprecated("Remove in v4.1. Use Enqueue() instead.")]] void QueueEvent(const EventHandlerPtr &h, val_list* vl, - SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, - TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); + SourceID src = SOURCE_LOCAL, zeek::analyzer::ID aid = 0, + zeek::detail::TimerMgr* mgr = nullptr, zeek::Obj* obj = nullptr); /** * Adds an event to the queue. If no handler is found for the event diff --git a/src/Frag.cc b/src/Frag.cc index 01ab4880f6..26eb25524a 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -56,7 +56,7 @@ FragReassembler::FragReassembler(NetSessions* arg_s, if ( frag_timeout != 0.0 ) { expire_timer = new FragTimer(this, t + frag_timeout); - timer_mgr->Add(expire_timer); + zeek::detail::timer_mgr->Add(expire_timer); } else expire_timer = nullptr; @@ -328,7 +328,7 @@ void FragReassembler::DeleteTimer() if ( expire_timer ) { expire_timer->ClearReassembler(); - timer_mgr->Cancel(expire_timer); + zeek::detail::timer_mgr->Cancel(expire_timer); expire_timer = nullptr; // timer manager will delete it } } diff --git a/src/Frag.h b/src/Frag.h index 60e1b78e57..3ece8632b3 100644 --- a/src/Frag.h +++ b/src/Frag.h @@ -53,10 +53,10 @@ protected: FragTimer* expire_timer; }; -class FragTimer final : public Timer { +class FragTimer final : public zeek::detail::Timer { public: FragTimer(FragReassembler* arg_f, double arg_t) - : Timer(arg_t, TIMER_FRAG) + : zeek::detail::Timer(arg_t, zeek::detail::TIMER_FRAG) { f = arg_f; } ~FragTimer() override; diff --git a/src/Net.cc b/src/Net.cc index 029a3203ac..67008cefe5 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -216,7 +216,7 @@ void expire_timers(iosource::PktSrc* src_ps) SegmentProfiler prof(segment_logger, "expiring-timers"); current_dispatched += - timer_mgr->Advance(network_time, + zeek::detail::timer_mgr->Advance(network_time, 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. - 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_iosrc = src_ps; @@ -342,7 +342,7 @@ void net_run() if ( ! reading_traces ) // Check whether we have timers scheduled for // 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 ) { diff --git a/src/PriorityQueue.cc b/src/PriorityQueue.cc index e77ed9e7e2..61d8776aeb 100644 --- a/src/PriorityQueue.cc +++ b/src/PriorityQueue.cc @@ -9,6 +9,8 @@ #include "Reporter.h" #include "util.h" +namespace zeek::detail { + PriorityQueue::PriorityQueue(int initial_size) : max_heap_size(initial_size) { heap = new PQ_Element*[max_heap_size]; @@ -135,3 +137,5 @@ void PriorityQueue::BubbleDown(int bin) } } } + +} // namespace zeek::detail diff --git a/src/PriorityQueue.h b/src/PriorityQueue.h index 591c79c474..35e281ce04 100644 --- a/src/PriorityQueue.h +++ b/src/PriorityQueue.h @@ -2,10 +2,14 @@ #pragma once +#include "zeek-config.h" + #include #include -class PriorityQueue; +ZEEK_FORWARD_DECLARE_NAMESPACED(PriorityQueue, zeek::detail); + +namespace zeek::detail { class PQ_Element { public: @@ -95,3 +99,8 @@ protected: int max_heap_size = 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; diff --git a/src/Reporter.cc b/src/Reporter.cc index c0a36e91ed..81cb6378b9 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -249,10 +249,11 @@ void Reporter::UpdateWeirdStats(const char* name) ++weird_count_by_type[name]; } -class NetWeirdTimer final : public Timer { +class NetWeirdTimer final : public zeek::detail::Timer { public: 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 @@ -261,12 +262,13 @@ public: std::string weird_name; }; -class FlowWeirdTimer final : public Timer { +class FlowWeirdTimer final : public zeek::detail::Timer { public: using IPPair = std::pair; 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 @@ -275,12 +277,12 @@ public: IPPair endpoints; }; -class ConnTupleWeirdTimer final : public Timer { +class ConnTupleWeirdTimer final : public zeek::detail::Timer { public: using ConnTuple = Reporter::ConnTuple; 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)) {} @@ -311,8 +313,8 @@ bool Reporter::PermitNetWeird(const char* name) ++count; if ( count == 1 ) - timer_mgr->Add(new NetWeirdTimer(network_time, name, - weird_sampling_duration)); + zeek::detail::timer_mgr->Add(new NetWeirdTimer(network_time, name, + weird_sampling_duration)); if ( count <= weird_sampling_threshold ) return true; @@ -331,8 +333,8 @@ bool Reporter::PermitFlowWeird(const char* name, auto& map = flow_weird_state[endpoints]; if ( map.empty() ) - timer_mgr->Add(new FlowWeirdTimer(network_time, endpoints, - weird_sampling_duration)); + zeek::detail::timer_mgr->Add(new FlowWeirdTimer(network_time, endpoints, + weird_sampling_duration)); auto& count = map[name]; ++count; @@ -358,9 +360,9 @@ bool Reporter::PermitExpiredConnWeird(const char* name, const zeek::RecordVal& c auto& map = expired_conn_weird_state[conn_tuple]; if ( map.empty() ) - timer_mgr->Add(new ConnTupleWeirdTimer(network_time, - std::move(conn_tuple), - weird_sampling_duration)); + zeek::detail::timer_mgr->Add(new ConnTupleWeirdTimer(network_time, + std::move(conn_tuple), + weird_sampling_duration)); auto& count = map[name]; ++count; diff --git a/src/Sessions.cc b/src/Sessions.cc index 70092302f7..7871e9241a 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -60,7 +60,7 @@ void IPTunnelTimer::Dispatch(double t, bool is_expire) else if ( ! is_expire ) // 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() @@ -627,7 +627,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const zeek::IP_Hdr* EncapsulatingConn ec(ip_hdr->SrcAddr(), ip_hdr->DstAddr(), tunnel_type); 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 it->second.second = network_time; diff --git a/src/Sessions.h b/src/Sessions.h index f6c75db57f..8a8ff98fdd 100644 --- a/src/Sessions.h +++ b/src/Sessions.h @@ -240,11 +240,11 @@ protected: }; -class IPTunnelTimer final : public Timer { +class IPTunnelTimer final : public zeek::detail::Timer { public: IPTunnelTimer(double t, NetSessions::IPPair p) - : Timer(t + zeek::BifConst::Tunnel::ip_tunnel_timeout, - TIMER_IP_TUNNEL_INACTIVITY), tunnel_idx(p) {} + : zeek::detail::Timer(t + zeek::BifConst::Tunnel::ip_tunnel_timeout, + zeek::detail::TIMER_IP_TUNNEL_INACTIVITY), tunnel_idx(p) {} ~IPTunnelTimer() override {} diff --git a/src/Stats.cc b/src/Stats.cc index 21df9e1bdf..1f6ea1d455 100644 --- a/src/Stats.cc +++ b/src/Stats.cc @@ -23,10 +23,10 @@ uint64_t tot_gap_events = 0; uint64_t tot_gap_bytes = 0; -class ProfileTimer final : public Timer { +class ProfileTimer final : public zeek::detail::Timer { public: ProfileTimer(double t, ProfileLogger* l, double i) - : Timer(t, TIMER_PROFILE) + : zeek::detail::Timer(t, zeek::detail::TIMER_PROFILE) { logger = l; interval = i; @@ -45,8 +45,8 @@ void ProfileTimer::Dispatch(double t, bool is_expire) // Reinstall timer. if ( ! is_expire ) - timer_mgr->Add(new ProfileTimer(network_time + interval, - logger, interval)); + zeek::detail::timer_mgr->Add(new ProfileTimer(network_time + interval, + logger, interval)); } @@ -55,7 +55,7 @@ ProfileLogger::ProfileLogger(zeek::File* arg_file, double interval) { file = arg_file; log_count = 0; - timer_mgr->Add(new ProfileTimer(1, this, interval)); + zeek::detail::timer_mgr->Add(new ProfileTimer(1, this, interval)); } ProfileLogger::~ProfileLogger() @@ -179,9 +179,9 @@ void ProfileLogger::Log() } file->Write(fmt("%.06f Timers: current=%d max=%d lag=%.2fs\n", - network_time, - timer_mgr->Size(), timer_mgr->PeakSize(), - network_time - timer_mgr->LastTimestamp())); + network_time, + zeek::detail::timer_mgr->Size(), zeek::detail::timer_mgr->PeakSize(), + network_time - zeek::detail::timer_mgr->LastTimestamp())); zeek::detail::DNS_Mgr::Stats 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)); - unsigned int* current_timers = TimerMgr::CurrentTimers(); - for ( int i = 0; i < NUM_TIMER_TYPES; ++i ) + unsigned int* current_timers = zeek::detail::TimerMgr::CurrentTimers(); + for ( int i = 0; i < zeek::detail::NUM_TIMER_TYPES; ++i ) { if ( current_timers[i] ) file->Write(fmt("%.06f %s = %d\n", network_time, - timer_type_to_string((TimerType) i), - current_timers[i])); + zeek::detail::timer_type_to_string(static_cast(i)), + current_timers[i])); } file->Write(fmt("%0.6f Threads: current=%d\n", network_time, thread_mgr->NumThreads())); diff --git a/src/Timer.cc b/src/Timer.cc index 142b63ee9e..cd3933cf40 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -11,6 +11,8 @@ #include "iosource/Manager.h" #include "iosource/PktSrc.h" +namespace zeek::detail { + // Names of timers in same order than in TimerType. const char* TimerNames[] = { "BackdoorTimer", @@ -108,7 +110,6 @@ void TimerMgr::InitPostScript() iosource_mgr->Register(this, true); } - PQ_TimerMgr::PQ_TimerMgr() : TimerMgr() { q = new PriorityQueue; @@ -188,3 +189,5 @@ double PQ_TimerMgr::GetNextTimeout() return -1; } + +} // namespace zeek::detail diff --git a/src/Timer.h b/src/Timer.h index 8a82eb4627..2eeb38e7f6 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -7,6 +7,10 @@ #include +class ODesc; + +namespace zeek::detail { + // If you add a timer here, adjust TimerNames in Timer.cc. enum TimerType : uint8_t { TIMER_BACKDOOR, @@ -42,15 +46,13 @@ enum TimerType : uint8_t { TIMER_TIMERMGR_EXPIRE, 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); -class ODesc; - -class Timer : public PQ_Element { +class Timer : public zeek::detail::PQ_Element { 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 { } TimerType Type() const { return type; } @@ -165,7 +167,49 @@ protected: Timer* Remove() { return (Timer*) q->Remove(); } Timer* Top() { return (Timer*) q->Top(); } - PriorityQueue* q; + zeek::detail::PriorityQueue* q; }; 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; diff --git a/src/Val.cc b/src/Val.cc index c9a018919d..020cf70fa5 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1345,7 +1345,7 @@ TableEntryVal* TableEntryVal::Clone(Val::CloneState* state) 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; } @@ -1452,7 +1452,7 @@ void TableVal::Init(TableTypePtr t) TableVal::~TableVal() { if ( timer ) - timer_mgr->Cancel(timer); + zeek::detail::timer_mgr->Cancel(timer); delete table_hash; delete AsTable(); @@ -1542,12 +1542,12 @@ void TableVal::CheckExpireAttr(detail::AttrTag at) } if ( timer ) - timer_mgr->Cancel(timer); + zeek::detail::timer_mgr->Cancel(timer); // As network_time is not necessarily initialized yet, // we set a timer which fires immediately. 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) { timer = new TableValTimer(this, network_time + delay); - timer_mgr->Add(timer); + zeek::detail::timer_mgr->Add(timer); } void TableVal::DoExpire(double t) @@ -2664,7 +2664,7 @@ double TableVal::GetExpireTime() expire_time = nullptr; if ( timer ) - timer_mgr->Cancel(timer); + zeek::detail::timer_mgr->Cancel(timer); return -1; } @@ -2765,7 +2765,7 @@ ValPtr TableVal::DoClone(CloneState* state) // As network_time is not necessarily initialized yet, we set // a timer which fires immediately. timer = new TableValTimer(this, 1); - timer_mgr->Add(timer); + zeek::detail::timer_mgr->Add(timer); } if ( expire_func ) diff --git a/src/Val.h b/src/Val.h index a5ad870439..6779d8f51c 100644 --- a/src/Val.h +++ b/src/Val.h @@ -759,7 +759,7 @@ protected: int expire_access_time; }; -class TableValTimer final : public Timer { +class TableValTimer final : public zeek::detail::Timer { public: TableValTimer(TableVal* val, double t); ~TableValTimer() override; @@ -997,7 +997,7 @@ public: unsigned int MemoryAllocation() const override; - void ClearTimer(Timer* t) + void ClearTimer(zeek::detail::Timer* t) { if ( timer == t ) timer = nullptr; diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index 78d8a944aa..72c7d6c30f 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -12,10 +12,10 @@ namespace zeek::analyzer { -class AnalyzerTimer final : public Timer { +class AnalyzerTimer final : public zeek::detail::Timer { public: 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(); @@ -36,7 +36,7 @@ protected: using namespace zeek::analyzer; 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) { 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, - 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); - timer_mgr->Add(analyzer_timer); + zeek::detail::timer_mgr->Add(analyzer_timer); timers.push_back(analyzer_timer); } -void Analyzer::RemoveTimer(Timer* t) +void Analyzer::RemoveTimer(zeek::detail::Timer* t) { timers.remove(t); } @@ -753,7 +753,7 @@ void Analyzer::CancelTimers() // TODO: could be a for_each for ( auto timer : tmp ) - timer_mgr->Cancel(timer); + zeek::detail::timer_mgr->Cancel(timer); timers_canceled = true; timers.clear(); diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index 3696504de5..567d4cf179 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -664,7 +664,7 @@ protected: * @param type The timer's type. */ void AddTimer(analyzer_timer_func timer, double t, bool do_expire, - TimerType type); + detail::TimerType type); /** * 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 * 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. diff --git a/src/analyzer/protocol/dns/DNS.cc b/src/analyzer/protocol/dns/DNS.cc index 8a1d2b719e..57f21b5f2e 100644 --- a/src/analyzer/protocol/dns/DNS.cc +++ b/src/analyzer/protocol/dns/DNS.cc @@ -1807,8 +1807,8 @@ DNS_Analyzer::DNS_Analyzer(Connection* conn) else { ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer, - network_time + dns_session_timeout, true, - TIMER_DNS_EXPIRE); + network_time + dns_session_timeout, true, + zeek::detail::TIMER_DNS_EXPIRE); } } @@ -1861,5 +1861,6 @@ void DNS_Analyzer::ExpireTimer(double t) } else ADD_ANALYZER_TIMER(&DNS_Analyzer::ExpireTimer, - t + dns_session_timeout, true, TIMER_DNS_EXPIRE); + t + dns_session_timeout, true, + zeek::detail::TIMER_DNS_EXPIRE); } diff --git a/src/analyzer/protocol/netbios/NetbiosSSN.cc b/src/analyzer/protocol/netbios/NetbiosSSN.cc index 0bb947a03f..262ab90112 100644 --- a/src/analyzer/protocol/netbios/NetbiosSSN.cc +++ b/src/analyzer/protocol/netbios/NetbiosSSN.cc @@ -471,8 +471,8 @@ NetbiosSSN_Analyzer::NetbiosSSN_Analyzer(Connection* conn) else { ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer, - network_time + netbios_ssn_session_timeout, true, - TIMER_NB_EXPIRE); + network_time + netbios_ssn_session_timeout, true, + zeek::detail::TIMER_NB_EXPIRE); } } @@ -535,6 +535,6 @@ void NetbiosSSN_Analyzer::ExpireTimer(double t) } else ADD_ANALYZER_TIMER(&NetbiosSSN_Analyzer::ExpireTimer, - t + netbios_ssn_session_timeout, - true, TIMER_NB_EXPIRE); + t + netbios_ssn_session_timeout, + true, zeek::detail::TIMER_NB_EXPIRE); } diff --git a/src/analyzer/protocol/rpc/RPC.cc b/src/analyzer/protocol/rpc/RPC.cc index fc32c4cf22..d8aba18095 100644 --- a/src/analyzer/protocol/rpc/RPC.cc +++ b/src/analyzer/protocol/rpc/RPC.cc @@ -727,7 +727,8 @@ RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn, { if ( Conn()->ConnTransport() == TRANSPORT_UDP ) 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() diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 2ae9c6baf4..6786e1757f 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -128,8 +128,8 @@ TCP_Analyzer::TCP_Analyzer(Connection* conn) { // Set a timer to eventually time out this connection. ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer, - network_time + tcp_SYN_timeout, false, - TIMER_TCP_EXPIRE); + network_time + tcp_SYN_timeout, false, + zeek::detail::TIMER_TCP_EXPIRE); deferred_gen_event = close_deferred = 0; @@ -496,8 +496,8 @@ void TCP_Analyzer::UpdateInactiveState(double t, if ( tcp_attempt_delay ) ADD_ANALYZER_TIMER(&TCP_Analyzer::AttemptTimer, - t + tcp_attempt_delay, true, - TIMER_TCP_ATTEMPT); + t + tcp_attempt_delay, true, + zeek::detail::TIMER_TCP_ATTEMPT); } else { @@ -726,8 +726,8 @@ void TCP_Analyzer::UpdateClosedState(double t, TCP_Endpoint* endpoint, if ( connection_reset ) ADD_ANALYZER_TIMER(&TCP_Analyzer::ResetTimer, - t + tcp_reset_delay, true, - TIMER_TCP_RESET); + t + tcp_reset_delay, true, + 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 // and adjust its value here, instead of creating a new 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 */) @@ -1700,11 +1700,11 @@ void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer, // deleted out from under us. if ( tcp_close_delay != 0.0 ) ADD_ANALYZER_TIMER(&TCP_Analyzer::ConnDeleteTimer, - Conn()->LastTime() + tcp_close_delay, false, - TIMER_CONN_DELETE); + Conn()->LastTime() + tcp_close_delay, false, + zeek::detail::TIMER_CONN_DELETE); else ADD_ANALYZER_TIMER(&TCP_Analyzer::DeleteTimer, Conn()->LastTime(), false, - TIMER_TCP_DELETE); + zeek::detail::TIMER_TCP_DELETE); } else @@ -1713,8 +1713,8 @@ void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer, { // First time we've seen anything from this side. if ( connection_partial_close ) ADD_ANALYZER_TIMER(&TCP_Analyzer::PartialCloseTimer, - Conn()->LastTime() + tcp_partial_close_delay, false, - TIMER_TCP_PARTIAL_CLOSE ); + Conn()->LastTime() + tcp_partial_close_delay, false, + zeek::detail::TIMER_TCP_PARTIAL_CLOSE ); } 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, // too. ADD_ANALYZER_TIMER(&TCP_Analyzer::ExpireTimer, - Conn()->LastTime() + tcp_session_timer, false, - TIMER_TCP_EXPIRE); + Conn()->LastTime() + tcp_session_timer, false, + zeek::detail::TIMER_TCP_EXPIRE); } } } diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index f6782d969d..5a3d981eec 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -250,7 +250,7 @@ bool File::IsComplete() 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) diff --git a/src/file_analysis/FileTimer.cc b/src/file_analysis/FileTimer.cc index cd85a965e6..af8d415b19 100644 --- a/src/file_analysis/FileTimer.cc +++ b/src/file_analysis/FileTimer.cc @@ -7,7 +7,7 @@ using namespace file_analysis; 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", interval, file_id.c_str()); diff --git a/src/file_analysis/FileTimer.h b/src/file_analysis/FileTimer.h index 9c5488a45f..529498d317 100644 --- a/src/file_analysis/FileTimer.h +++ b/src/file_analysis/FileTimer.h @@ -10,7 +10,7 @@ namespace file_analysis { /** * 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: /** diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 0eba859407..941106918f 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -64,7 +64,7 @@ struct Manager::Filter { struct Manager::WriterInfo { zeek::EnumVal* type; double open_time; - Timer* rotation_timer; + zeek::detail::Timer* rotation_timer; double interval; zeek::Func* postprocessor; WriterFrontend* writer; @@ -118,7 +118,7 @@ Manager::Stream::~Stream() WriterInfo* winfo = i->second; if ( winfo->rotation_timer ) - timer_mgr->Cancel(winfo->rotation_timer); + zeek::detail::timer_mgr->Cancel(winfo->rotation_timer); Unref(winfo->type); delete winfo->writer; @@ -1408,10 +1408,10 @@ zeek::RecordType* Manager::StreamColumns(zeek::EnumVal* stream_id) } // Timer which on dispatching rotates the filter. -class RotationTimer final : public Timer { +class RotationTimer final : public zeek::detail::Timer { public: 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; rotate = arg_rotate; @@ -1453,7 +1453,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo) if ( winfo->rotation_timer ) { - timer_mgr->Cancel(winfo->rotation_timer); + zeek::detail::timer_mgr->Cancel(winfo->rotation_timer); winfo->rotation_timer = nullptr; } @@ -1482,7 +1482,7 @@ void Manager::InstallRotationTimer(WriterInfo* winfo) 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", winfo->writer->Name(), winfo->rotation_timer->Time()); diff --git a/src/main.cc b/src/main.cc index d0760d9df9..63741b469f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -38,7 +38,7 @@ int main(int argc, char** argv) #endif 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);; diff --git a/src/stats.bif b/src/stats.bif index 6bc2ed4fa2..6e6f6d18a0 100644 --- a/src/stats.bif +++ b/src/stats.bif @@ -283,9 +283,9 @@ function get_timer_stats%(%): TimerStats auto r = zeek::make_intrusive(TimerStats); int n = 0; - r->Assign(n++, zeek::val_mgr->Count(unsigned(timer_mgr->Size()))); - r->Assign(n++, zeek::val_mgr->Count(unsigned(timer_mgr->PeakSize()))); - r->Assign(n++, zeek::val_mgr->Count(timer_mgr->CumulativeNum())); + r->Assign(n++, zeek::val_mgr->Count(unsigned(zeek::detail::timer_mgr->Size()))); + r->Assign(n++, zeek::val_mgr->Count(unsigned(zeek::detail::timer_mgr->PeakSize()))); + r->Assign(n++, zeek::val_mgr->Count(zeek::detail::timer_mgr->CumulativeNum())); return r; %} diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index ce2fd83f93..e211b45c9f 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -127,7 +127,7 @@ void Manager::SendHeartbeats() void Manager::StartHeartbeatTimer() { 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 @@ -250,7 +250,7 @@ void Manager::Flush() 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() diff --git a/src/threading/Manager.h b/src/threading/Manager.h index 6429baf8a4..443473954d 100644 --- a/src/threading/Manager.h +++ b/src/threading/Manager.h @@ -9,9 +9,9 @@ namespace threading { -class HeartbeatTimer final : public Timer { +class HeartbeatTimer final : public zeek::detail::Timer { public: - HeartbeatTimer(double t) : Timer(t, TIMER_THREAD_HEARTBEAT) {} + HeartbeatTimer(double t) : zeek::detail::Timer(t, zeek::detail::TIMER_THREAD_HEARTBEAT) {} virtual ~HeartbeatTimer() {} void Dispatch(double t, bool is_expire) override; diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 05b295f028..d710c456d6 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -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*& 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; threading::Manager* thread_mgr = nullptr; @@ -230,7 +231,7 @@ void done_with_network() mgr.Drain(); // Don't propagate this event to remote clients. mgr.Dispatch(new Event(net_done, - {zeek::make_intrusive(timer_mgr->Time())}), + {zeek::make_intrusive(zeek::detail::timer_mgr->Time())}), true); } @@ -240,7 +241,7 @@ void done_with_network() terminating = true; zeek::analyzer_mgr->Done(); - timer_mgr->Expire(); + zeek::detail::timer_mgr->Expire(); zeek::detail::dns_mgr->Flush(); mgr.Drain(); mgr.Drain(); @@ -282,7 +283,7 @@ void terminate_bro() if ( zeek_done ) mgr.Enqueue(zeek_done, zeek::Args{}); - timer_mgr->Expire(); + zeek::detail::timer_mgr->Expire(); mgr.Drain(); 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 #endif - timer_mgr = new PQ_TimerMgr(); + zeek::detail::timer_mgr = new zeek::detail::PQ_TimerMgr(); auto zeekygen_cfg = options.zeekygen_config_file.value_or(""); 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(); zeekygen_mgr->InitPostScript(); broker_mgr->InitPostScript(); - timer_mgr->InitPostScript(); + zeek::detail::timer_mgr->InitPostScript(); mgr.InitPostScript(); if ( zeek::supervisor_mgr ) @@ -870,7 +871,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv, zeek::reporter->ZeekInitDone(); 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)}; }