-
Notifications
You must be signed in to change notification settings - Fork 140
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
Multi thread io_service::run() SET GET DEL #48
Comments
It might be related to #21. |
I got more useful log for analyze using clang address sanitizer. Compile command:
Log:
|
I guess that it is the following issue. Should I serialize command sending to the redis connection? And can I call multiple async command concurrently? Or I can call async command only from its callback function? Boost.Asio async_write has the limitation:
http://www.boost.org/doc/libs/1_65_1/doc/html/boost_asio/reference/async_write/overload1.html And one solution: |
I found the answer for thread safety:
I will use lock or one special thread for the redis connection. So rest of my question is "can I call multiple async command concurrently? Or I can call async command only from its callback function?" like this:
|
Yes you can multiple async call. RedisClient serializes write operations in internal queue. |
Thank you! It's easy to use :) |
I'd like to use redisclient on multi thread program. In the program, io_service::run() is called from each threads.
I got some unexpected behavior.
Here is the list of behavior I ovserved:
Got stucked. Log output is stopped.
Core dumped.
I wrote the code that reproduces the behavior based on
https://github.com/nekipelov/redisclient/blob/master/examples/async_set_get.cpp
The code continues SET, GET, DEL, SET, GET, DEL, ...
When I run the executable file again and again, the behavior above is observed.
Compile command:
Environment:
boost 1.65.1
Linux 4.13.3-1-ARCH #1 SMP PREEMPT Thu Sep 21 20:33:16 CEST 2017 x86_64 GNU/Linux
Can I send async command like
redisClient.command("SET", ...)
via the same connection from multiple threads?The text was updated successfully, but these errors were encountered: