Skip to content

fix memory leak when an error occur in pipeline mode. #58

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

Merged
merged 1 commit into from
Feb 4, 2025
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
11 changes: 8 additions & 3 deletions src/Fast.xs
Original file line number Diff line number Diff line change
Expand Up @@ -440,24 +440,29 @@ void run_cmd_impl_pipeline(pTHX_ Redis__Cluster__Fast self, int argc, const char
node = get_node_by_random(aTHX_ self);
if (node == NULL) {
reply_t->error = newSVpvf("%s", "No node found");
return;
goto error;
}

status = redisClusterAsyncCommandArgvToNode(self->acc, node, replyCallbackPipeline, reply_pipeline_t, argc, argv, argvlen);
if (status != REDIS_OK) {
DEBUG_MSG("error: err=%d errstr=%s", self->acc->err, self->acc->errstr);
reply_t->error = newSVpvf("%s", self->acc->errstr);
return;
goto error;
}
} else {
DEBUG_MSG("error: err=%d errstr=%s", self->acc->err, self->acc->errstr);
reply_t->error = newSVpvf("%s", self->acc->errstr);
return;
goto error;
}
}

self->pipeline_callback_remain++;
DEBUG_MSG("pipeline callback remain: %ld", self->pipeline_callback_remain);
return;

error:
SvREFCNT_dec(reply_pipeline_t->cb);
Safefree(reply_pipeline_t);
}

int Redis__Cluster__Fast_run_event_loop(pTHX_ Redis__Cluster__Fast self) {
Expand Down