aboutsummaryrefslogtreecommitdiff
path: root/src/sp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-26 12:15:48 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-26 12:53:46 -0800
commit2c4324c2b7a3dd5583b3b2c499575cf1c8e52e0c (patch)
tree6c6a70bcc3d2f2d78981dcf662b178e0a2da7277 /src/sp
parentb5826dac78e75520c26f2d84a952fe04d69fa2d3 (diff)
downloadnng-2c4324c2b7a3dd5583b3b2c499575cf1c8e52e0c.tar.gz
nng-2c4324c2b7a3dd5583b3b2c499575cf1c8e52e0c.tar.bz2
nng-2c4324c2b7a3dd5583b3b2c499575cf1c8e52e0c.zip
sockfd: convert to use nni_aio_start
Diffstat (limited to 'src/sp')
-rw-r--r--src/sp/transport/socket/sockfd.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/sp/transport/socket/sockfd.c b/src/sp/transport/socket/sockfd.c
index 646151ed..b66687b3 100644
--- a/src/sp/transport/socket/sockfd.c
+++ b/src/sp/transport/socket/sockfd.c
@@ -453,19 +453,10 @@ static void
sfd_tran_pipe_send(void *arg, nni_aio *aio)
{
sfd_tran_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_mtx_lock(&p->mtx);
- if ((rv = nni_aio_schedule(aio, sfd_tran_pipe_send_cancel, p)) != 0) {
+ if (!nni_aio_start(aio, sfd_tran_pipe_send_cancel, p)) {
nni_mtx_unlock(&p->mtx);
- nni_aio_finish_error(aio, rv);
return;
}
nni_list_append(&p->sendq, aio);
@@ -530,15 +521,10 @@ static void
sfd_tran_pipe_recv(void *arg, nni_aio *aio)
{
sfd_tran_pipe *p = arg;
- int rv;
- if (nni_aio_begin(aio) != 0) {
- return;
- }
nni_mtx_lock(&p->mtx);
- if ((rv = nni_aio_schedule(aio, sfd_tran_pipe_recv_cancel, p)) != 0) {
+ if (!nni_aio_start(aio, sfd_tran_pipe_recv_cancel, p)) {
nni_mtx_unlock(&p->mtx);
- nni_aio_finish_error(aio, rv);
return;
}
@@ -687,7 +673,7 @@ error:
ep->useraio = NULL;
nni_aio_finish_error(aio, rv);
}
- if (!ep->closed) {
+ if (!ep->closed && rv != NNG_ESTOPPED) {
nng_stream_listener_accept(ep->listener, &ep->connaio);
}
nni_mtx_unlock(&ep->mtx);
@@ -791,11 +777,7 @@ static void
sfd_tran_ep_accept(void *arg, nni_aio *aio)
{
sfd_tran_ep *ep = arg;
- int rv;
- if (nni_aio_begin(aio) != 0) {
- return;
- }
nni_mtx_lock(&ep->mtx);
if (ep->closed) {
nni_mtx_unlock(&ep->mtx);
@@ -807,9 +789,8 @@ sfd_tran_ep_accept(void *arg, nni_aio *aio)
nni_aio_finish_error(aio, NNG_EBUSY);
return;
}
- if ((rv = nni_aio_schedule(aio, sfd_tran_ep_cancel, ep)) != 0) {
+ if (!nni_aio_start(aio, sfd_tran_ep_cancel, ep)) {
nni_mtx_unlock(&ep->mtx);
- nni_aio_finish_error(aio, rv);
return;
}
ep->useraio = aio;