Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error handling in thread.c #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions libjack/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ jack_process_already_has_real_time_scheduling (int priority)
int res;
struct rtprio rtp;
res = rtprio(RTP_LOOKUP, getpid(), &rtp);
if (res == 0 && rtp.type == RTP_PRIO_REALTIME && rtp.prio <= priority) {
if (res) {
jack_error("failed to read realtime priority of the process (error=%d: %s)",
res, strerror (res));
return 0; // act like priority isn't sufficient
}
if (rtp.type == RTP_PRIO_REALTIME && rtp.prio <= priority) {
jack_info("process already runs at sufficient realtime priority %u (<=%d)",
(unsigned)rtp.prio,
priority);
Expand All @@ -296,8 +301,8 @@ jack_drop_real_time_scheduling (pthread_t thread)
int x, policy;

if ((x = pthread_getschedparam (thread, &policy, &rtparam)) != 0) {
jack_error ("cannot read thread scheduling priority(%s)\n",
strerror (errno));
jack_error ("cannot read thread scheduling priority (error=%d: %s)\n",
x, strerror (x));
return -1;
}
if (policy == SCHED_OTHER) {
Expand All @@ -307,8 +312,8 @@ jack_drop_real_time_scheduling (pthread_t thread)
memset (&rtparam, 0, sizeof(rtparam));

if ((x = pthread_setschedparam (thread, SCHED_OTHER, &rtparam)) != 0) {
jack_error ("cannot switch to normal scheduling priority(%s)\n",
strerror (errno));
jack_error ("cannot switch to normal scheduling priority (error=%d: %s)\n",
x, strerror (x));
return -1;
}

Expand All @@ -330,7 +335,7 @@ jack_acquire_real_time_scheduling (pthread_t thread, int priority)

if ((x = pthread_setschedparam (thread, SCHED_FIFO, &rtparam)) != 0) {
jack_error ("cannot use real-time scheduling (FIFO at priority %d) "
"[for thread %d, from thread %d] (%d: %s)",
"[for thread %d, from thread %d] (error=%d: %s)",
rtparam.sched_priority,
thread, pthread_self (),
x, strerror (x));
Expand Down