mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-938: fix IO loop iterations sometimes skipping offline pcap sources
This commit is contained in:
parent
fda9498276
commit
1b190906c7
3 changed files with 39 additions and 4 deletions
|
@ -136,6 +136,8 @@ void Manager::FindReadySources(std::vector<IOSource*>* ready)
|
||||||
if ( iosource->IsOpen() )
|
if ( iosource->IsOpen() )
|
||||||
{
|
{
|
||||||
double next = iosource->GetNextTimeout();
|
double next = iosource->GetNextTimeout();
|
||||||
|
bool added = false;
|
||||||
|
|
||||||
if ( timeout == -1 || ( next >= 0.0 && next < timeout ) )
|
if ( timeout == -1 || ( next >= 0.0 && next < timeout ) )
|
||||||
{
|
{
|
||||||
timeout = next;
|
timeout = next;
|
||||||
|
@ -146,14 +148,30 @@ void Manager::FindReadySources(std::vector<IOSource*>* ready)
|
||||||
// we don't want things in the vector passed into Poll() or it'll end
|
// we don't want things in the vector passed into Poll() or it'll end
|
||||||
// up inserting duplicates.
|
// up inserting duplicates.
|
||||||
if ( timeout == 0 && ! time_to_poll )
|
if ( timeout == 0 && ! time_to_poll )
|
||||||
|
{
|
||||||
|
added = true;
|
||||||
ready->push_back(timeout_src);
|
ready->push_back(timeout_src);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid calling Poll() if we can help it since on very high-traffic
|
if ( iosource == pkt_src && ! added )
|
||||||
// networks, we spend too much time in Poll() and end up dropping packets.
|
{
|
||||||
if ( ! time_to_poll && iosource == pkt_src && pkt_src->IsLive() )
|
if ( pkt_src->IsLive() )
|
||||||
|
{
|
||||||
|
if ( ! time_to_poll )
|
||||||
|
// Avoid calling Poll() if we can help it since on very
|
||||||
|
// high-traffic networks, we spend too much time in
|
||||||
|
// Poll() and end up dropping packets.
|
||||||
ready->push_back(pkt_src);
|
ready->push_back(pkt_src);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ! pseudo_realtime )
|
||||||
|
// A pcap file is always ready to process.
|
||||||
|
ready->push_back(pkt_src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_LOG(DBG_MAINLOOP, "timeout: %f ready size: %zu time_to_poll: %d\n",
|
DBG_LOG(DBG_MAINLOOP, "timeout: %f ready size: %zu time_to_poll: %d\n",
|
||||||
|
|
2
testing/btest/Baseline/core.network-time-init/out
Normal file
2
testing/btest/Baseline/core.network-time-init/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
0.0
|
||||||
|
1362692526.869344
|
15
testing/btest/core/network-time-init.zeek
Normal file
15
testing/btest/core/network-time-init.zeek
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# @TEST-EXEC: zeek -b -r $TRACES/http/get.trace %INPUT >out
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
event my_init()
|
||||||
|
{
|
||||||
|
# Expect time to be initialized (PktSrc was processed at least once).
|
||||||
|
print network_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
# Expect time to be zero
|
||||||
|
print network_time();
|
||||||
|
schedule 0sec { my_init() };
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue