Skip to content

Commit 4806fbf

Browse files
authored
CTFReader: do not use usleep (#8923)
FairMQ can hang if one waits using usleep and we trigger a state transition in between.
1 parent 801832c commit 4806fbf

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Detectors/CTF/workflow/src/CTFReaderSpec.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Framework/ControlService.h"
2020
#include "Framework/ConfigParamRegistry.h"
2121
#include "Framework/InputSpec.h"
22+
#include "Framework/RawDeviceService.h"
2223
#include "CommonUtils/StringUtils.h"
2324
#include "CommonUtils/FileFetcher.h"
2425
#include "CTFWorkflow/CTFReaderSpec.h"
@@ -176,7 +177,7 @@ void CTFReaderSpec::run(ProcessingContext& pc)
176177

177178
if (!mCTFCounter) { // RS FIXME: this is a temporary hack to avoid late-starting devices to lose the input
178179
LOG(warning) << "This is a hack, sleeping 5 s at startup";
179-
usleep(1000000);
180+
pc.services().get<RawDeviceService>().waitFor(1000);
180181
}
181182

182183
std::string tfFileName;
@@ -206,7 +207,7 @@ void CTFReaderSpec::run(ProcessingContext& pc)
206207
mRunning = false;
207208
break;
208209
}
209-
usleep(5000); // wait 5ms for the files cache to be filled
210+
pc.services().get<RawDeviceService>().waitFor(5);
210211
continue;
211212
}
212213
LOG(info) << "Reading CTF input " << ' ' << tfFileName;
@@ -285,7 +286,7 @@ void CTFReaderSpec::processTF(ProcessingContext& pc)
285286
auto tDiff = tNow - mLastSendTime;
286287
if (mCTFCounter) {
287288
if (tDiff < mInput.delay_us) {
288-
usleep(mInput.delay_us - tDiff); // respect requested delay before sending
289+
pc.services().get<RawDeviceService>().waitFor((mInput.delay_us - tDiff) / 1000); // respect requested delay before sending
289290
}
290291
} else {
291292
mLastSendTime = tNow;

0 commit comments

Comments
 (0)