Skip to content

Commit

Permalink
inproc: use nni_aio_start
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Dec 26, 2024
1 parent 2c4324c commit 8027aeb
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/sp/transport/inproc/inproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,10 @@ inproc_pipe_send(void *arg, nni_aio *aio)
inproc_pipe *pipe = arg;
inproc_queue *queue = pipe->send_queue;

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(&queue->lock);
if (!nni_aio_defer(aio, inproc_queue_cancel, queue)) {
if (!nni_aio_start(aio, inproc_queue_cancel, queue)) {
nni_mtx_unlock(&queue->lock);
return;
}
Expand All @@ -218,12 +212,10 @@ inproc_pipe_recv(void *arg, nni_aio *aio)
inproc_pipe *pipe = arg;
inproc_queue *queue = pipe->recv_queue;

if (nni_aio_begin(aio) != 0) {
return;
}
nni_aio_reset(aio);

nni_mtx_lock(&queue->lock);
if (!nni_aio_defer(aio, inproc_queue_cancel, queue)) {
if (!nni_aio_start(aio, inproc_queue_cancel, queue)) {
nni_mtx_unlock(&queue->lock);
return;
}
Expand Down Expand Up @@ -460,9 +452,7 @@ inproc_ep_connect(void *arg, nni_aio *aio)
inproc_ep *ep = arg;
inproc_ep *server;

if (nni_aio_begin(aio) != 0) {
return;
}
nni_aio_reset(aio);

nni_mtx_lock(&nni_inproc.mx);

Expand All @@ -481,7 +471,7 @@ inproc_ep_connect(void *arg, nni_aio *aio)
// We don't have to worry about the case where a zero timeout
// on connect was specified, as there is no option to specify
// that in the upper API.
if (!nni_aio_defer(aio, inproc_ep_cancel, ep)) {
if (!nni_aio_start(aio, inproc_ep_cancel, ep)) {
nni_mtx_unlock(&nni_inproc.mx);
return;
}
Expand Down Expand Up @@ -518,15 +508,13 @@ inproc_ep_accept(void *arg, nni_aio *aio)
{
inproc_ep *ep = arg;

if (nni_aio_begin(aio) != 0) {
return;
}
nni_aio_reset(aio);

nni_mtx_lock(&nni_inproc.mx);

// We need not worry about the case where a non-blocking
// accept was tried -- there is no API to do such a thing.
if (!nni_aio_defer(aio, inproc_ep_cancel, ep)) {
if (!nni_aio_start(aio, inproc_ep_cancel, ep)) {
nni_mtx_unlock(&nni_inproc.mx);
return;
}
Expand Down

0 comments on commit 8027aeb

Please sign in to comment.