reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ares_timeout.c
Go to the documentation of this file.
1
/* Copyright 1998 by the Massachusetts Institute of Technology.
2
*
3
* Permission to use, copy, modify, and distribute this
4
* software and its documentation for any purpose and without
5
* fee is hereby granted, provided that the above copyright
6
* notice appear in all copies and that both that copyright
7
* notice and this permission notice appear in supporting
8
* documentation, and that the name of M.I.T. not be used in
9
* advertising or publicity pertaining to distribution of the
10
* software without specific, written prior permission.
11
* M.I.T. makes no representations about the suitability of
12
* this software for any purpose. It is provided "as is"
13
* without express or implied warranty.
14
*/
15
16
#include <sys/types.h>
17
#include <time.h>
18
#include "
ares.h
"
19
#include "
ares_private.h
"
20
#ifndef WIN32
21
#include <sys/time.h>
22
#endif
23
24
struct
timeval
*
ares_timeout
(
ares_channel
channel,
struct
timeval
*
maxtv
,
25
struct
timeval
*
tvbuf
)
26
{
27
struct
query
*
query
;
28
time_t
now;
29
time_t
offset,
min_offset
;
30
31
/* No queries, no timeout (and no fetch of the current time). */
32
if
(!channel->
queries
)
33
return
maxtv
;
34
35
/* Find the minimum timeout for the current set of queries. */
36
time(&now);
37
min_offset
= -1;
38
for
(
query
= channel->
queries
;
query
;
query
=
query
->
next
)
39
{
40
if
(
query
->
timeout
== 0)
41
continue
;
42
offset =
query
->
timeout
- now;
43
if
(offset < 0)
44
offset = 0;
45
if
(
min_offset
== -1 || offset <
min_offset
)
46
min_offset
= offset;
47
}
48
49
/* If we found a minimum timeout and it's sooner than the one
50
* specified in maxtv (if any), return it. Otherwise go with
51
* maxtv.
52
*/
53
if
(
min_offset
!= -1 && (!
maxtv
||
min_offset <= maxtv->
tv_sec))
54
{
55
tvbuf
->tv_sec = (
long
)
min_offset
;
56
tvbuf
->tv_usec = 0;
57
return
tvbuf
;
58
}
59
else
60
return
maxtv
;
61
}
ares.h
ares_private.h
ares_timeout
struct timeval * ares_timeout(ares_channel channel, struct timeval *maxtv, struct timeval *tvbuf)
Definition
ares_timeout.c:24
ares_channeldata
Definition
ares_private.h:118
ares_channeldata::queries
struct query * queries
Definition
ares_private.h:140
query
Definition
ares_private.h:86
query::next
struct query * next
Definition
ares_private.h:109
query::timeout
time_t timeout
Definition
ares_private.h:89
list
void list()
Definition
userAdmin.cxx:66
rutil
dns
ares
ares_timeout.c
Generated by
1.9.8