From 92681a25b7d215fbfcac386fd038a4c170e0b9fb Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Thu, 5 Dec 2024 14:43:25 +0000
Subject: [PATCH] IOHandlerFileRead: Add INFO message with full path when
 opening an MDF file

---
 DAQ/MDF/include/MDF/IOHandlerFileRead.h | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/DAQ/MDF/include/MDF/IOHandlerFileRead.h b/DAQ/MDF/include/MDF/IOHandlerFileRead.h
index 25b600266da..03e01f1be3e 100644
--- a/DAQ/MDF/include/MDF/IOHandlerFileRead.h
+++ b/DAQ/MDF/include/MDF/IOHandlerFileRead.h
@@ -61,7 +61,9 @@ namespace LHCb::MDF {
      */
     void rewind() { throw GaudiException{"IOHandlerFileRead", "Rewind not implemented", StatusCode::FAILURE}; }
 
-    void finalize() {}
+    void finalize() {
+      if ( m_curConnection.isConnected() ) { m_ioMgr->disconnect( &m_curConnection ).ignore(); }
+    }
 
     /// destructor
     ~FileReadInputHandler() { m_ioMgr.reset(); }
@@ -115,7 +117,7 @@ namespace LHCb::MDF {
     void connectToCurrentInput( Owner& owner );
 
     /// Incident service. FIXME : drop whenever FSRSink is not depending on this anymore
-    IIncidentSvc* m_incidentSvc;
+    IIncidentSvc* m_incidentSvc = nullptr;
     /// vector of input files
     std::vector<std::string> const m_input;
     /// currently used input as an index in m_input
@@ -203,12 +205,14 @@ void LHCb::MDF::FileReadInputHandler::connectToCurrentInput( Owner& owner ) {
     m_curConnection = LHCb::RawDataConnection( 0, m_input[m_curInput] );
     auto sc         = m_ioMgr->connectRead( false, &m_curConnection );
     if ( sc.isSuccess() ) {
+      owner.info() << fmt::format( "Connected to {}, input {}/{}", m_input[m_curInput], m_curInput + 1, m_input.size() )
+                   << endmsg;
       // Needed for OpenFilesTracker. FIXME : to be dropped when OpenFilesTracker does not need it anymore
       m_incidentSvc->fireIncident( Incident( m_input[m_curInput], "CONNECTED_INPUT" ) );
       return;
     }
-    owner.error() << "could not connect to input " << m_input[m_curInput] << endmsg;
-    m_curInput++;
+    owner.error() << "Could not connect to input " << m_input[m_curInput] << endmsg;
+    ++m_curInput;
   }
   throw IO::EndOfInput();
 }
@@ -222,13 +226,13 @@ void LHCb::MDF::FileReadInputHandler::readNextEventHeader( Owner& owner, LHCb::M
       throw IO::EndOfInput();
     }
     // No space left ? Or input error ? Anyway close current input
-    owner.info() << fmt::format( "Over with input from {}, processed {}/{} files : ", m_input[m_curInput],
-                                 m_curInput + 1, m_input.size() )
+    owner.info() << fmt::format( "Disconnected from {}, processed {}/{} files", m_input[m_curInput], m_curInput + 1,
+                                 m_input.size() )
                  << endmsg;
 
     m_ioMgr->disconnect( &m_curConnection ).ignore();
     // and connect to next one
-    m_curInput++;
+    ++m_curInput;
     connectToCurrentInput( owner );
     if ( m_curInput >= m_input.size() ) { throw IO::EndOfInput(); }
     // try again to read header
-- 
GitLab