sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

Async callbacks are not working when linked to daemonized process #435

Closed NanthiniRasu closed 1 year ago

NanthiniRasu commented 1 year ago

Below sample is not working when api is invoked from daemonized process.

include

include

include

include<sw/redis++/async_redis++.h>

include "test.h"

using namespace std; using namespace sw::redis;

ConnectionOptions opts; ConnectionPoolOptions pool_opts;

auto async_redis = AsyncRedis(opts, pool_opts); auto sub = async_redis.subscriber();

void process_message(std::string channel, std::string msg) { const char pStr = msg.c_str(); / Further message proceesing */ }

int async_redis_init() { opts.host = "127.0.0.1"; opts.port = 6379;

pool_opts.size = 3;

async_redis = AsyncRedis(opts, pool_opts);

Future ping_res = async_redis.ping();

cout << ping_res.get() << endl;

sub = async_redis.subscriber();

// Future fut1 = sub.subscribe("mychannel");

sub.on_message(process_message); }

This async_redis_init is invoked from daemonized process init . When we execute process normally without daemon option, async callback works fine. When we execute process with daemon mode , only PONG message is getting printed.

call_back api's are not getting hit

Please let us know, what we are missing or we need to enable some option for daemonized process?

sewenew commented 1 year ago

Sorry, but I'm not familiar with daemonized process. Not sure if the daemonized process destroy the global variable? You might need to seek help from a system programming expert.

Regards

sewenew commented 1 year ago

Since there's no update, I'll close this issue.

If you got the solution, feel free to share it. Thanks!

Regards