mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
DNS_Mgr: Remove usage of ares_getsock from GetNextTimeout
This commit is contained in:
parent
16474ed77f
commit
6739fca645
1 changed files with 10 additions and 14 deletions
|
@ -1315,23 +1315,19 @@ double DNS_Mgr::GetNextTimeout() {
|
||||||
if ( asyncs_pending == 0 )
|
if ( asyncs_pending == 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int nfds = 0;
|
struct timeval tv;
|
||||||
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
|
struct timeval* tvp = ares_timeout(channel, NULL, &tv);
|
||||||
int bitmap = ares_getsock(channel, socks, ARES_GETSOCK_MAXNUM);
|
|
||||||
for ( int i = 0; i < ARES_GETSOCK_MAXNUM; i++ ) {
|
|
||||||
if ( ARES_GETSOCK_READABLE(bitmap, i) || ARES_GETSOCK_WRITABLE(bitmap, i) )
|
|
||||||
++nfds;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do we have any sockets that are read or writable?
|
// If you pass NULL as the max time argument to ares_timeout, it will return null if there
|
||||||
if ( nfds == 0 )
|
// isn't anything waiting to be processed.
|
||||||
|
if ( ! tvp )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
struct timeval tv;
|
// Clamp the timeout to our desired max, since we passed NULl to ares_timeout.
|
||||||
tv.tv_sec = DNS_TIMEOUT;
|
if ( tvp->tv_sec > DNS_TIMEOUT ) {
|
||||||
tv.tv_usec = 0;
|
tvp->tv_sec = DNS_TIMEOUT;
|
||||||
|
tvp->tv_usec = 0;
|
||||||
struct timeval* tvp = ares_timeout(channel, &tv, &tv);
|
}
|
||||||
|
|
||||||
return static_cast<double>(tvp->tv_sec) + (static_cast<double>(tvp->tv_usec) / 1e6);
|
return static_cast<double>(tvp->tv_sec) + (static_cast<double>(tvp->tv_usec) / 1e6);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue