-
Nils Goroll authored
The dance of taking a reference when waiting caused a lot of trouble already before, and with a fresh look at it does not seem to make much sense. But most importantly, it was wrong: lbuf->ff was set to NULL in logbuffer_flush_finish_work_one() before the mutex was returned with pthread_cond_wait(), so if (ff == NULL) goto unlock; in logbuffer_wait_flush_fini() could lead to the function returning before logbuffer_flush_finish_work_one() _was_ actually done. But with bceec122 this could lead to the stack memory being repurposed (logbuffer_flush_finish returning) before it was actually safe to. This issue could surface in fellow_log_test hanging. We also now return all allocations under the lock to prevent a race with fellow_log_close() where flush finish threads could outlive the ffd, resulting in buddy leak detection to fire, because the ff allocation was not returned. Fixes #49