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 protocol: free msg early if no retries #2107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/sp/protocol/reqrep0/req.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ req0_recv_cb(void *arg)
nni_id_remove(&s->requests, id);
ctx->request_id = 0;
if (ctx->req_msg != NULL) {
nni_msg_free(ctx->req_msg);
// Only free msg if we originally cloned it (for retries)
if (ctx->retry > 0) {
nni_msg_free(ctx->req_msg);
}
ctx->req_msg = NULL;
}

Expand Down Expand Up @@ -533,7 +536,10 @@ req0_run_send_queue(req0_sock *s, nni_aio_completions *sent_list)
// At this point, we will never give this message back to
// the user, so we don't have to worry about making it
// unique. We can freely clone it.
nni_msg_clone(ctx->req_msg);
// But only do so if we need to hang onto it (for potential retries)
if (ctx->retry > 0) {
nni_msg_clone(ctx->req_msg);
}
nni_aio_set_msg(&p->aio_send, ctx->req_msg);
nni_pipe_send(p->pipe, &p->aio_send);
}
Expand All @@ -553,7 +559,10 @@ req0_ctx_reset(req0_ctx *ctx)
ctx->request_id = 0;
}
if (ctx->req_msg != NULL) {
nni_msg_free(ctx->req_msg);
// Only free msg if we originally cloned it (for retries)
if (ctx->retry > 0) {
nni_msg_free(ctx->req_msg);
}
ctx->req_msg = NULL;
}
if (ctx->rep_msg != NULL) {
Expand Down
Loading