diff --git a/include/pulsar/Result.h b/include/pulsar/Result.h index 0f7d8a8b..033f4cb3 100644 --- a/include/pulsar/Result.h +++ b/include/pulsar/Result.h @@ -92,6 +92,8 @@ enum Result ResultMemoryBufferIsFull, /// Client-wide memory limit has been reached ResultInterrupted, /// Interrupted while waiting to dequeue + + ResultDisconnected, /// Client connection has been disconnected }; // Return string representation of result code diff --git a/lib/ClientConnection.cc b/lib/ClientConnection.cc index 51a09f45..e9726c2c 100644 --- a/lib/ClientConnection.cc +++ b/lib/ClientConnection.cc @@ -1596,7 +1596,11 @@ void ClientConnection::close(Result result) { } lock.unlock(); - LOG_INFO(cnxString_ << "Connection closed with " << result); + if (result != ResultDisconnected && result != ResultRetryable) { + LOG_ERROR(cnxString_ << "Connection closed with " << result); + } else { + LOG_INFO(cnxString_ << "Connection disconnected"); + } for (ProducersMap::iterator it = producers.begin(); it != producers.end(); ++it) { HandlerBase::handleDisconnection(result, shared_from_this(), it->second); diff --git a/lib/ConnectionPool.cc b/lib/ConnectionPool.cc index 1c246d64..37c72b9e 100644 --- a/lib/ConnectionPool.cc +++ b/lib/ConnectionPool.cc @@ -53,7 +53,7 @@ bool ConnectionPool::close() { for (auto cnxIt = pool_.begin(); cnxIt != pool_.end(); cnxIt++) { ClientConnectionPtr cnx = cnxIt->second.lock(); if (cnx) { - cnx->close(); + cnx->close(ResultDisconnected); } } pool_.clear(); diff --git a/lib/Result.cc b/lib/Result.cc index 3533b1ec..f7156ac5 100644 --- a/lib/Result.cc +++ b/lib/Result.cc @@ -165,6 +165,9 @@ const char* strResult(Result result) { case ResultInterrupted: return "ResultInterrupted"; + + case ResultDisconnected: + return "ResultDisconnected"; }; // NOTE : Do not add default case in the switch above. In future if we get new cases for // ServerError and miss them in the switch above we would like to get notified. Adding diff --git a/tests/ClientTest.cc b/tests/ClientTest.cc index a4abc3a9..07fe22fd 100644 --- a/tests/ClientTest.cc +++ b/tests/ClientTest.cc @@ -126,7 +126,7 @@ TEST(ClientTest, testConnectTimeout) { clientDefault.close(); ASSERT_EQ(futureDefault.wait_for(std::chrono::milliseconds(10)), std::future_status::ready); - ASSERT_EQ(futureDefault.get(), ResultConnectError); + ASSERT_EQ(futureDefault.get(), ResultDisconnected); } TEST(ClientTest, testGetNumberOfReferences) {