像下面这样运行阻塞订阅会在redisGetReply
(来源:hiredis#pipelining)处停止程序
void subscribe (std::string& key, Subscriber* subscriber)
{
void* reply = redisCommand (redis, "SUBSCRIBE %s", key.c_str ());
freeReplyObject (reply);
while (redisGetReply (redis, &reply) == REDIS_OK)
{
subscriber -> notify ();
freeReplyObject (reply);
}
}
我认为通过调用redisFree
(通过信号处理)套接字将被关闭并redisGetReply
返回,如hiredis#cleaning-up所述,而是引发内存访问冲突。