aboutsummaryrefslogtreecommitdiff
path: root/src/sp/protocol/reqrep0
diff options
context:
space:
mode:
authorshikokuchuo <53399081+shikokuchuo@users.noreply.github.com>2025-02-27 15:55:16 +0000
committerGarrett D'Amore <garrett@damore.org>2025-03-16 18:05:55 -0700
commit4783afb5e4c4f21f474776949c61fa9d7b8d26ab (patch)
tree60e717156590c1c98b28c44362aeb580ed168503 /src/sp/protocol/reqrep0
parent7cc29a0b7a9e45e8bf3e70ec7ddab119b3380c02 (diff)
downloadnng-4783afb5e4c4f21f474776949c61fa9d7b8d26ab.tar.gz
nng-4783afb5e4c4f21f474776949c61fa9d7b8d26ab.tar.bz2
nng-4783afb5e4c4f21f474776949c61fa9d7b8d26ab.zip
req protocol: free msg early if no retries
Diffstat (limited to 'src/sp/protocol/reqrep0')
-rw-r--r--src/sp/protocol/reqrep0/req.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/sp/protocol/reqrep0/req.c b/src/sp/protocol/reqrep0/req.c
index 0a10462a..468ece15 100644
--- a/src/sp/protocol/reqrep0/req.c
+++ b/src/sp/protocol/reqrep0/req.c
@@ -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;
}
@@ -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);
}
@@ -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) {