Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
third_party
cares
cares
src
lib
ares_timeout.c
Go to the documentation of this file.
1
2
/* Copyright 1998 by the Massachusetts Institute of Technology.
3
*
4
* Permission to use, copy, modify, and distribute this
5
* software and its documentation for any purpose and without
6
* fee is hereby granted, provided that the above copyright
7
* notice appear in all copies and that both that copyright
8
* notice and this permission notice appear in supporting
9
* documentation, and that the name of M.I.T. not be used in
10
* advertising or publicity pertaining to distribution of the
11
* software without specific, written prior permission.
12
* M.I.T. makes no representations about the suitability of
13
* this software for any purpose. It is provided "as is"
14
* without express or implied warranty.
15
*/
16
17
#include "
ares_setup.h
"
18
19
#ifdef HAVE_LIMITS_H
20
#include <limits.h>
21
#endif
22
23
#include "
ares.h
"
24
#include "
ares_private.h
"
25
26
/* return time offset between now and (future) check, in milliseconds */
27
static
long
timeoffset
(
struct
timeval
*
now
,
struct
timeval
*
check
)
28
{
29
return
(
check
->tv_sec -
now
->tv_sec)*1000 +
30
(
check
->tv_usec -
now
->tv_usec)/1000;
31
}
32
33
/* WARNING: Beware that this is linear in the number of outstanding
34
* requests! You are probably far better off just calling ares_process()
35
* once per second, rather than calling ares_timeout() to figure out
36
* when to next call ares_process().
37
*/
38
struct
timeval
*
ares_timeout
(
ares_channel
channel
,
struct
timeval
*maxtv,
39
struct
timeval
*tvbuf)
40
{
41
struct
query
*
query
;
42
struct
list_node
* list_head;
43
struct
list_node
*
list_node
;
44
struct
timeval
now
;
45
struct
timeval
nextstop;
46
long
offset
, min_offset;
47
48
/* No queries, no timeout (and no fetch of the current time). */
49
if
(
ares__is_list_empty
(&(
channel
->all_queries)))
50
return
maxtv;
51
52
/* Find the minimum timeout for the current set of queries. */
53
now
=
ares__tvnow
();
54
min_offset = -1;
55
56
list_head = &(
channel
->all_queries);
57
for
(
list_node
= list_head->
next
;
list_node
!= list_head;
58
list_node
=
list_node
->
next
)
59
{
60
query
=
list_node
->
data
;
61
if
(
query
->
timeout
.
tv_sec
== 0)
62
continue
;
63
offset
=
timeoffset
(&
now
, &
query
->
timeout
);
64
if
(
offset
< 0)
65
offset
= 0;
66
if
(min_offset == -1 ||
offset
< min_offset)
67
min_offset =
offset
;
68
}
69
70
/* If we found a minimum timeout and it's sooner than the one specified in
71
* maxtv (if any), return it. Otherwise go with maxtv.
72
*/
73
if
(min_offset != -1)
74
{
75
int
ioffset = (min_offset > (
long
)INT_MAX) ? INT_MAX : (
int
)min_offset;
76
77
nextstop.
tv_sec
= ioffset/1000;
78
nextstop.
tv_usec
= (ioffset%1000)*1000;
79
80
if
(!maxtv ||
ares__timedout
(maxtv, &nextstop))
81
{
82
*tvbuf = nextstop;
83
return
tvbuf;
84
}
85
}
86
87
return
maxtv;
88
}
now
static double now(void)
Definition:
test/core/fling/client.cc:130
ares.h
list_node::data
void * data
Definition:
ares_llist.h:25
ares_timeout
struct timeval * ares_timeout(ares_channel channel, struct timeval *maxtv, struct timeval *tvbuf)
Definition:
ares_timeout.c:38
ares__is_list_empty
int ares__is_list_empty(struct list_node *head)
Definition:
ares_llist.c:41
query
Definition:
ares_private.h:198
channel
wrapped_grpc_channel * channel
Definition:
src/php/ext/grpc/call.h:33
xds_interop_client.int
int
Definition:
xds_interop_client.py:113
ares_setup.h
ares_channeldata
Definition:
ares_private.h:266
timeval::tv_sec
long tv_sec
Definition:
setup_once.h:121
timeval::tv_usec
long tv_usec
Definition:
setup_once.h:122
ares__timedout
int ares__timedout(struct timeval *now, struct timeval *check)
Definition:
ares_process.c:89
ares__tvnow
struct timeval ares__tvnow(void)
Definition:
ares__timeval.c:85
timeval
Definition:
setup_once.h:113
timeoffset
static long timeoffset(struct timeval *now, struct timeval *check)
Definition:
ares_timeout.c:27
list_node
Definition:
ares_llist.h:22
check
static void check(upb_inttable *t)
Definition:
bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1715
ares_private.h
list_node::next
struct list_node * next
Definition:
ares_llist.h:24
query::timeout
struct timeval timeout
Definition:
ares_private.h:201
offset
voidpf uLong offset
Definition:
bloaty/third_party/zlib/contrib/minizip/ioapi.h:142
google::protobuf.internal.decoder.long
long
Definition:
bloaty/third_party/protobuf/python/google/protobuf/internal/decoder.py:89
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:33