Merge branch 'topic/jgras/shutdown-session-clear' of https://github.com/J-Gras/zeek

* 'topic/jgras/shutdown-session-clear' of https://github.com/J-Gras/zeek:
  Remove finish_run()
  Deprecate session manager's Done()
  Clear sessions when session manager is done
This commit is contained in:
Arne Welzel 2025-04-17 15:20:27 +02:00
commit 2f0be32f5f
7 changed files with 20 additions and 34 deletions

12
CHANGES
View file

@ -1,3 +1,15 @@
7.2.0-dev.548 | 2025-04-17 15:20:27 +0200
* Remove finish_run() (Jan Grashoefer, Corelight)
* Deprecate session manager's Done() (Jan Grashoefer, Corelight)
* Clear sessions when session manager is done (Jan Grashoefer, Corelight)
It looks like there is no reason to keep sessions in the map beyond the
point where the session manager is considered done. This hopefully
simplifies the shutdown control flow a tiny bit.
7.2.0-dev.544 | 2025-04-16 15:40:52 -0700
* Suppress warnings from compilation of external ixwebsocket dependency (Benjamin Bannier, Corelight)

View file

@ -1 +1 @@
7.2.0-dev.544
7.2.0-dev.548

View file

@ -106,7 +106,7 @@ RETSIGTYPE watchdog(int /* signo */) {
}
get_final_stats();
finish_run(0);
util::detail::set_processing_status("TERMINATING", "watchdog");
reporter->FatalErrorWithCore("**watchdog timer expired, t = %d.%06d, start = %d.%06d, dispatched = %d",
int_ct, frac_ct, int_pst, frac_pst, current_dispatched);
@ -340,9 +340,7 @@ void run_loop() {
}
}
// Get the final statistics now, and not when finish_run() is
// called, since that might happen quite a bit in the future
// due to expiring pending timers, and we don't want to ding
// Get the final statistics now, as we don't want to ding
// for any packets dropped beyond this point.
get_final_stats();
}
@ -375,29 +373,6 @@ void get_final_stats() {
}
}
void finish_run(int drain_events) {
util::detail::set_processing_status("TERMINATING", "finish_run");
if ( drain_events ) {
if ( session_mgr )
session_mgr->Drain();
event_mgr.Drain();
if ( session_mgr )
session_mgr->Done();
}
#ifdef DEBUG
extern int reassem_seen_bytes, reassem_copied_bytes;
// DEBUG_MSG("Reassembly (TCP and IP/Frag): %d bytes seen, %d bytes copied\n",
// reassem_seen_bytes, reassem_copied_bytes);
extern int num_packets_held, num_packets_cleaned;
// DEBUG_MSG("packets clean up: %d/%d\n", num_packets_cleaned, num_packets_held);
#endif
}
void delete_run() {
util::detail::set_processing_status("TERMINATING", "delete_run");

View file

@ -26,7 +26,6 @@ extern void init_run(const std::optional<std::string>& interfaces, const std::op
const std::optional<std::string>& pcap_output_file, bool do_watchdog);
extern void run_loop();
extern void get_final_stats();
extern void finish_run(int drain_events);
extern void delete_run(); // Reclaim all memory, etc.
extern void update_network_time(double new_network_time);
extern void dispatch_packet(zeek::Packet* pkt, zeek::iosource::PktSrc* pkt_src);

View file

@ -87,8 +87,6 @@ Manager::~Manager() {
delete stats;
}
void Manager::Done() {}
Connection* Manager::FindConnection(Val* v) {
zeek::detail::ConnKey conn_key(v);

View file

@ -59,7 +59,8 @@ public:
Manager();
~Manager();
void Done(); // call to drain events before destructing
[[deprecated("Remove in v8.1 - no functionality. Use Drain() and Clear().")]]
void Done() {};
// Looks up the connection referred to by the given Val,
// which should be a conn_id record. Returns nil if there's

View file

@ -322,7 +322,9 @@ static void done_with_network() {
event_mgr.Drain();
event_mgr.Drain();
run_state::detail::finish_run(1);
session_mgr->Drain();
event_mgr.Drain();
session_mgr->Clear();
#ifdef USE_PERFTOOLS_DEBUG
@ -391,7 +393,6 @@ static void terminate_zeek() {
event_mgr.Drain();
session_mgr->Clear();
plugin_mgr->FinishPlugins();
finish_script_execution();