--- file_not_specified_in_diff +++ file_not_specified_in_diff @@ -, +, @@ --- rtkit-0.13.orig/rtkit-daemon.c +++ rtkit-0.13/rtkit-daemon.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -196,6 +197,15 @@ static pthread_t canary_thread_id = 0, watchdog_thread_id = 0; static volatile uint32_t refuse_until = 0; +static int _sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) { + static const struct sched_param def; + return syscall(SYS_sched_setscheduler, pid, 0, &def); +} + +static int _sched_getscheduler(pid_t pid) { + return syscall(SYS_sched_getscheduler, pid); +} + static const char *get_proc_path(void) { /* Useful for chroot environments */ @@ -439,7 +449,7 @@ if (st != t->starttime) return FALSE; - if ((r = sched_getscheduler(t->pid)) < 0) { + if ((r = _sched_getscheduler(t->pid)) < 0) { /* Maybe it died right now? */ if (errno == ESRCH) @@ -564,7 +574,7 @@ memset(¶m, 0, sizeof(param)); param.sched_priority = priority; - if (sched_setscheduler(0, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { + if (_sched_setscheduler(0, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { r = -errno; syslog(LOG_ERR, "Failed to make ourselves RT: %s\n", strerror(errno)); goto finish; @@ -581,7 +591,7 @@ memset(¶m, 0, sizeof(param)); - if (sched_setscheduler(0, SCHED_OTHER, ¶m) < 0) + if (_sched_setscheduler(0, SCHED_OTHER, ¶m) < 0) syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER: %s\n", strerror(errno)); if (setpriority(PRIO_PROCESS, 0, nice_level) < 0) @@ -696,7 +706,7 @@ memset(¶m, 0, sizeof(param)); param.sched_priority = 0; - if (sched_setscheduler(tid, SCHED_OTHER, ¶m) < 0) { + if (_sched_setscheduler(tid, SCHED_OTHER, ¶m) < 0) { if (errno != ESRCH) syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER for thread %llu: %s\n", (unsigned long long) tid, strerror(errno)); r = -1; @@ -748,7 +758,7 @@ /* Ok, everything seems to be in order, now, let's do it */ memset(¶m, 0, sizeof(param)); param.sched_priority = (int) priority; - if (sched_setscheduler(t->pid, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { + if (_sched_setscheduler(t->pid, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { r = -errno; syslog(LOG_ERR, "Failed to make thread %llu RT: %s\n", (unsigned long long) t->pid, strerror(errno)); goto finish; @@ -809,7 +819,7 @@ /* Ok, everything seems to be in order, now, let's do it */ memset(¶m, 0, sizeof(param)); param.sched_priority = 0; - if (sched_setscheduler(t->pid, SCHED_OTHER|SCHED_RESET_ON_FORK, ¶m) < 0) { + if (_sched_setscheduler(t->pid, SCHED_OTHER|SCHED_RESET_ON_FORK, ¶m) < 0) { r = -errno; syslog(LOG_ERR, "Failed to make process %llu SCHED_NORMAL: %s\n", (unsigned long long) t->pid, strerror(errno)); goto finish; @@ -943,7 +953,7 @@ if (errno != 0 || !e || *e != 0) continue; - if ((r = sched_getscheduler(tid)) < 0) { + if ((r = _sched_getscheduler(tid)) < 0) { if (errno != ESRCH) syslog(LOG_WARNING, "Warning: sched_getscheduler() failed: %s\n", strerror(errno)); continue;