Properly handle thread cancelation in rwlock_condvar_t