diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-26 14:40:13 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-26 15:57:49 -0800 |
| commit | aada131b6dde8a915a21be958dda9109bc290648 (patch) | |
| tree | 2db247288cd96e2c475f88c3028eef8928ed8bfe /src/sp | |
| parent | 35e77bdd02a735da8e7cde7a3be8b9a1fbbf084a (diff) | |
| download | nng-aada131b6dde8a915a21be958dda9109bc290648.tar.gz nng-aada131b6dde8a915a21be958dda9109bc290648.tar.bz2 nng-aada131b6dde8a915a21be958dda9109bc290648.zip | |
tls: use nni_aio_begin
Diffstat (limited to 'src/sp')
| -rw-r--r-- | src/sp/transport/tls/tls.c | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/src/sp/transport/tls/tls.c b/src/sp/transport/tls/tls.c index 9a216f2b..db301af3 100644 --- a/src/sp/transport/tls/tls.c +++ b/src/sp/transport/tls/tls.c @@ -458,19 +458,11 @@ static void tlstran_pipe_send(void *arg, nni_aio *aio) { tlstran_pipe *p = arg; - int rv; - if (nni_aio_begin(aio) != 0) { - // No way to give the message back to the protocol, so - // we just discard it silently to prevent it from leaking. - nni_msg_free(nni_aio_get_msg(aio)); - nni_aio_set_msg(aio, NULL); - return; - } + nni_aio_reset(aio); nni_mtx_lock(&p->mtx); - if ((rv = nni_aio_schedule(aio, tlstran_pipe_send_cancel, p)) != 0) { + if (!nni_aio_start(aio, tlstran_pipe_send_cancel, p)) { nni_mtx_unlock(&p->mtx); - nni_aio_finish_error(aio, rv); return; } nni_list_append(&p->sendq, aio); @@ -523,15 +515,11 @@ static void tlstran_pipe_recv(void *arg, nni_aio *aio) { tlstran_pipe *p = arg; - int rv; - if (nni_aio_begin(aio) != 0) { - return; - } + nni_aio_reset(aio); nni_mtx_lock(&p->mtx); - if ((rv = nni_aio_schedule(aio, tlstran_pipe_recv_cancel, p)) != 0) { + if (!nni_aio_start(aio, tlstran_pipe_recv_cancel, p)) { nni_mtx_unlock(&p->mtx); - nni_aio_finish_error(aio, rv); return; } @@ -681,7 +669,9 @@ error: nni_aio_finish_error(aio, rv); } switch (rv) { - + case NNG_ECLOSED: + case NNG_ESTOPPED: + break; case NNG_ENOMEM: case NNG_ENOFILES: // We need to cool down here, to avoid spinning. @@ -837,12 +827,8 @@ static void tlstran_ep_connect(void *arg, nni_aio *aio) { tlstran_ep *ep = arg; - int rv; - - if (nni_aio_begin(aio) != 0) { - return; - } + nni_aio_reset(aio); nni_mtx_lock(&ep->mtx); if (ep->closed) { nni_mtx_unlock(&ep->mtx); @@ -854,9 +840,8 @@ tlstran_ep_connect(void *arg, nni_aio *aio) nni_aio_finish_error(aio, NNG_EBUSY); return; } - if ((rv = nni_aio_schedule(aio, tlstran_ep_cancel, ep)) != 0) { + if (!nni_aio_start(aio, tlstran_ep_cancel, ep)) { nni_mtx_unlock(&ep->mtx); - nni_aio_finish_error(aio, rv); return; } ep->useraio = aio; @@ -888,11 +873,8 @@ static void tlstran_ep_accept(void *arg, nni_aio *aio) { tlstran_ep *ep = arg; - int rv; - if (nni_aio_begin(aio) != 0) { - return; - } + nni_aio_reset(aio); nni_mtx_lock(&ep->mtx); if (ep->closed) { nni_mtx_unlock(&ep->mtx); @@ -904,9 +886,8 @@ tlstran_ep_accept(void *arg, nni_aio *aio) nni_aio_finish_error(aio, NNG_EBUSY); return; } - if ((rv = nni_aio_schedule(aio, tlstran_ep_cancel, ep)) != 0) { + if (!nni_aio_start(aio, tlstran_ep_cancel, ep)) { nni_mtx_unlock(&ep->mtx); - nni_aio_finish_error(aio, rv); return; } ep->useraio = aio; |
