diff --git a/nosql_lib/redis/src/RedisConnection.cc b/nosql_lib/redis/src/RedisConnection.cc index 7b6a18cf..47db2863 100644 --- a/nosql_lib/redis/src/RedisConnection.cc +++ b/nosql_lib/redis/src/RedisConnection.cc @@ -38,11 +38,20 @@ void RedisConnection::startConnectionInLoop() if (redisContext_->err) { LOG_ERROR << "Error: " << redisContext_->errstr; + if (disconnectCallback_) { disconnectCallback_(shared_from_this()); } + + // Strange things have happend. In some kinds of connection errors, such + // as setsockopt errors, hiredis already set redisContext_->c.fd to -1, + // but the tcp connection stays in ESTABLISHED status. And there is no + // way for us to obtain the fd of that socket nor close it. This + // probably is a bug of hiredis. + return; } + redisContext_->ev.addWrite = addWrite; redisContext_->ev.delWrite = delWrite; redisContext_->ev.addRead = addRead;