Skip to content

Commit

Permalink
Silence TSAN, lock before checking ares_event_thread::isup (c-ares#915
Browse files Browse the repository at this point in the history
)

TSAN is warning about a thread concurrency issue that doesn't actually matter if the operation isn't atomic as its an optimization in this code path to skip timeout processing if we're shutting down due to ares_destroy().

Fix By: Jiwoo Park (@jimmy-park)
  • Loading branch information
jimmy-park authored Nov 9, 2024
1 parent cd6602b commit bd5561b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/event/ares_event_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,16 @@ static void *ares_event_thread(void *arg)
ares_process_pending_write(e->channel);
}

/* Relock before we loop again */
ares_thread_mutex_lock(e->mutex);

/* Each iteration should do timeout processing and any other cleanup
* that may not have been performed */
if (e->isup) {
ares_thread_mutex_unlock(e->mutex);
ares_process_fds(e->channel, NULL, 0, ARES_PROCESS_FLAG_NONE);
ares_thread_mutex_lock(e->mutex);
}

/* Relock before we loop again */
ares_thread_mutex_lock(e->mutex);
}

/* Lets cleanup while we're in the thread itself */
Expand Down

0 comments on commit bd5561b

Please sign in to comment.