bugfix: lock wasnt always held when calling condition_wait