diff --git a/libraries/AP_HAL_SITL/Semaphores.cpp b/libraries/AP_HAL_SITL/Semaphores.cpp index 0067fd9c148..b68ab31e86a 100644 --- a/libraries/AP_HAL_SITL/Semaphores.cpp +++ b/libraries/AP_HAL_SITL/Semaphores.cpp @@ -22,12 +22,12 @@ Semaphore::Semaphore() bool Semaphore::give() { take_count--; - if (pthread_mutex_unlock(&_lock) != 0) { - AP_HAL::panic("Bad semaphore usage"); - } if (take_count == 0) { owner = (pthread_t)-1; } + if (pthread_mutex_unlock(&_lock) != 0) { + AP_HAL::panic("Bad semaphore usage"); + } return true; }