fixup! HACK: make isc_nm_tlsconnect() work when being invoked from within the context of a network thread

This commit is contained in:
Artem Boldariev
2021-02-11 16:01:34 +02:00
parent b7e8994ad3
commit 70b1946896
2 changed files with 15 additions and 11 deletions

View File

@@ -810,6 +810,7 @@ struct isc_nmsocket {
BIO *ssl_bio;
isc_nmsocket_t *tlslistener;
bool connect_from_networker;
atomic_bool result_updated;
enum {
TLS_INIT,
TLS_HANDSHAKE,

View File

@@ -74,18 +74,21 @@ inactive(isc_nmsocket_t *sock) {
static void
update_result(isc_nmsocket_t *sock, const isc_result_t result) {
if (!sock->tlsstream.server) {
LOCK(&sock->lock);
sock->result = result;
SIGNAL(&sock->cond);
while (!atomic_load(&sock->active)) {
WAIT(&sock->scond, &sock->lock);
if (!atomic_load(&sock->tlsstream.result_updated)) {
atomic_store(&sock->tlsstream.result_updated, true);
if (!sock->tlsstream.server) {
LOCK(&sock->lock);
sock->result = result;
SIGNAL(&sock->cond);
while (!atomic_load(&sock->active)) {
WAIT(&sock->scond, &sock->lock);
}
UNLOCK(&sock->lock);
} else {
LOCK(&sock->lock);
sock->result = result;
UNLOCK(&sock->lock);
}
UNLOCK(&sock->lock);
} else {
LOCK(&sock->lock);
sock->result = result;
UNLOCK(&sock->lock);
}
}