-#if YAZ_POSIX_THREADS
- pthread_mutex_lock(&p->mutex);
-
- while (p->is_sorting)
- pthread_cond_wait(&p->cond_sorting, &p->mutex);
-
- p->is_sorting = 1;
-
- p->thread_ptr_top = p->ptr_top;
- p->thread_ptr_i = p->ptr_i;
- p->thread_key_buf = p->key_buf;
-
- tmp = p->key_buf;
- p->key_buf = p->alt_buf;
- p->alt_buf = tmp;
-
- yaz_log(YLOG_LOG, "key_block_flush 1 p=%p", p);
- pthread_cond_signal(&p->work_available);
-
- if (is_final)