diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index 00fc61ff5c..57f3caecdf 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -136,6 +136,8 @@ void Manager::FindReadySources(std::vector* ready) if ( iosource->IsOpen() ) { double next = iosource->GetNextTimeout(); + bool added = false; + if ( timeout == -1 || ( next >= 0.0 && next < timeout ) ) { timeout = next; @@ -146,13 +148,29 @@ void Manager::FindReadySources(std::vector* ready) // we don't want things in the vector passed into Poll() or it'll end // up inserting duplicates. if ( timeout == 0 && ! time_to_poll ) + { + added = true; ready->push_back(timeout_src); + } } - // 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. - if ( ! time_to_poll && iosource == pkt_src && pkt_src->IsLive() ) - ready->push_back(pkt_src); + if ( iosource == pkt_src && ! added ) + { + 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); + } + else + { + if ( ! pseudo_realtime ) + // A pcap file is always ready to process. + ready->push_back(pkt_src); + } + } } } diff --git a/testing/btest/Baseline/core.network-time-init/out b/testing/btest/Baseline/core.network-time-init/out new file mode 100644 index 0000000000..0324e77fa6 --- /dev/null +++ b/testing/btest/Baseline/core.network-time-init/out @@ -0,0 +1,2 @@ +0.0 +1362692526.869344 diff --git a/testing/btest/core/network-time-init.zeek b/testing/btest/core/network-time-init.zeek new file mode 100644 index 0000000000..cea9b3f85f --- /dev/null +++ b/testing/btest/core/network-time-init.zeek @@ -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() }; + }