mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +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:
parent
0e67a73bdf
commit
b57a38ae43
@ -2816,6 +2816,11 @@ internal_accept(isc__socket_t *sock) {
|
|||||||
INSIST(VALID_SOCKET(sock));
|
INSIST(VALID_SOCKET(sock));
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
|
if (sock->fd < 0) {
|
||||||
|
/* Socket is gone */
|
||||||
|
UNLOCK(&sock->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
socket_log(sock, NULL, TRACE,
|
socket_log(sock, NULL, TRACE,
|
||||||
"internal_accept called, locked socket");
|
"internal_accept called, locked socket");
|
||||||
|
|
||||||
@ -3051,6 +3056,11 @@ internal_recv(isc__socket_t *sock) {
|
|||||||
INSIST(VALID_SOCKET(sock));
|
INSIST(VALID_SOCKET(sock));
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
|
if (sock->fd < 0) {
|
||||||
|
/* Socket is gone */
|
||||||
|
UNLOCK(&sock->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
dev = ISC_LIST_HEAD(sock->recv_list);
|
dev = ISC_LIST_HEAD(sock->recv_list);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
goto finish;
|
goto finish;
|
||||||
@ -3105,6 +3115,11 @@ internal_send(isc__socket_t *sock) {
|
|||||||
INSIST(VALID_SOCKET(sock));
|
INSIST(VALID_SOCKET(sock));
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
|
if (sock->fd < 0) {
|
||||||
|
/* Socket is gone */
|
||||||
|
UNLOCK(&sock->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
dev = ISC_LIST_HEAD(sock->send_list);
|
dev = ISC_LIST_HEAD(sock->send_list);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
goto finish;
|
goto finish;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user