mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 04:12:08 -04:00
Merge branch '874-fix-race-in-socket-code' into 'master'
Fix a race in socket code Closes #874 See merge request isc-projects/bind9!1590
This commit is contained in:
commit
52d90da41e
2 changed files with 20 additions and 0 deletions
5
CHANGES
5
CHANGES
|
|
@ -1,3 +1,8 @@
|
|||
5173. [bug] Fixed a race in socket code that could occur when
|
||||
accept, send, or recv were called from an event
|
||||
loop but the socket had been closed by another
|
||||
thread. [RT #874]
|
||||
|
||||
5172. [bug] nsupdate now honors the operating system's preferred
|
||||
ephemeral port range. [GL #905]
|
||||
|
||||
|
|
|
|||
|
|
@ -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