Skip to content
This repository was archived by the owner on Apr 6, 2019. It is now read-only.

smembers return #9

Closed
lulumahot opened this issue Aug 23, 2016 · 2 comments
Closed

smembers return #9

lulumahot opened this issue Aug 23, 2016 · 2 comments

Comments

@lulumahot
Copy link

lulumahot commented Aug 23, 2016

Hello,
I need to request a redis db containing sets.
I think there is a problem with smembers and its return values :

std::vector<int> el; client.smembers(key), [&] (cpp_redis::reply& reply) { std::vector<cpp_redis::reply> rep = reply.as_array(); for (auto it = rep.begin(); it != rep.end(); it++){ el.push_back(std::stoi(it->as_string())); } }); client.commit();

I get pieces of the good answer and then segfault or memory error if i use this code. But if I put a sleep(1) before (or after) client.commit(); it's ok.

So I think the problem is the client is not reading returned values as far as they're sent. I can't use a sleep(1) because of my application.

Have you ever experienced that ? Thank you for your help.

@Cylix
Copy link
Owner

Cylix commented Aug 23, 2016

Hi,

Unfortunately, I can't reproduce the bug on my machines.

Considering the fact that adding a sleep(1) seems to solve your problem, would it be possible that your program terminates while the different callbacks are executed?
In the examples, I used a while (not should_exit) loop: do you have a construct that allow you to avoid the destruction of the redis_client while there are still callback being processed?

If not, is there any way you could provide a valgrind report or gdb backtrace that could help me localize the problem? I'll keep trying to reproduce the error but it would help me a lot.

Thanks

@lulumahot
Copy link
Author

I used a sync_commit and it solved it.

@Cylix Cylix closed this as completed Aug 24, 2016
cmorse pushed a commit to cmorse/cpp_redis that referenced this issue Oct 18, 2017
* switch from poll to select (unix)

* windows impl

* clang format
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants