diff --git a/CHANGES b/CHANGES index db2ac6a730..87f5e01a48 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +5243. [bug] Fix a possible race between dispatcher and socket + code in a high-load cold-cache resolver scenario. + [GL #943] + 5242. [bug] In relaxed qname minimizatiom mode, fall back to normal resolution when encountering a lame delegation, and use _.domain/A queries rather diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 2c97e6e697..fc93d369b5 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -2596,15 +2596,16 @@ isc_socket_open(isc_socket_t *sock0) { REQUIRE(VALID_SOCKET(sock)); - REQUIRE(isc_refcount_current(&sock->references) == 1); - /* - * We don't need to retain the lock hereafter, since no one else has - * this socket. - */ + LOCK(&sock->lock); + + REQUIRE(isc_refcount_current(&sock->references) >= 1); REQUIRE(sock->fd == -1); REQUIRE(sock->threadid == -1); result = opensocket(sock->manager, sock, NULL); + + UNLOCK(&sock->lock); + if (result != ISC_R_SUCCESS) { sock->fd = -1; } else {