-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Added REDIS_NO_AUTO_FREE_REPLIES flag #962
Conversation
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.
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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
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 |
Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
@michael-grunder anything else you want me to change/add here? |
Nope, I think it's good. I'll get it merged over the weekend. |
Merged, thanks! (and sorry for the delay) |
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>
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>
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.