Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/pulsar/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/ClientConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/ConnectionPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions lib/Result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/ClientTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down