2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

Fix a race in socket code when internal_{accept, send, receive} is called

from event loop on an socket and, in the meantime, someone has closed this
socket.
This commit is contained in:
Witold Kręcicki
2019-02-15 11:28:58 +01:00
committed by Evan Hunt
parent 0e67a73bdf
commit b57a38ae43

View File

@@ -2816,6 +2816,11 @@ internal_accept(isc__socket_t *sock) {
INSIST(VALID_SOCKET(sock));
LOCK(&sock->lock);
if (sock->fd < 0) {
/* Socket is gone */
UNLOCK(&sock->lock);
return;
}
socket_log(sock, NULL, TRACE,
"internal_accept called, locked socket");
@@ -3051,6 +3056,11 @@ internal_recv(isc__socket_t *sock) {
INSIST(VALID_SOCKET(sock));
LOCK(&sock->lock);
if (sock->fd < 0) {
/* Socket is gone */
UNLOCK(&sock->lock);
return;
}
dev = ISC_LIST_HEAD(sock->recv_list);
if (dev == NULL) {
goto finish;
@@ -3105,6 +3115,11 @@ internal_send(isc__socket_t *sock) {
INSIST(VALID_SOCKET(sock));
LOCK(&sock->lock);
if (sock->fd < 0) {
/* Socket is gone */
UNLOCK(&sock->lock);
return;
}
dev = ISC_LIST_HEAD(sock->send_list);
if (dev == NULL) {
goto finish;