diff --git a/DAQ/MDF/include/MDF/IOHandlerFileRead.h b/DAQ/MDF/include/MDF/IOHandlerFileRead.h index c6ff4ecf1a7b544f2d3643213383c1d4b13ac269..f6316278738feab2e0136bcea9ebfdd19d4fef31 100644 --- a/DAQ/MDF/include/MDF/IOHandlerFileRead.h +++ b/DAQ/MDF/include/MDF/IOHandlerFileRead.h @@ -63,7 +63,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(); } @@ -117,7 +119,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 @@ -222,12 +224,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(); } @@ -241,13 +245,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