iosource/Manager: Do not manage lifetime of pkt_src

Now that dry sources are properly reaped and freed, an offline packet
source would be deleted once dry, resulting in GetPktSrc() returning
a wild pointer. Don't manage the packet source lifetime and instead
free it during Manager destruction.
This commit is contained in:
Arne Welzel 2024-06-18 12:38:53 +02:00
parent fcca8670d3
commit 0451a4038c

View file

@ -76,6 +76,9 @@ Manager::~Manager() {
pkt_dumpers.clear(); pkt_dumpers.clear();
// Was registered without lifetime management.
delete pkt_src;
#ifndef _MSC_VER #ifndef _MSC_VER
// There's a bug here with builds on Windows that causes an assertion with debug builds // There's a bug here with builds on Windows that causes an assertion with debug builds
// related to libkqueue returning a zero for the file descriptor. The assert happens // related to libkqueue returning a zero for the file descriptor. The assert happens
@ -357,7 +360,7 @@ void Manager::Register(IOSource* src, bool dont_count, bool manage_lifetime) {
void Manager::Register(PktSrc* src) { void Manager::Register(PktSrc* src) {
pkt_src = src; pkt_src = src;
Register(src, false); Register(src, false, false);
// Once we know if the source is live or not, adapt the // Once we know if the source is live or not, adapt the
// poll_interval accordingly. // poll_interval accordingly.