Skip to content

Commit ebf8600

Browse files
chore: Improve closing on FairLmdSource
`Close` is a virtual method. It's getting called internally in a scenario where only FairLmdSource specific resources should be closed. Also the desctructor did not close.
1 parent 7104250 commit ebf8600

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

fairroot/online/source/FairLmdSource.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ FairLmdSource::FairLmdSource(const FairLmdSource& source)
5454

5555
FairLmdSource::~FairLmdSource()
5656
{
57+
CloseLmd();
5758
fFileNames->Delete();
5859
delete fFileNames;
5960
}
@@ -121,6 +122,8 @@ Bool_t FairLmdSource::Init()
121122

122123
Bool_t FairLmdSource::OpenNextFile(TString fileName)
123124
{
125+
CloseLmd();
126+
124127
Int_t inputMode = GETEVT__FILE;
125128
fxInputChannel = new s_evt_channel;
126129
void* headptr = &fxInfoHeader;
@@ -133,6 +136,8 @@ Bool_t FairLmdSource::OpenNextFile(TString fileName)
133136

134137
if (status) {
135138
LOG(error) << "File " << fileName << " opening failed.";
139+
delete fxInputChannel;
140+
fxInputChannel = nullptr;
136141
return kFALSE;
137142
}
138143

@@ -236,7 +241,17 @@ Int_t FairLmdSource::ReadEvent(UInt_t)
236241

237242
void FairLmdSource::Close()
238243
{
244+
CloseLmd();
245+
}
246+
247+
void FairLmdSource::CloseLmd()
248+
{
249+
if (!fxInputChannel) {
250+
return;
251+
}
239252
f_evt_get_close(fxInputChannel);
253+
delete fxInputChannel;
254+
fxInputChannel = nullptr;
240255
Unpack(reinterpret_cast<Int_t*>(fxBuffer), sizeof(s_bufhe), -4, -4, -4, -4, -4);
241256
fCurrentEvent = 0;
242257
}

fairroot/online/source/FairLmdSource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class FairLmdSource : public FairMbsSource
6565

6666
FairLmdSource& operator=(const FairLmdSource&);
6767

68+
private:
69+
void CloseLmd();
70+
6871
ClassDefOverride(FairLmdSource, 0);
6972
};
7073

0 commit comments

Comments
 (0)