diff --git a/src/lib/ares__threads.c b/src/lib/ares__threads.c index 44442357..f748b578 100644 --- a/src/lib/ares__threads.c +++ b/src/lib/ares__threads.c @@ -586,9 +586,11 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms) ares__thread_cond_timedwait(channel->cond_empty, channel->lock, tms); } - /* Either there was a timeout or we were signaled that the queue was - * empty. Don't loop */ - break; + /* If there was a timeout, don't loop. Otherwise, make sure this wasn't + * a spurious wakeup by looping and checking the condition. */ + if (status == ARES_ETIMEOUT) { + break; + } } } ares__thread_mutex_unlock(channel->lock);