- //PARA_CRIT_LOG("waiting for data\n");
- //usleep(1000);
- //pthread_mutex_unlock(&pawd->mutex);
- pthread_cond_wait(&pawd->data_available, &pawd->mutex);
+ /*
+ * No data available, go to sleep and wait for the main
+ * thread to wake us up. pthread_cond_wait() unlocks
+ * the mutex while it waits and locks it again upon
+ * return.
+ */
+ ret = pthread_cond_wait(&pawd->data_available,
+ &pawd->mutex);
+ /* pthread_cond_wait() can never fail here */
+ assert(ret == 0);