From f716f61c81a5f120d61b58ee9b4a52b33b2ecb16 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 14 Sep 2025 17:21:00 -0700 Subject: Fix dtls reconnect attempts. Once a DTLS client is started and has reasonably resolved things, it will restart message connections; this way we can restart after a failed connection attempt (e.g. if the CERT was bad or something.) --- src/sp/transport/dtls/dtls.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sp/transport/dtls/dtls.c b/src/sp/transport/dtls/dtls.c index bcfab6c7..e95560de 100644 --- a/src/sp/transport/dtls/dtls.c +++ b/src/sp/transport/dtls/dtls.c @@ -1134,7 +1134,8 @@ dtls_ep_stop(void *arg) nni_aio_stop(&ep->timeaio); nni_mtx_lock(&ep->mtx); - ep->fini = true; + ep->fini = true; + ep->started = false; nni_mtx_unlock(&ep->mtx); } @@ -1440,18 +1441,21 @@ dtls_ep_connect(void *arg, nni_aio *aio) nni_mtx_unlock(&ep->mtx); return; } - if (ep->started) { + if (!nni_list_empty(&ep->connaios)) { nni_aio_finish_error(aio, NNG_EBUSY); nni_mtx_unlock(&ep->mtx); return; } - NNI_ASSERT(nni_list_empty(&ep->connaios)); ep->dialer = true; - + NNI_ASSERT(nni_list_empty(&ep->connaios)); nni_list_append(&ep->connaios, aio); - // lookup the IP address + if (ep->started) { + nni_mtx_unlock(&ep->mtx); + return; + } + // lookup the IP address memset(&ep->resolv, 0, sizeof(ep->resolv)); ep->resolv.ri_family = ep->af; ep->resolv.ri_host = ep->url->u_hostname; -- cgit v1.2.3-70-g09d2