Fixed issue with setting timeout for pthread_cond_wait.