diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index ec935bb00c..7c53ec2325 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -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