rtkit: improve DISABLE_RTKIT

DISABLE_RTKIT should not even try to get the dbus connection or
anything.
This commit is contained in:
Wim Taymans 2019-01-09 11:17:46 +01:00
parent 714178b1e4
commit 8fa6126599

View file

@ -116,6 +116,9 @@ struct pw_rtkit_bus *pw_rtkit_bus_get_system(void)
struct pw_rtkit_bus *bus; struct pw_rtkit_bus *bus;
DBusError error; DBusError error;
if (getenv("DISABLE_RTKIT"))
return NULL;
dbus_error_init(&error); dbus_error_init(&error);
bus = calloc(1, sizeof(struct pw_rtkit_bus)); 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; DBusError error;
int ret; int ret;
if (getenv("DISABLE_RTKIT"))
return -EPERM;
dbus_error_init(&error); dbus_error_init(&error);
if (thread == 0) if (thread == 0)
@ -441,6 +441,8 @@ static void idle_func(struct spa_source *source)
long long rttime; long long rttime;
uint64_t count; uint64_t count;
read(impl->source.fd, &count, sizeof(uint64_t));
rtprio = 20; rtprio = 20;
rttime = 20000; rttime = 20000;
@ -451,7 +453,10 @@ static void idle_func(struct spa_source *source)
pw_log_debug("SCHED_OTHER|SCHED_RESET_ON_FORK worked."); pw_log_debug("SCHED_OTHER|SCHED_RESET_ON_FORK worked.");
return; return;
} }
system_bus = pw_rtkit_bus_get_system(); system_bus = pw_rtkit_bus_get_system();
if (system_bus == NULL)
return;
rl.rlim_cur = rl.rlim_max = rttime; rl.rlim_cur = rl.rlim_max = rttime;
if ((r = setrlimit(RLIMIT_RTTIME, &rl)) < 0) 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_log_debug("thread made realtime");
} }
pw_rtkit_bus_free(system_bus); 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) static int module_init(struct pw_module *module, struct pw_properties *properties)