Line
Link Here
|
0 |
-- rtkit-0.13.orig/rtkit-daemon.c |
0 |
++ rtkit-0.13/rtkit-daemon.c |
Lines 32-37
Link Here
|
32 |
#include <sys/stat.h> |
32 |
#include <sys/stat.h> |
33 |
#include <string.h> |
33 |
#include <string.h> |
34 |
#include <sched.h> |
34 |
#include <sched.h> |
|
|
35 |
#include <syscall.h> |
35 |
#include <sys/time.h> |
36 |
#include <sys/time.h> |
36 |
#include <sys/resource.h> |
37 |
#include <sys/resource.h> |
37 |
#include <stdlib.h> |
38 |
#include <stdlib.h> |
Lines 196-201
Link Here
|
196 |
static pthread_t canary_thread_id = 0, watchdog_thread_id = 0; |
197 |
static pthread_t canary_thread_id = 0, watchdog_thread_id = 0; |
197 |
static volatile uint32_t refuse_until = 0; |
198 |
static volatile uint32_t refuse_until = 0; |
198 |
|
199 |
|
|
|
200 |
static int _sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) { |
201 |
static const struct sched_param def; |
202 |
return syscall(SYS_sched_setscheduler, pid, 0, &def); |
203 |
} |
204 |
|
205 |
static int _sched_getscheduler(pid_t pid) { |
206 |
return syscall(SYS_sched_getscheduler, pid); |
207 |
} |
208 |
|
199 |
static const char *get_proc_path(void) { |
209 |
static const char *get_proc_path(void) { |
200 |
/* Useful for chroot environments */ |
210 |
/* Useful for chroot environments */ |
201 |
|
211 |
|
Lines 439-445
Link Here
|
439 |
if (st != t->starttime) |
449 |
if (st != t->starttime) |
440 |
return FALSE; |
450 |
return FALSE; |
441 |
|
451 |
|
442 |
if ((r = sched_getscheduler(t->pid)) < 0) { |
452 |
if ((r = _sched_getscheduler(t->pid)) < 0) { |
443 |
|
453 |
|
444 |
/* Maybe it died right now? */ |
454 |
/* Maybe it died right now? */ |
445 |
if (errno == ESRCH) |
455 |
if (errno == ESRCH) |
Lines 564-570
Link Here
|
564 |
memset(¶m, 0, sizeof(param)); |
574 |
memset(¶m, 0, sizeof(param)); |
565 |
param.sched_priority = priority; |
575 |
param.sched_priority = priority; |
566 |
|
576 |
|
567 |
if (sched_setscheduler(0, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { |
577 |
if (_sched_setscheduler(0, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { |
568 |
r = -errno; |
578 |
r = -errno; |
569 |
syslog(LOG_ERR, "Failed to make ourselves RT: %s\n", strerror(errno)); |
579 |
syslog(LOG_ERR, "Failed to make ourselves RT: %s\n", strerror(errno)); |
570 |
goto finish; |
580 |
goto finish; |
Lines 581-587
Link Here
|
581 |
|
591 |
|
582 |
memset(¶m, 0, sizeof(param)); |
592 |
memset(¶m, 0, sizeof(param)); |
583 |
|
593 |
|
584 |
if (sched_setscheduler(0, SCHED_OTHER, ¶m) < 0) |
594 |
if (_sched_setscheduler(0, SCHED_OTHER, ¶m) < 0) |
585 |
syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER: %s\n", strerror(errno)); |
595 |
syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER: %s\n", strerror(errno)); |
586 |
|
596 |
|
587 |
if (setpriority(PRIO_PROCESS, 0, nice_level) < 0) |
597 |
if (setpriority(PRIO_PROCESS, 0, nice_level) < 0) |
Lines 696-702
Link Here
|
696 |
memset(¶m, 0, sizeof(param)); |
706 |
memset(¶m, 0, sizeof(param)); |
697 |
param.sched_priority = 0; |
707 |
param.sched_priority = 0; |
698 |
|
708 |
|
699 |
if (sched_setscheduler(tid, SCHED_OTHER, ¶m) < 0) { |
709 |
if (_sched_setscheduler(tid, SCHED_OTHER, ¶m) < 0) { |
700 |
if (errno != ESRCH) |
710 |
if (errno != ESRCH) |
701 |
syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER for thread %llu: %s\n", (unsigned long long) tid, strerror(errno)); |
711 |
syslog(LOG_WARNING, "Warning: Failed to reset scheduling to SCHED_OTHER for thread %llu: %s\n", (unsigned long long) tid, strerror(errno)); |
702 |
r = -1; |
712 |
r = -1; |
Lines 748-754
Link Here
|
748 |
/* Ok, everything seems to be in order, now, let's do it */ |
758 |
/* Ok, everything seems to be in order, now, let's do it */ |
749 |
memset(¶m, 0, sizeof(param)); |
759 |
memset(¶m, 0, sizeof(param)); |
750 |
param.sched_priority = (int) priority; |
760 |
param.sched_priority = (int) priority; |
751 |
if (sched_setscheduler(t->pid, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { |
761 |
if (_sched_setscheduler(t->pid, sched_policy|SCHED_RESET_ON_FORK, ¶m) < 0) { |
752 |
r = -errno; |
762 |
r = -errno; |
753 |
syslog(LOG_ERR, "Failed to make thread %llu RT: %s\n", (unsigned long long) t->pid, strerror(errno)); |
763 |
syslog(LOG_ERR, "Failed to make thread %llu RT: %s\n", (unsigned long long) t->pid, strerror(errno)); |
754 |
goto finish; |
764 |
goto finish; |
Lines 809-815
Link Here
|
809 |
/* Ok, everything seems to be in order, now, let's do it */ |
819 |
/* Ok, everything seems to be in order, now, let's do it */ |
810 |
memset(¶m, 0, sizeof(param)); |
820 |
memset(¶m, 0, sizeof(param)); |
811 |
param.sched_priority = 0; |
821 |
param.sched_priority = 0; |
812 |
if (sched_setscheduler(t->pid, SCHED_OTHER|SCHED_RESET_ON_FORK, ¶m) < 0) { |
822 |
if (_sched_setscheduler(t->pid, SCHED_OTHER|SCHED_RESET_ON_FORK, ¶m) < 0) { |
813 |
r = -errno; |
823 |
r = -errno; |
814 |
syslog(LOG_ERR, "Failed to make process %llu SCHED_NORMAL: %s\n", (unsigned long long) t->pid, strerror(errno)); |
824 |
syslog(LOG_ERR, "Failed to make process %llu SCHED_NORMAL: %s\n", (unsigned long long) t->pid, strerror(errno)); |
815 |
goto finish; |
825 |
goto finish; |
Lines 943-949
Link Here
|
943 |
if (errno != 0 || !e || *e != 0) |
953 |
if (errno != 0 || !e || *e != 0) |
944 |
continue; |
954 |
continue; |
945 |
|
955 |
|
946 |
if ((r = sched_getscheduler(tid)) < 0) { |
956 |
if ((r = _sched_getscheduler(tid)) < 0) { |
947 |
if (errno != ESRCH) |
957 |
if (errno != ESRCH) |
948 |
syslog(LOG_WARNING, "Warning: sched_getscheduler() failed: %s\n", strerror(errno)); |
958 |
syslog(LOG_WARNING, "Warning: sched_getscheduler() failed: %s\n", strerror(errno)); |
949 |
continue; |
959 |
continue; |