mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Fix a possible race between udp dispatch and socket code
There's a small possibility of race between udp dispatcher and socket code - socket code can still hold internal reference to a socket while dispatcher calls isc_socket_open, which can cause an assertion failure. Fix it by relaxing the assertion test, and instead simply locking the socket in isc_socket_open.
This commit is contained in:
committed by
Evan Hunt
parent
126b3e0bd7
commit
e517c18d98
@@ -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 {
|
||||
|
Reference in New Issue
Block a user