Skip to content

Commit

Permalink
Resetting the signal for desired configuration (#159) (#162)
Browse files Browse the repository at this point in the history
Co-authored-by: Marius Niculescu <[email protected]>
  • Loading branch information
AhmedBM and MariusNi authored Apr 4, 2022
1 parent 71bb4b9 commit 06bdbec
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/agents/pnp/PnpAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,12 @@ static void SignalInterrupt(int signal)
}
}

static void SignalReloadConfiguration(int signal)
static void SignalReloadConfiguration(int incomingSignal)
{
g_refreshSignal = signal;
g_refreshSignal = incomingSignal;

// Reset the handler
signal(SIGHUP, SignalReloadConfiguration);
}

static void RefreshConnection()
Expand Down Expand Up @@ -281,7 +284,7 @@ static void RefreshConnection()
void ScheduleRefreshConnection(void)
{
OsConfigLogInfo(GetLog(), "Scheduling refresh connection");
SignalReloadConfiguration(SIGHUP);
g_refreshSignal = SIGHUP;
}

static void SignalChild(int signal)
Expand All @@ -290,11 +293,15 @@ static void SignalChild(int signal)
UNUSED(signal);
}

static void SignalProcessDesired(int signal)
static void SignalProcessDesired(int incomingSignal)
{
OsConfigLogInfo(GetLog(), "Processing desired twin updates");
ProcessDesiredTwinUpdates();
UNUSED(signal);

// Reset the signal handler for the next use otherwise the default handler will be invoked instead
signal(SIGUSR1, SignalProcessDesired);

UNUSED(incomingSignal);
}

static void ForkDaemon()
Expand Down

0 comments on commit 06bdbec

Please sign in to comment.