static void* writer_routine(void *arg) {
struct writer_thread* my = arg;
+ struct buf* buf = NULL;
+ lock(&shared_queue_mutex);
for (;;) {
- // FIXME: less locking
- struct buf* buf = NULL;
-
- lock(&shared_queue_mutex);
while (!stopping && STAILQ_EMPTY(&my->queue)) {
// Sleep.
pthread_cond_wait(&shared_wakeup_cond, &shared_queue_mutex);
// Unreference buffer, freeing it if we have to.
lock(&shared_queue_mutex);
unref_buf(buf);
- unlock(&shared_queue_mutex);
}
warnx("thread exiting cleanly");
return NULL;