hmartiro / redox

Modern, asynchronous, and wicked fast C++11 client for Redis
Apache License 2.0
382 stars 103 forks source link

Disconnect behavior broken after revamping .free() #10

Open hmartiro opened 9 years ago

hmartiro commented 9 years ago

Can get segfaults if the server goes down while running commands. Get back to the previous behavior, where the disconnect callback is invoked.

yaqwsx commented 9 years ago

Is this bug going to be fixed soon? It stops me from using this library in my project.

hmartiro commented 9 years ago

Hi there. Can you help and post the simplest program you can make that demonstrates this behavior?

yaqwsx commented 9 years ago

Here it is:

#include <redox.hpp>
#include <iostream>
#include <thread>
#include <chrono>

int main()
{
    redox::Redox connection;

    if(!connection.connect("localhost")) {
        std::cout << "Cannot connect!\n";
        exit(1);
    }

    while(true) {
        redox::Command<std::string>& c = connection.commandSync<std::string>({"BLPOP", "key", "0"});
        // If the redis-server stops, command fails
        if (!c.ok()) {
            std::cout << "Command failed!\n";
            // It is also impossible to reconnect here (SIGSEGV)
            // If I want to reconnect I have to create new Redox object
            // while(!connection.connect("localhost")) {
            //      std::this_thread::sleep_for(std::chrono::seconds(5));
            // }
        }
        else {
            std::cout << "Reply: " << c.reply() << std::endl;
        }

        // When I try to free failed command, I get SIGSEGV, when I don't
        // free failed command, I get warning from Redox to stdout
        // "Not all commands were freed"
        c.free();
        std::cout << "Done\n";
    }
}
hmartiro commented 9 years ago

Thank you. I will try to find time to investigate this. I have frustrations with disconnect interactions with hiredis.

shikharkhattar commented 8 years ago

Facing the same issue. Is there a workaround ?

bspguy commented 7 years ago

Hi all Please upgrade hiredis and libev to latest versions. Once these are upgraded, I was not able to reproduce this issue. (working with redis 3.2.6 on fedora)

Please let me know if you are still facing problems.