Fix FatalUnsetRealtimePriority
Errno was getting modified, so PCHECK wasn't printing the right thing.
Save it and restore it around the scheduler restore.
While I was debugging this with strace, I noticed that we weren't
switching to SCHED_OTHER properly, and that syscall was returning an
error (which was the errorno being displayed with PCHECK).
Change-Id: Iadd0c8725766318f1480ff2f50d51fa0a6a0516d
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/realtime.cc b/aos/realtime.cc
index ea54d9e..2f299e6 100644
--- a/aos/realtime.cc
+++ b/aos/realtime.cc
@@ -293,10 +293,11 @@
}
void FatalUnsetRealtimePriority() {
+ int saved_errno = errno;
// Drop our priority first. We are about to do lots of work to undo
// everything, don't get overly clever.
struct sched_param param;
- param.sched_priority = 20;
+ param.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, ¶m);
is_realtime = false;
@@ -311,12 +312,13 @@
// ignore . and .. which are zeroes for some reason
if (thread_id != 0) {
struct sched_param param;
- param.sched_priority = 20;
+ param.sched_priority = 0;
sched_setscheduler(thread_id, SCHED_OTHER, ¶m);
}
}
closedir(dirp);
}
+ errno = saved_errno;
}
void RegisterMallocHook() {