More Linux fixes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c
index 7141888..30a3748 100644
--- a/src/core/linux/SDL_threadprio.c
+++ b/src/core/linux/SDL_threadprio.c
@@ -223,53 +223,53 @@ SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedP
#if SDL_THREADS_DISABLED
return SDL_Unsupported();
#else
- if (schedPolicy != SCHED_RR && schedPolicy != SCHED_FIFO && setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
- return 0;
- }
+ int osPriority;
-#if SDL_USE_LIBDBUS
- /* Note that this fails you most likely:
- * Have your process's scheduler incorrectly configured.
- See the requirements at:
- http://git.0pointer.net/rtkit.git/tree/README#n16
- * Encountered dbus/polkit security restrictions. Note
- that the RealtimeKit1 dbus endpoint is inaccessible
- over ssh connections for most common distro configs.
- You might want to check your local config for details:
- /usr/share/polkit-1/actions/org.freedesktop.RealtimeKit1.policy
-
- README and sample code at: http://git.0pointer.net/rtkit.git
- */
if (schedPolicy == SCHED_RR || schedPolicy == SCHED_FIFO) {
- int rtPriority;
-
if (sdlPriority == SDL_THREAD_PRIORITY_LOW) {
- rtPriority = 1;
+ osPriority = 1;
} else if (sdlPriority == SDL_THREAD_PRIORITY_HIGH) {
- rtPriority = rtkit_max_realtime_priority * 3 / 4;
+ osPriority = rtkit_max_realtime_priority * 3 / 4;
} else if (sdlPriority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
- rtPriority = rtkit_max_realtime_priority;
+ osPriority = rtkit_max_realtime_priority;
} else {
- rtPriority = rtkit_max_realtime_priority / 2;
- }
-
- if (rtkit_setpriority_realtime((pid_t)threadID, rtPriority)) {
- return 0;
+ osPriority = rtkit_max_realtime_priority / 2;
}
} else {
- int niceLevel;
-
if (sdlPriority == SDL_THREAD_PRIORITY_LOW) {
- niceLevel = 19;
+ osPriority = 19;
} else if (sdlPriority == SDL_THREAD_PRIORITY_HIGH) {
- niceLevel = -10;
+ osPriority = -10;
} else if (sdlPriority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
- niceLevel = -20;
+ osPriority = -20;
} else {
- niceLevel = 0;
+ osPriority = 0;
+ }
+
+ if (setpriority(PRIO_PROCESS, (id_t)threadID, osPriority) == 0) {
+ return 0;
}
+ }
+
+#if SDL_USE_LIBDBUS
+ /* Note that this fails you most likely:
+ * Have your process's scheduler incorrectly configured.
+ See the requirements at:
+ http://git.0pointer.net/rtkit.git/tree/README#n16
+ * Encountered dbus/polkit security restrictions. Note
+ that the RealtimeKit1 dbus endpoint is inaccessible
+ over ssh connections for most common distro configs.
+ You might want to check your local config for details:
+ /usr/share/polkit-1/actions/org.freedesktop.RealtimeKit1.policy
- if (rtkit_setpriority_nice((pid_t)threadID, niceLevel)) {
+ README and sample code at: http://git.0pointer.net/rtkit.git
+ */
+ if (schedPolicy == SCHED_RR || schedPolicy == SCHED_FIFO) {
+ if (rtkit_setpriority_realtime((pid_t)threadID, osPriority)) {
+ return 0;
+ }
+ } else {
+ if (rtkit_setpriority_nice((pid_t)threadID, osPriority)) {
return 0;
}
}
diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
index d2f2043..6df049c 100644
--- a/src/thread/pthread/SDL_systhread.c
+++ b/src/thread/pthread/SDL_systhread.c
@@ -247,8 +247,10 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
}
#if __LINUX__
- pid_t linuxTid = syscall(SYS_gettid);
- return SDL_LinuxSetThreadPriorityAndPolicy(linuxTid, priority, policy);
+ {
+ pid_t linuxTid = syscall(SYS_gettid);
+ return SDL_LinuxSetThreadPriorityAndPolicy(linuxTid, priority, policy);
+ }
#else
if (priority == SDL_THREAD_PRIORITY_LOW) {
sched.sched_priority = sched_get_priority_min(policy);