Skip to content

Commit 74a64e4

Browse files
committed
ares_timeout: missing thread-safety lock
1 parent ef186fe commit 74a64e4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/lib/ares_timeout.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ static void struct_timeval_to_ares_timeval(ares_timeval_t *atv, const struct tim
8484
atv->usec = (unsigned int)tv->tv_usec;
8585
}
8686

87-
struct timeval *ares_timeout(const ares_channel_t *channel,
88-
struct timeval *maxtv, struct timeval *tvbuf)
87+
static struct timeval *ares_timeout_int(const ares_channel_t *channel,
88+
struct timeval *maxtv,
89+
struct timeval *tvbuf)
8990
{
9091
const struct query *query;
9192
ares__slist_node_t *node;
@@ -130,3 +131,20 @@ struct timeval *ares_timeout(const ares_channel_t *channel,
130131

131132
return tvbuf;
132133
}
134+
135+
struct timeval *ares_timeout(const ares_channel_t *channel,
136+
struct timeval *maxtv, struct timeval *tvbuf)
137+
{
138+
struct timeval *rv;
139+
140+
if (channel == NULL || tvbuf == NULL)
141+
return NULL;
142+
143+
ares__channel_lock(channel);
144+
145+
rv = ares_timeout_int(channel, maxtv, tvbuf);
146+
147+
ares__channel_unlock(channel);
148+
149+
return rv;
150+
}

0 commit comments

Comments
 (0)