Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

req: use nni_aio_completions - this is similar to #1523 #1710

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/sp/protocol/reqrep0/req.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Staysail Systems, Inc. <[email protected]>
// Copyright 2023 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
//
// This software is supplied under the terms of the MIT License, a
Expand All @@ -19,7 +19,7 @@ typedef struct req0_pipe req0_pipe;
typedef struct req0_sock req0_sock;
typedef struct req0_ctx req0_ctx;

static void req0_run_send_queue(req0_sock *, nni_list *);
static void req0_run_send_queue(req0_sock *, nni_aio_completions *);
static void req0_ctx_reset(req0_ctx *);
static void req0_ctx_timeout(void *);
static void req0_pipe_fini(void *);
Expand Down Expand Up @@ -255,12 +255,11 @@ req0_pipe_close(void *arg)
static void
req0_send_cb(void *arg)
{
req0_pipe *p = arg;
req0_sock *s = p->req;
nni_aio *aio;
nni_list sent_list;
req0_pipe *p = arg;
req0_sock *s = p->req;
nni_aio_completions sent_list;

nni_aio_list_init(&sent_list);
nni_aio_completions_init(&sent_list);
if (nni_aio_result(&p->aio_send) != 0) {
// We failed to send... clean up and deal with it.
nni_msg_free(nni_aio_get_msg(&p->aio_send));
Expand All @@ -287,10 +286,7 @@ req0_send_cb(void *arg)
req0_run_send_queue(s, &sent_list);
nni_mtx_unlock(&s->mtx);

while ((aio = nni_list_first(&sent_list)) != NULL) {
nni_list_remove(&sent_list, aio);
nni_aio_finish_sync(aio, 0, 0);
}
nni_aio_completions_run(&sent_list);
}

static void
Expand Down Expand Up @@ -439,7 +435,7 @@ req0_ctx_get_resend_time(void *arg, void *buf, size_t *szp, nni_opt_type t)
}

static void
req0_run_send_queue(req0_sock *s, nni_list *sent_list)
req0_run_send_queue(req0_sock *s, nni_aio_completions *sent_list)
{
req0_ctx *ctx;
nni_aio *aio;
Expand Down Expand Up @@ -486,7 +482,7 @@ req0_run_send_queue(req0_sock *s, nni_list *sent_list)
// If the list was passed in, we want to do a
// synchronous completion later.
if (sent_list != NULL) {
nni_list_append(sent_list, aio);
nni_aio_completions_add(sent_list, aio, 0, 0);
} else {
nni_aio_finish(aio, 0, 0);
}
Expand Down
Loading