aboutsummaryrefslogtreecommitdiff
path: root/src/sp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp')
-rw-r--r--src/sp/transport/udp/udp.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/sp/transport/udp/udp.c b/src/sp/transport/udp/udp.c
index 97ffdc04..f2fc6889 100644
--- a/src/sp/transport/udp/udp.c
+++ b/src/sp/transport/udp/udp.c
@@ -1108,6 +1108,10 @@ udp_ep_fini(void *arg)
nni_aio_fini(&ep->tx_aio);
nni_aio_fini(&ep->rx_aio);
+ if (ep->udp != NULL) {
+ nni_udp_close(ep->udp);
+ }
+
for (int i = 0; i < ep->tx_ring.size; i++) {
nni_msg_free(ep->tx_ring.descs[i].payload);
ep->tx_ring.descs[i].payload = NULL;
@@ -1167,10 +1171,6 @@ udp_ep_stop(void *arg)
// finally close the tx channel
nni_aio_stop(&ep->tx_aio);
-
- if (ep->udp != NULL) {
- nni_udp_close(ep->udp);
- }
}
// timer handler - sends out additional creqs as needed,
@@ -1517,12 +1517,12 @@ static void
udp_ep_connect(void *arg, nni_aio *aio)
{
udp_ep *ep = arg;
- int rv;
- if (nni_aio_begin(aio) != 0) {
+ nni_mtx_lock(&ep->mtx);
+ if (!nni_aio_start(aio, udp_ep_cancel, ep)) {
+ nni_mtx_unlock(&ep->mtx);
return;
}
- nni_mtx_lock(&ep->mtx);
if (ep->closed) {
nni_mtx_unlock(&ep->mtx);
nni_aio_finish_error(aio, NNG_ECLOSED);
@@ -1536,12 +1536,6 @@ udp_ep_connect(void *arg, nni_aio *aio)
NNI_ASSERT(nni_list_empty(&ep->connaios));
ep->dialer = true;
- if ((rv = nni_aio_schedule(aio, udp_ep_cancel, ep)) != 0) {
- nni_mtx_unlock(&ep->mtx);
- nni_aio_finish_error(aio, rv);
- return;
- }
-
nni_list_append(&ep->connaios, aio);
// lookup the IP address