mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Move the lock from internal_{accept,connect,recv,send} to global level to protect more socket variables
This commit is contained in:
parent
43f3b3211f
commit
9808d7360e
@ -2778,10 +2778,8 @@ 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,
|
||||
@ -2800,7 +2798,6 @@ internal_accept(isc__socket_t *sock) {
|
||||
dev = ISC_LIST_HEAD(sock->accept_list);
|
||||
if (dev == NULL) {
|
||||
unwatch_fd(thread, sock->fd, SELECT_POKE_ACCEPT);
|
||||
UNLOCK(&sock->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2916,11 +2913,10 @@ internal_accept(isc__socket_t *sock) {
|
||||
/*
|
||||
* Poke watcher if there are more pending accepts.
|
||||
*/
|
||||
if (ISC_LIST_EMPTY(sock->accept_list))
|
||||
if (ISC_LIST_EMPTY(sock->accept_list)) {
|
||||
unwatch_fd(thread, sock->fd,
|
||||
SELECT_POKE_ACCEPT);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
}
|
||||
|
||||
if (fd != -1) {
|
||||
result = make_nonblock(fd);
|
||||
@ -3017,7 +3013,6 @@ internal_accept(isc__socket_t *sock) {
|
||||
|
||||
soft_error:
|
||||
watch_fd(thread, sock->fd, SELECT_POKE_ACCEPT);
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]);
|
||||
return;
|
||||
@ -3029,10 +3024,8 @@ 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);
|
||||
@ -3079,7 +3072,6 @@ internal_recv(isc__socket_t *sock) {
|
||||
unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd,
|
||||
SELECT_POKE_READ);
|
||||
}
|
||||
UNLOCK(&sock->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3088,10 +3080,8 @@ 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);
|
||||
@ -3125,7 +3115,6 @@ internal_send(isc__socket_t *sock) {
|
||||
unwatch_fd(&sock->manager->threads[sock->threadid],
|
||||
sock->fd, SELECT_POKE_WRITE);
|
||||
}
|
||||
UNLOCK(&sock->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3166,6 +3155,7 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable,
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK(&sock->lock);
|
||||
if (readable) {
|
||||
if (sock->listener) {
|
||||
internal_accept(sock);
|
||||
@ -3181,6 +3171,7 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable,
|
||||
internal_send(sock);
|
||||
}
|
||||
}
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
UNLOCK(&thread->fdlock[lockid]);
|
||||
if (isc_refcount_decrement(&sock->references) == 1) {
|
||||
@ -4875,8 +4866,6 @@ internal_connect(isc__socket_t *sock) {
|
||||
|
||||
INSIST(VALID_SOCKET(sock));
|
||||
|
||||
LOCK(&sock->lock);
|
||||
|
||||
/*
|
||||
* Get the first item off the connect list.
|
||||
* If it is empty, unlock the socket and return.
|
||||
@ -4907,7 +4896,6 @@ internal_connect(isc__socket_t *sock) {
|
||||
*/
|
||||
if (SOFT_ERROR(errno) || errno == EINPROGRESS) {
|
||||
sock->connecting = 1;
|
||||
UNLOCK(&sock->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4960,8 +4948,6 @@ internal_connect(isc__socket_t *sock) {
|
||||
finish:
|
||||
unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd,
|
||||
SELECT_POKE_CONNECT);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
Loading…
x
Reference in New Issue
Block a user