mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
address race condition with multiple isc_socket_connect calls in change 4041
This commit is contained in:
@@ -5719,6 +5719,16 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
|
|||||||
goto queue;
|
goto queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sock->connected) {
|
||||||
|
INSIST(isc_sockaddr_equal(&sock->peer_address, addr));
|
||||||
|
dev->result = ISC_R_SUCCESS;
|
||||||
|
isc_task_send(task, ISC_EVENT_PTR(&dev));
|
||||||
|
|
||||||
|
UNLOCK(&sock->lock);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to do the connect right away, as there can be only one
|
* Try to do the connect right away, as there can be only one
|
||||||
* outstanding, and it might happen to complete.
|
* outstanding, and it might happen to complete.
|
||||||
|
@@ -3579,6 +3579,15 @@ isc__socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
|
|||||||
}
|
}
|
||||||
ISC_LINK_INIT(cdev, ev_link);
|
ISC_LINK_INIT(cdev, ev_link);
|
||||||
|
|
||||||
|
if (sock->connected) {
|
||||||
|
INSIST(isc_sockaddr_equal(&sock->address, addr));
|
||||||
|
cdev->result = ISC_R_SUCCESS;
|
||||||
|
isc_task_send(task, ISC_EVENT_PTR(&cdev));
|
||||||
|
|
||||||
|
UNLOCK(&sock->lock);
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
if ((sock->type == isc_sockettype_tcp) && !sock->pending_connect) {
|
if ((sock->type == isc_sockettype_tcp) && !sock->pending_connect) {
|
||||||
/*
|
/*
|
||||||
* Queue io completion for an accept().
|
* Queue io completion for an accept().
|
||||||
@@ -3609,6 +3618,7 @@ isc__socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
|
|||||||
ISC_LIST_ENQUEUE(sock->connect_list, cdev, ev_link);
|
ISC_LIST_ENQUEUE(sock->connect_list, cdev, ev_link);
|
||||||
sock->pending_iocp++;
|
sock->pending_iocp++;
|
||||||
} else if (sock->type == isc_sockettype_tcp) {
|
} else if (sock->type == isc_sockettype_tcp) {
|
||||||
|
INSIST(sock->pending_connect);
|
||||||
INSIST(isc_sockaddr_equal(&sock->address, addr));
|
INSIST(isc_sockaddr_equal(&sock->address, addr));
|
||||||
isc_task_attach(task, &ntask);
|
isc_task_attach(task, &ntask);
|
||||||
cdev->ev_sender = ntask;
|
cdev->ev_sender = ntask;
|
||||||
|
Reference in New Issue
Block a user