diff --git a/pulsar-client-cpp/lib/ClientConnection.cc b/pulsar-client-cpp/lib/ClientConnection.cc index fc3582da4fd78..3f0106351cd4a 100644 --- a/pulsar-client-cpp/lib/ClientConnection.cc +++ b/pulsar-client-cpp/lib/ClientConnection.cc @@ -569,7 +569,11 @@ void ClientConnection::handleRead(const boost::system::error_code& err, size_t b if (err || bytesTransferred == 0) { if (err) { - LOG_ERROR(cnxString_ << "Read failed: " << err.message()); + if (err == boost::asio::error::operation_aborted) { + LOG_DEBUG(cnxString_ << "Read failed: " << err.message()); + } else { + LOG_ERROR(cnxString_ << "Read operation was cancelled"); + } } // else: bytesTransferred == 0, which means server has closed the connection close(); } else if (bytesTransferred < minReadSize) { diff --git a/pulsar-client-cpp/lib/ExecutorService.cc b/pulsar-client-cpp/lib/ExecutorService.cc index e056f0fb054a9..e0e382b02a9de 100644 --- a/pulsar-client-cpp/lib/ExecutorService.cc +++ b/pulsar-client-cpp/lib/ExecutorService.cc @@ -73,11 +73,9 @@ void ExecutorService::close() { io_service_->stop(); work_.reset(); - // If this thread is attempting to join itself, do not. The destructor's - // call to close will handle joining if it does not occur here. This also ensures - // join is not called twice since it is not re-entrant on windows - if (std::this_thread::get_id() != worker_.get_id() && worker_.joinable()) { - worker_.join(); + // Detach the worker thread instead of join to avoid potential deadlock + if (worker_.joinable()) { + worker_.detach(); } }