Prevent realtime scheduling for ad-hoc acceptors

I noticed that there were some realtime adhoc-acceptors running on my
system. That should of course not happen, since these only exist to
catch some sporadic (and likely as a result of a badly behaving plugin)
mutual recursion on the audio thread.
This commit is contained in:
Robbert van der Helm
2022-02-08 02:20:18 +01:00
parent de470d345a
commit 823f6bb239
3 changed files with 13 additions and 0 deletions
+3
View File
@@ -780,6 +780,9 @@ class AdHocSocketHandler {
Thread secondary_requests_handler([&]() {
pthread_setname_np(pthread_self(), "adhoc-acceptor");
// Any secondary threads should not be realtime
set_realtime_priority(false);
secondary_context.run();
});
+6
View File
@@ -102,6 +102,12 @@ std::optional<int> get_realtime_priority() noexcept;
*
* @return Whether the operation was successful or not. This will fail if the
* user does not have the privileges to set realtime priorities.
*
* TODO: At some point, consider using `SCHED_RESET_ON_FORK` instead of manually
* disabling this when we don't want realtime scheduling to propagate.
* That would require a bit of careful analysis because we do want it to
* propagate to a Windows plugin's audio threads, and I don't think
* there's a way to go back once you've set `SCHED_RESET_ON_FORK`.
*/
bool set_realtime_priority(bool sched_fifo, int priority = 5) noexcept;