summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-11-22 05:56:30 +0000
committerDavid Robillard <d@drobilla.net>2012-11-22 05:56:30 +0000
commit5642368878114fd99cb6bf877258945a38c3c0b9 (patch)
treea1a37752cecb7dd6b0470cefabf81d7e2ed141bb
parent994084dd6ace5489d741a825bc381aa38963ef57 (diff)
downloadraul-5642368878114fd99cb6bf877258945a38c3c0b9.tar.gz
raul-5642368878114fd99cb6bf877258945a38c3c0b9.tar.bz2
raul-5642368878114fd99cb6bf877258945a38c3c0b9.zip
Fix crash when calling Thread::set_scheduling on a Thread that does not exist.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4850 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--raul/Thread.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/raul/Thread.hpp b/raul/Thread.hpp
index 9720007..11cd0fb 100644
--- a/raul/Thread.hpp
+++ b/raul/Thread.hpp
@@ -68,10 +68,14 @@ public:
* @return True on success.
*/
virtual bool set_scheduling(bool realtime, unsigned priority) {
- sched_param sp;
- sp.sched_priority = priority;
- const int policy = realtime ? SCHED_FIFO : SCHED_OTHER;
- return !pthread_setschedparam(_pthread, policy, &sp);
+ if (_thread_exists) {
+ sched_param sp;
+ sp.sched_priority = priority;
+ const int policy = realtime ? SCHED_FIFO : SCHED_OTHER;
+ return !pthread_setschedparam(_pthread, policy, &sp);
+ } else {
+ return false;
+ }
}
protected: