From 5c7f19b3c1a6d104f50bdbf30c215f6d52eb6c14 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 131c9d9443151..eb9de9e6e2fee 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 2344195c6efd9..dc0c3b52c1c3b 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; @@ -1549,6 +1550,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 { @@ -1558,7 +1560,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; } @@ -1581,17 +1583,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; } @@ -1599,7 +1601,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; } @@ -1768,7 +1770,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; } } @@ -1784,11 +1786,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; } } @@ -1796,7 +1798,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 4b95f1a8df9c6..4f0b69aa86f49 100644 --- a/EventFilter/Utilities/src/FedRawDataInputSource.cc +++ b/EventFilter/Utilities/src/FedRawDataInputSource.cc @@ -1299,12 +1299,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;