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.
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 {