From a9f8627dd9d6eccacc3e61e184656b42d8585b2c Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 14 Mar 2023 17:53:43 +0100 Subject: [PATCH] PktSrc: Move termination pseduo_realtime special case to RunState This also removes setting pseduo_realtime to 0.0 in the main loop when the packet source has been closed. I had tried to understand the implications it actually seems, if we shutdown the iosource::Manager anyway, it shouldn't and it's just confusing. --- src/RunState.cc | 12 ++++-------- src/iosource/PktSrc.cc | 6 ------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/RunState.cc b/src/RunState.cc index 67041cc915..3188f4b63c 100644 --- a/src/RunState.cc +++ b/src/RunState.cc @@ -352,17 +352,13 @@ void run_loop() // the future on which we need to wait. have_pending_timers = zeek::detail::timer_mgr->Size() > 0; + // Terminate if we're running pseudo_realtime and + // the interface has been closed. if ( pseudo_realtime && communication_enabled ) { - auto have_active_packet_source = false; - iosource::PktSrc* ps = iosource_mgr->GetPktSrc(); - if ( ps && ps->IsOpen() ) - have_active_packet_source = true; - - if ( ! have_active_packet_source ) - // Can turn off pseudo realtime now - pseudo_realtime = 0.0; + if ( ps && ! ps->IsOpen() ) + iosource_mgr->Terminate(); } } diff --git a/src/iosource/PktSrc.cc b/src/iosource/PktSrc.cc index a7940250df..2ca5d2720e 100644 --- a/src/iosource/PktSrc.cc +++ b/src/iosource/PktSrc.cc @@ -194,12 +194,6 @@ bool PktSrc::ExtractNextPacketInternal() had_packet = false; } - if ( run_state::pseudo_realtime && ! IsOpen() ) - { - if ( broker_mgr->Active() ) - iosource_mgr->Terminate(); - } - return false; }