From 8fa6126599ea6a1e296ab1ec5f303c73ff5bd97c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 9 Jan 2019 11:17:46 +0100 Subject: [PATCH] rtkit: improve DISABLE_RTKIT DISABLE_RTKIT should not even try to get the dbus connection or anything. --- src/modules/module-rtkit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index d927fbc14..cf44844fe 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -116,6 +116,9 @@ struct pw_rtkit_bus *pw_rtkit_bus_get_system(void) struct pw_rtkit_bus *bus; DBusError error; + if (getenv("DISABLE_RTKIT")) + return NULL; + dbus_error_init(&error); bus = calloc(1, sizeof(struct pw_rtkit_bus)); @@ -279,9 +282,6 @@ int pw_rtkit_make_realtime(struct pw_rtkit_bus *connection, pid_t thread, int pr DBusError error; int ret; - if (getenv("DISABLE_RTKIT")) - return -EPERM; - dbus_error_init(&error); if (thread == 0) @@ -441,6 +441,8 @@ static void idle_func(struct spa_source *source) long long rttime; uint64_t count; + read(impl->source.fd, &count, sizeof(uint64_t)); + rtprio = 20; rttime = 20000; @@ -451,7 +453,10 @@ static void idle_func(struct spa_source *source) pw_log_debug("SCHED_OTHER|SCHED_RESET_ON_FORK worked."); return; } + system_bus = pw_rtkit_bus_get_system(); + if (system_bus == NULL) + return; rl.rlim_cur = rl.rlim_max = rttime; if ((r = setrlimit(RLIMIT_RTTIME, &rl)) < 0) @@ -474,8 +479,6 @@ static void idle_func(struct spa_source *source) pw_log_debug("thread made realtime"); } pw_rtkit_bus_free(system_bus); - - read(impl->source.fd, &count, sizeof(uint64_t)); } static int module_init(struct pw_module *module, struct pw_properties *properties)