diff --git a/README.md b/README.md index 8abe2c8..6bba6b8 100644 --- a/README.md +++ b/README.md @@ -272,4 +272,5 @@ then: Redox is in its early stages and I am looking for feedback and contributors to make it easier, faster, and more robust. Open issues on GitHub or message me directly. -Redox is not currently recommended for production use. It has no support for features like connection pooling, sentinels, clusters, etc. Feel free to provide them! +Redox is not currently recommended for production use. It has no support for features like +connection pooling, sentinels, clusters, etc. Feel free to provide them! diff --git a/include/redox/client.hpp b/include/redox/client.hpp index c9a6af7..00b2edc 100644 --- a/include/redox/client.hpp +++ b/include/redox/client.hpp @@ -368,6 +368,10 @@ private: // give it access to private members template friend void Command::free(); + + // Access to call disconnectedCallback + template + friend void Command::processReply(redisReply* r); }; // ------------------------------------------------ diff --git a/src/client.cpp b/src/client.cpp index f7f8153..f05615d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -136,7 +136,7 @@ void Redox::disconnectedCallback(const redisAsyncContext* ctx, int status) { Redox* rdx = (Redox*) ctx->data; if (status != REDIS_OK) { - rdx->logger_.error() << "Could not disconnect from Redis: " << ctx->errstr; + rdx->logger_.error() << "Disconnected from Redis on error: " << ctx->errstr; rdx->connect_state_ = DISCONNECT_ERROR; } else { rdx->logger_.info() << "Disconnected from Redis as planned."; diff --git a/src/command.cpp b/src/command.cpp index 3f94782..9587545 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -53,9 +53,15 @@ void Command::processReply(redisReply* r) { reply_obj_ = r; - reply_guard_.lock(); - parseReplyObject(); - reply_guard_.unlock(); + if(reply_obj_ == nullptr) { + reply_status_ = ERROR_REPLY; + logger_.error() << "Received null redisReply* from hiredis."; + Redox::disconnectedCallback(rdx_->ctx_, REDIS_ERR); + + } else { + lock_guard lg(reply_guard_); + parseReplyObject(); + } invoke(); diff --git a/src/utils/logger.cpp b/src/utils/logger.cpp index 6d3e8b6..637b0f4 100644 --- a/src/utils/logger.cpp +++ b/src/utils/logger.cpp @@ -75,7 +75,7 @@ const tm *Logger::getLocalTime() { void Logger::log(Level l, std::string oMessage) { const static char *LevelStr[] = { - "[Trace] ", "[Debug] ", "[Info] ", "[Warning]", "[Error] ", "[Severe] " + "[Trace] ", "[Debug] ", "[Info] ", "[Warning]", "[Error] ", "[Fatal] " }; m_lock.lock();