mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-08 18:42:04 -04: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:
parent
0e67a73bdf
commit
b57a38ae43
1 changed files with 15 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue