Skip to content

Commit

Permalink
DPL: only listen to SIGUSR1 when the task is alive
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Nov 3, 2023
1 parent e5b4dac commit 484aff8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Framework/Core/include/Framework/DeviceContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define O2_FRAMEWORK_DEVICECONTEXT_H_

typedef struct uv_timer_s uv_timer_t;
typedef struct uv_signal_s uv_signal_t;

namespace o2::framework
{
Expand All @@ -27,6 +28,7 @@ struct ComputingQuotaStats;
struct DeviceContext {
ComputingQuotaStats* quotaStats = nullptr;
uv_timer_t* gracePeriodTimer = nullptr;
uv_signal_t* sigusr1Handle = nullptr;
int expectedRegionCallbacks = 0;
int exitTransitionTimeout = 0;
};
Expand Down
15 changes: 11 additions & 4 deletions Framework/Core/src/DataProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,12 @@ void DataProcessingDevice::InitTask()
// an event from the outside, making sure that the event loop can
// be unblocked (e.g. by a quitting DPL driver) even when there
// is no data pending to be processed.
auto* sigusr1Handle = (uv_signal_t*)malloc(sizeof(uv_signal_t));
uv_signal_init(state.loop, sigusr1Handle);
sigusr1Handle->data = &mServiceRegistry;
uv_signal_start(sigusr1Handle, on_signal_callback, SIGUSR1);
if (deviceContext.sigusr1Handle == nullptr) {
deviceContext.sigusr1Handle = (uv_signal_t*)malloc(sizeof(uv_signal_t));
deviceContext.sigusr1Handle->data = &mServiceRegistry;
uv_signal_init(state.loop, deviceContext.sigusr1Handle);
}
uv_signal_start(deviceContext.sigusr1Handle, on_signal_callback, SIGUSR1);

/// Initialise the pollers
DataProcessingDevice::initPollers();
Expand Down Expand Up @@ -1675,6 +1677,11 @@ void DataProcessingDevice::ResetTask()
{
ServiceRegistryRef ref{mServiceRegistry};
ref.get<DataRelayer>().clear();
auto& deviceContext = ref.get<DeviceContext>();
// Stop the signal handler
if (deviceContext.sigusr1Handle) {
uv_signal_stop(deviceContext.sigusr1Handle);
}
}

struct WaitBackpressurePolicy {
Expand Down

0 comments on commit 484aff8

Please sign in to comment.