Not checking nice_limit here can result in some calls to setpriority() succeeding while others fail, which can result in relative priorities being incorrect. For example, buffer underflows can occur in winepulse.drv because the priority is too low in pulse_timer_loop().
From: Conor McCarthy cmccarthy@codeweavers.com
--- server/thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/server/thread.c b/server/thread.c index 27a40ce38ad..603bf2bd0a5 100644 --- a/server/thread.c +++ b/server/thread.c @@ -256,7 +256,8 @@ static void apply_thread_priority( struct thread *thread, int effective_priority if (effective_priority >= LOW_REALTIME_PRIORITY) effective_priority = LOW_REALTIME_PRIORITY - 1; /* map an NT application band [1,15] priority to [-nice_limit, nice_limit] */ niceness = (min + (effective_priority - 1) * range / 14); - setpriority( PRIO_PROCESS, thread->unix_tid, niceness ); + if (setpriority( PRIO_PROCESS, thread->unix_tid, niceness ) != 0) + fprintf( stderr, "wine: setpriority %d for pid %d failed: %d\n", niceness, thread->unix_tid, errno ); }
#elif defined(__APPLE__)
From: Conor McCarthy cmccarthy@codeweavers.com
Not checking nice_limit here can result in some calls to setpriority() succeeding while others fail, which can result in relative priorities being incorrect. For example, buffer underflows can occur in winepulse.drv because the priority is too low in pulse_timer_loop(). --- server/thread.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/server/thread.c b/server/thread.c index 603bf2bd0a5..addb0292e5f 100644 --- a/server/thread.c +++ b/server/thread.c @@ -252,6 +252,9 @@ static void apply_thread_priority( struct thread *thread, int effective_priority { int min = -nice_limit, max = nice_limit, range = max - min, niceness;
+ if (nice_limit >= 0) + return; + /* FIXME: handle realtime priorities using SCHED_RR if possible */ if (effective_priority >= LOW_REALTIME_PRIORITY) effective_priority = LOW_REALTIME_PRIORITY - 1; /* map an NT application band [1,15] priority to [-nice_limit, nice_limit] */
Printing errors from the server should be avoided. If there's really a need for it, the error should be propagated to the client and printed there.