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

Added REDIS_NO_AUTO_FREE_REPLIES flag #962

Merged
merged 3 commits into from
Jul 11, 2021

Conversation

MeirShpilraien
Copy link
Contributor

The new flag can be set on the redisOptions struct and given to the async connection. If set, the new flag makes sure the replies given to the async callback will not be freed by hiredis. Instead, the reply ownership is given to the callback and it's the user's
responsibility to free it when he finished using it.

The new flag can be set on the redisOptions struct and given to the async connection.
If set, the new flag makes sure the replies given to the async callback will not be
freed by hiredis. Instead, the reply ownership is given to the callback and it's the user's
responsibility to free it when he finished using it.
@michael-grunder michael-grunder self-requested a review June 9, 2021 17:23
async.c Outdated
@@ -569,7 +569,9 @@ void redisProcessCallbacks(redisAsyncContext *ac) {

if (cb.fn != NULL) {
__redisRunCallback(ac,&cb,reply);
c->reader->fn->freeObject(reply);
if (!(c->flags & REDIS_NO_AUTO_FREE_REPLIES)){
c->reader->fn->freeObject(reply);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a whitespace change (4 space indentation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

hiredis.h Outdated Show resolved Hide resolved
@michael-grunder michael-grunder self-assigned this Jun 9, 2021
@michael-grunder
Copy link
Collaborator

Thanks for the PR!

This is a useful addition and small enough a change that we can probably get it in v1.0.1.

I'll also play around with how we might want this flag to work for PUSH messages as being able to retain those may also be useful for certain use cases.

MeirShpilraien and others added 2 commits June 10, 2021 12:12
Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
@MeirShpilraien
Copy link
Contributor Author

@michael-grunder anything else you want me to change/add here?

@michael-grunder
Copy link
Collaborator

Nope, I think it's good. I'll get it merged over the weekend.

@michael-grunder michael-grunder merged commit f5f31ff into redis:master Jul 11, 2021
@michael-grunder
Copy link
Collaborator

Merged, thanks! (and sorry for the delay)

dlazar-dn pushed a commit to dlazar-dn/hiredis that referenced this pull request Sep 30, 2021
When set hiredis will not automatically free replies in an async context, and the replies must be freed instead by the user.

Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
dlazar-dn pushed a commit to dlazar-dn/hiredis that referenced this pull request Dec 22, 2021
When set hiredis will not automatically free replies in an async context, and the replies must be freed instead by the user.

Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants