mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Improve DNS_Mgr I/O loop: prevent starvation due to busy Broker
This commit is contained in:
parent
a8281ff9f9
commit
6db576195c
2 changed files with 14 additions and 2 deletions
|
@ -392,6 +392,7 @@ DNS_Mgr::DNS_Mgr(DNS_MgrMode arg_mode)
|
||||||
successful = 0;
|
successful = 0;
|
||||||
failed = 0;
|
failed = 0;
|
||||||
nb_dns = nullptr;
|
nb_dns = nullptr;
|
||||||
|
next_timestamp = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DNS_Mgr::~DNS_Mgr()
|
DNS_Mgr::~DNS_Mgr()
|
||||||
|
@ -1252,8 +1253,17 @@ void DNS_Mgr::GetFds(iosource::FD_Set* read, iosource::FD_Set* write,
|
||||||
|
|
||||||
double DNS_Mgr::NextTimestamp(double* network_time)
|
double DNS_Mgr::NextTimestamp(double* network_time)
|
||||||
{
|
{
|
||||||
// This is kind of cheating ...
|
if ( asyncs_timeouts.empty() )
|
||||||
return asyncs_timeouts.size() ? timer_mgr->Time() : -1.0;
|
// No pending requests.
|
||||||
|
return -1.0;
|
||||||
|
|
||||||
|
if ( next_timestamp < 0 )
|
||||||
|
// Store the timestamp to help prevent starvation by some other
|
||||||
|
// IOSource always trying to use the same timestamp
|
||||||
|
// (assuming network_time does actually increase).
|
||||||
|
next_timestamp = timer_mgr->Time();
|
||||||
|
|
||||||
|
return next_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNS_Mgr::CheckAsyncAddrRequest(const IPAddr& addr, bool timeout)
|
void DNS_Mgr::CheckAsyncAddrRequest(const IPAddr& addr, bool timeout)
|
||||||
|
@ -1382,6 +1392,7 @@ void DNS_Mgr::Flush()
|
||||||
void DNS_Mgr::Process()
|
void DNS_Mgr::Process()
|
||||||
{
|
{
|
||||||
DoProcess(false);
|
DoProcess(false);
|
||||||
|
next_timestamp = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNS_Mgr::DoProcess(bool flush)
|
void DNS_Mgr::DoProcess(bool flush)
|
||||||
|
|
|
@ -236,6 +236,7 @@ protected:
|
||||||
unsigned long num_requests;
|
unsigned long num_requests;
|
||||||
unsigned long successful;
|
unsigned long successful;
|
||||||
unsigned long failed;
|
unsigned long failed;
|
||||||
|
double next_timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DNS_Mgr* dns_mgr;
|
extern DNS_Mgr* dns_mgr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue