#include "ares_private.h"Include dependency graph for ares_timeout.c:
Go to the source code of this file.
Functions | |
| timeval * | ares_timeout (ares_channel channel, struct timeval *maxtv, struct timeval *tvbuf) |
|
||||||||||||||||
|
Definition at line 25 of file ares_timeout.c. References ares_channel, query::next, ares_channeldata::queries, time, timeval::tv_sec, and timeval::tv_usec. Referenced by dns_client(), and gethostbynameaddr().
00027 {
00028 struct query *query;
00029 time_t now;
00030 int offset, min_offset;
00031
00032 /* No queries, no timeout (and no fetch of the current time). */
00033 if (!channel->queries)
00034 return maxtv;
00035
00036 /* Find the minimum timeout for the current set of queries. */
00037 time(&now);
00038 min_offset = -1;
00039 for (query = channel->queries; query; query = query->next)
00040 {
00041 if (query->timeout == 0)
00042 continue;
00043 offset = query->timeout - now;
00044 if (offset < 0)
00045 offset = 0;
00046 if (min_offset == -1 || offset < min_offset)
00047 min_offset = offset;
00048 }
00049
00050 /* If we found a minimum timeout and it's sooner than the one
00051 * specified in maxtv (if any), return it. Otherwise go with
00052 * maxtv.
00053 */
00054 if (min_offset != -1 && (!maxtv || min_offset <= maxtv->tv_sec))
00055 {
00056 tvbuf->tv_sec = min_offset;
00057 tvbuf->tv_usec = 0;
00058 return tvbuf;
00059 }
00060 else
00061 return maxtv;
00062 }
|
1.3.4