From 46c71e0c85732d10c6df89783aaa6615c8a7fe9f Mon Sep 17 00:00:00 2001 From: Srecko Date: Thu, 30 May 2024 12:56:12 +0200 Subject: [PATCH] - fix lock not being relased after waiting for cv variable. - more logging details for DAQ Director connection to filebroker --- EventFilter/Utilities/src/DAQSource.cc | 3 ++- EventFilter/Utilities/src/EvFDaqDirector.cc | 20 ++++++++++--------- .../Utilities/src/FedRawDataInputSource.cc | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/EventFilter/Utilities/src/DAQSource.cc b/EventFilter/Utilities/src/DAQSource.cc index 8947b2876c681..bc8c4bde37f38 100644 --- a/EventFilter/Utilities/src/DAQSource.cc +++ b/EventFilter/Utilities/src/DAQSource.cc @@ -1075,12 +1075,13 @@ void DAQSource::readWorker(unsigned int tid) { workerPool_.push(tid); if (init) { - std::unique_lock lk(startupLock_); + std::unique_lock lks(startupLock_); init = false; startupCv_.notify_one(); } cvWakeup_.notify_all(); cvReader_[tid]->wait(lk); + lk.unlock(); if (thread_quit_signal[tid]) return; diff --git a/EventFilter/Utilities/src/EvFDaqDirector.cc b/EventFilter/Utilities/src/EvFDaqDirector.cc index 68d062df551a2..4e7062a76c540 100644 --- a/EventFilter/Utilities/src/EvFDaqDirector.cc +++ b/EventFilter/Utilities/src/EvFDaqDirector.cc @@ -24,6 +24,7 @@ #include #include #include +#include //using boost::asio::ip::tcp; @@ -1550,6 +1551,7 @@ namespace evf { int maxLS) { EvFDaqDirector::FileStatus fileStatus = noFile; serverError = false; + std::string dest = fmt::sprintf(" on connection to %s:%s", fileBrokerHost_, fileBrokerPort_); boost::system::error_code ec; try { @@ -1559,7 +1561,7 @@ namespace evf { boost::asio::connect(*socket_, *endpoint_iterator_, ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "boost::asio::connect error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "boost::asio::connect error -:" << ec << dest; serverError = true; break; } @@ -1582,17 +1584,17 @@ namespace evf { boost::asio::write(*socket_, request, ec); if (ec) { if (fileBrokerKeepAlive_ && ec == boost::asio::error::connection_reset) { - edm::LogInfo("EvFDaqDirector") << "reconnecting socket on received connection_reset"; + edm::LogInfo("EvFDaqDirector") << "reconnecting socket on received connection_reset" << dest; //we got disconnected, try to reconnect to the server before writing the request boost::asio::connect(*socket_, *endpoint_iterator_, ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "boost::asio::connect error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "boost::asio::connect error -:" << ec << dest; serverError = true; break; } continue; } - edm::LogWarning("EvFDaqDirector") << "boost::asio::write error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "boost::asio::write error -:" << ec << dest; serverError = true; break; } @@ -1600,7 +1602,7 @@ namespace evf { boost::asio::streambuf response; boost::asio::read_until(*socket_, response, "\r\n", ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "boost::asio::read_until error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "boost::asio::read_until error -:" << ec << dest; serverError = true; break; } @@ -1769,7 +1771,7 @@ namespace evf { while (boost::asio::read(*socket_, response, boost::asio::transfer_at_least(1), ec)) { } if (ec != boost::asio::error::eof) { - edm::LogWarning("EvFDaqDirector") << "boost::asio::read_until error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "boost::asio::read_until error -:" << ec << dest; serverError = true; } } @@ -1785,11 +1787,11 @@ namespace evf { if (!fileBrokerKeepAlive_ && socket_->is_open()) { socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "socket shutdown error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "socket shutdown error -:" << ec << dest; } socket_->close(ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "socket close error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "socket close error -:" << ec << dest; } } @@ -1797,7 +1799,7 @@ namespace evf { if (socket_->is_open()) socket_->close(ec); if (ec) { - edm::LogWarning("EvFDaqDirector") << "socket close error -:" << ec; + edm::LogWarning("EvFDaqDirector") << "socket close error -:" << ec << dest; } fileStatus = noFile; sleep(1); //back-off if error detected diff --git a/EventFilter/Utilities/src/FedRawDataInputSource.cc b/EventFilter/Utilities/src/FedRawDataInputSource.cc index 5349a515d26fe..33020ab45edd7 100644 --- a/EventFilter/Utilities/src/FedRawDataInputSource.cc +++ b/EventFilter/Utilities/src/FedRawDataInputSource.cc @@ -1300,12 +1300,13 @@ void FedRawDataInputSource::readWorker(unsigned int tid) { workerPool_.push(tid); if (init) { - std::unique_lock lk(startupLock_); + std::unique_lock lks(startupLock_); init = false; startupCv_.notify_one(); } cvWakeup_.notify_all(); cvReader_[tid]->wait(lk); + lk.unlock(); if (thread_quit_signal[tid]) return;