From 5642368878114fd99cb6bf877258945a38c3c0b9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 22 Nov 2012 05:56:30 +0000 Subject: 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 --- raul/Thread.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'raul') 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: -- cgit v1.2.1