Skip to content

Commit

Permalink
fix data race in us_internal_handle_dns_result (#11201)
Browse files Browse the repository at this point in the history
Co-authored-by: Georgijs Vilums <=>
  • Loading branch information
gvilums authored May 20, 2024
1 parent ff1db36 commit 06a9aa8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/bun-usockets/src/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ void us_internal_drain_pending_dns_resolve(struct us_loop_t *loop, struct us_con
}

int us_internal_handle_dns_results(struct us_loop_t *loop) {
struct us_connecting_socket_t *s = __atomic_exchange_n(&loop->data.dns_ready_head, NULL, __ATOMIC_ACQ_REL);
Bun__lock(&loop->data.mutex);
struct us_connecting_socket_t *s = loop->data.dns_ready_head;
loop->data.dns_ready_head = NULL;
Bun__unlock(&loop->data.mutex);
us_internal_drain_pending_dns_resolve(loop, s);
return s != NULL;
}
Expand Down

0 comments on commit 06a9aa8

Please sign in to comment.