Skip to content

Commit 2000c78

Browse files
committed
dns: delay the AresTimeout timer by 1 ms
This is because ChannelWrap::StartTimer happens before ares_calc_query_timeout usually by a few tens of microseconds but could be longer. An additional allowance of 1 ms helps reduce the chance of missing a timeout. Fixes: #65340 Signed-off-by: Peng-Yu Chen <pengyu@libstarrify.so>
1 parent ed5f5fc commit 2000c78

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/cares_wrap.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,10 @@ void ChannelWrap::StartTimer() {
10821082
int timeout = timeout_;
10831083
if (timeout <= 0 || timeout > 1000) timeout = 1000;
10841084
uv_update_time(env()->event_loop());
1085-
uv_timer_start(timer_handle_, AresTimeout, timeout, timeout);
1085+
// This is called earlier than ares_calc_query_timeout, usually by a few tens
1086+
// of microseconds but could be longer. An additional allowance of 1 ms helps
1087+
// reduce the change of missing a timeout.
1088+
uv_timer_start(timer_handle_, AresTimeout, timeout + 1, timeout);
10861089
}
10871090

10881091
void ChannelWrap::CloseTimer() {

0 commit comments

Comments
 (0)