Bug: pipedal doesn't always shut down cleanly.
This commit is contained in:
@@ -172,6 +172,7 @@ void Updater::ThreadProc()
|
|||||||
pfd.fd = this->event_reader;
|
pfd.fd = this->event_reader;
|
||||||
pfd.events = POLLIN;
|
pfd.events = POLLIN;
|
||||||
|
|
||||||
|
try {
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int ret = poll(&pfd, 1, std::chrono::duration_cast<std::chrono::milliseconds>(updateRate).count()); // 1000 ms timeout
|
int ret = poll(&pfd, 1, std::chrono::duration_cast<std::chrono::milliseconds>(updateRate).count()); // 1000 ms timeout
|
||||||
@@ -207,6 +208,10 @@ void Updater::ThreadProc()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (const std::exception&e)
|
||||||
|
{
|
||||||
|
Lv2Log::error(SS("Updater: Service thread terminated abnormally: " << e.what()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GithubAsset
|
class GithubAsset
|
||||||
|
|||||||
+20
-14
@@ -220,8 +220,28 @@ int main(int argc, char *argv[])
|
|||||||
return EXIT_SUCCESS; // tell systemd not to auto-restart.
|
return EXIT_SUCCESS; // tell systemd not to auto-restart.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// only accept signals on the main thread.
|
||||||
|
// block now so that threads spawned by model inherit the block mask.
|
||||||
|
int sig;
|
||||||
|
sigset_t sigSet;
|
||||||
|
int s;
|
||||||
|
sigemptyset(&sigSet);
|
||||||
|
sigaddset(&sigSet, SIGINT);
|
||||||
|
sigaddset(&sigSet, SIGTERM);
|
||||||
|
sigaddset(&sigSet, SIGUSR1);
|
||||||
|
|
||||||
|
s = pthread_sigmask(SIG_BLOCK, &sigSet, NULL);
|
||||||
|
if (s != 0)
|
||||||
|
{
|
||||||
|
throw std::logic_error("pthread_sigmask failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PiPedalModel model;
|
PiPedalModel model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
model.SetRestartListener(
|
model.SetRestartListener(
|
||||||
[]()
|
[]()
|
||||||
{
|
{
|
||||||
@@ -243,20 +263,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
model.WaitForAudioDeviceToComeOnline();
|
model.WaitForAudioDeviceToComeOnline();
|
||||||
|
|
||||||
// only accept signals on the main thread.
|
|
||||||
int sig;
|
|
||||||
sigset_t sigSet;
|
|
||||||
int s;
|
|
||||||
sigemptyset(&sigSet);
|
|
||||||
sigaddset(&sigSet, SIGINT);
|
|
||||||
sigaddset(&sigSet, SIGTERM);
|
|
||||||
sigaddset(&sigSet, SIGUSR1);
|
|
||||||
|
|
||||||
s = pthread_sigmask(SIG_BLOCK, &sigSet, NULL);
|
|
||||||
if (s != 0)
|
|
||||||
{
|
|
||||||
throw std::logic_error("pthread_sigmask failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if JACK_HOST
|
#if JACK_HOST
|
||||||
if (systemd)
|
if (systemd)
|
||||||
|
|||||||
Reference in New Issue
Block a user