redox icon indicating copy to clipboard operation
redox copied to clipboard

Disconnect behavior broken after revamping .free()

Open hmartiro opened this issue 10 years ago • 6 comments

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

hmartiro avatar Jan 28 '15 02:01 hmartiro

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

yaqwsx avatar Jun 18 '15 10:06 yaqwsx

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

hmartiro avatar Jun 21 '15 21:06 hmartiro

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";
    }
}

yaqwsx avatar Jun 21 '15 21:06 yaqwsx

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

hmartiro avatar Jun 21 '15 22:06 hmartiro

Facing the same issue. Is there a workaround ?

shikharkhattar avatar Jul 20 '16 12:07 shikharkhattar

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.

bspguy avatar Apr 16 '17 20:04 bspguy