mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
iosource/Manager: Honor manage_lifetime and dont_count for short-lived IO sources
If an IO source is registered and becomes dry at runtime, the IO manager would not honor its manage_lifetime or dont_count attribute during collection, resulting in memory leaks. This probably hasn't mattered so far as there's no IO sources registered in-tree at runtime using manage_lifetime=true.
This commit is contained in:
parent
43804fa3b5
commit
fcca8670d3
2 changed files with 39 additions and 8 deletions
|
@ -104,6 +104,22 @@ void Manager::Wakeup(std::string_view where) {
|
|||
wakeup->Ping(where);
|
||||
}
|
||||
|
||||
void Manager::ReapSource(Source* src) {
|
||||
auto* iosource = src->src;
|
||||
assert(! iosource->IsOpen());
|
||||
|
||||
DBG_LOG(DBG_MAINLOOP, "Reaping %s", src->src->Tag());
|
||||
iosource->Done();
|
||||
|
||||
if ( src->manage_lifetime )
|
||||
delete iosource;
|
||||
|
||||
if ( src->dont_count )
|
||||
dont_counts--;
|
||||
|
||||
delete src;
|
||||
}
|
||||
|
||||
void Manager::FindReadySources(ReadySources* ready) {
|
||||
ready->clear();
|
||||
|
||||
|
@ -111,8 +127,7 @@ void Manager::FindReadySources(ReadySources* ready) {
|
|||
// remove at most one each time.
|
||||
for ( SourceList::iterator i = sources.begin(); i != sources.end(); ++i )
|
||||
if ( ! (*i)->src->IsOpen() ) {
|
||||
(*i)->src->Done();
|
||||
delete *i;
|
||||
ReapSource(*i);
|
||||
sources.erase(i);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue