thread-loop: only restore recurse on error

Only restore the previous recurse state when we fail to unlock.
This commit is contained in:
Wim Taymans 2023-04-04 12:20:56 +02:00
parent aa2ea737c7
commit edbfd180d0

View file

@ -60,10 +60,10 @@ static int do_unlock(struct pw_thread_loop *this)
int res; int res;
spa_return_val_if_fail(this->recurse > 0, -EIO); spa_return_val_if_fail(this->recurse > 0, -EIO);
this->recurse--; this->recurse--;
if ((res = pthread_mutex_unlock(&this->lock)) != 0) if ((res = pthread_mutex_unlock(&this->lock)) != 0) {
pw_log_error("%p: thread:%lu: %s", this, pthread_self(), strerror(res)); pw_log_error("%p: thread:%lu: %s", this, pthread_self(), strerror(res));
else
this->recurse++; this->recurse++;
}
return -res; return -res;
} }