From b62c8dac34f18b1ed45cdcb0ae3ca9d11fbd6c13 Mon Sep 17 00:00:00 2001 From: Megh Bhatt Date: Fri, 23 Oct 2015 16:20:48 -0700 Subject: [PATCH] Handle NULL redisReply in connect callback process in opserver proxy code. This can happen during read EOF resulting in redisAsyncFree calling the callbacks with NULL replies. Closes-Bug: #1499129 Conflicts: src/query_engine/QEOpServerProxy.cc Change-Id: Ic691f8075f314e34254a94c7a9aea21b577f5524 (cherry picked from commit 6786de564f945765fb0d8a4644c0bd6bbe80c9b8) --- src/analytics/OpServerProxy.cc | 12 ++++++++++-- src/query_engine/QEOpServerProxy.cc | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/analytics/OpServerProxy.cc b/src/analytics/OpServerProxy.cc index 1ebfe0ee7b8..93fa21bfaa5 100644 --- a/src/analytics/OpServerProxy.cc +++ b/src/analytics/OpServerProxy.cc @@ -224,7 +224,11 @@ class OpServerProxy::OpServerImpl { } void toConnectCallbackProcess(const redisAsyncContext *c, void *r, void *privdata) { - //Handle the AUTH callback + if (r == NULL) { + LOG(DEBUG, "In toConnectCallbackProcess.. NULL Reply"); + return; + } + // Handle the AUTH callback redisReply reply = *reinterpret_cast(r); if (reply.type != REDIS_REPLY_ERROR) { { @@ -245,7 +249,11 @@ class OpServerProxy::OpServerImpl { } void fromConnectCallbackProcess(const redisAsyncContext *c, void *r, void *privdata) { - //Handle the AUTH callback + if (r == NULL) { + LOG(DEBUG, "In fromConnectCallbackProcess.. NULL Reply"); + return; + } + // Handle the AUTH callback redisReply reply = *reinterpret_cast(r); if (reply.type != REDIS_REPLY_ERROR) { ConnectionState::GetInstance()->Update(ConnectionType::REDIS, diff --git a/src/query_engine/QEOpServerProxy.cc b/src/query_engine/QEOpServerProxy.cc index 2b11fe75cc4..5cc921beffc 100644 --- a/src/query_engine/QEOpServerProxy.cc +++ b/src/query_engine/QEOpServerProxy.cc @@ -882,16 +882,20 @@ class QEOpServerProxy::QEOpServerImpl { } void ConnectCallbackProcess(uint8_t cnum, const redisAsyncContext *c, void *r, void *privdata) { - QE_LOG_NOQID(DEBUG,"In ConnectCallbackProcess.."); + if (r == NULL) { + QE_LOG_NOQID(DEBUG, "In ConnectCallbackProcess.. NULL Reply"); + return; + } redisReply reply = *reinterpret_cast(r); if (reply.type != REDIS_REPLY_ERROR) { + QE_LOG_NOQID(DEBUG, "In ConnectCallbackProcess.."); ConnectionState::GetInstance()->Update(ConnectionType::REDIS, "Query", ConnectionStatus::UP, conns_[cnum]->Endpoint(), std::string()); qosp_->evm_->io_service()->post( boost::bind(&QEOpServerImpl::ConnUpPostProcess, this, cnum)); - }else { + } else { QE_LOG_NOQID(ERROR,"In connectCallbackProcess.. Error"); QE_ASSERT(reply.type != REDIS_REPLY_ERROR); }