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

Is there a way to tell hiredis to disconnect in the async onConnect callback? #835

Closed
echoma opened this issue Jun 21, 2020 · 3 comments
Closed

Comments

@echoma
Copy link

echoma commented Jun 21, 2020

https://github.com/redis/hiredis/blob/master/async.c#L620
If I call redisAsyncDisconnect() in the onConnect callback, the redisContext pointer "c" will point to a freed memory, this might make a crash.

may be, a REDIS_IN_CALLBACK like flag which protecting the context object will help?

@michael-grunder
Copy link
Collaborator

The onConnect callback gives you a const redisAsyncContext *ac so you really shouldn't be mutating it there.

What's the use case for this?

@echoma
Copy link
Author

echoma commented Jul 11, 2020

I am a library writer, the library's user may do some checking logic in business layer in onConnect callback. In some situation, the user would like to close the connection when checking failed. I cant control the user's code, so I came here to see whether there is any solution. @michael-grunder

@michael-grunder
Copy link
Collaborator

Closing as this is now possible as #931 was merged and then modified slightly in #1087

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

No branches or pull requests

2 participants