From 686b24cfb95e4f451b5993c2c15cbf50c173b32e Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 30 Nov 2023 10:38:28 -0800 Subject: til_fb: initialize synchronization primitives earlier Noticed while working on unrelated til_fb stuff; once _til_fb_page_new() started taking a mutex, its use in til_fb_new() was too early relative to initializing said mutex. Funny that this never blew anything up nor angered ASAN, just having the memory allocated and zeroed goes a long way towards hiding such things... for better or worse. --- src/til_fb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/til_fb.c b/src/til_fb.c index 951688c..a802c40 100644 --- a/src/til_fb.c +++ b/src/til_fb.c @@ -579,17 +579,17 @@ int til_fb_new(const til_fb_ops_t *ops, const char *title, const til_setup_t *se goto fail; } - for (int i = 0; i < n_pages; i++) - _til_fb_page_new(fb); - - fb->n_pages = n_pages; - pthread_mutex_init(&fb->ready_mutex, NULL); pthread_cond_init(&fb->ready_cond, NULL); pthread_mutex_init(&fb->inactive_mutex, NULL); pthread_cond_init(&fb->inactive_cond, NULL); pthread_mutex_init(&fb->rebuild_mutex, NULL); + for (int i = 0; i < n_pages; i++) + _til_fb_page_new(fb); + + fb->n_pages = n_pages; + page = _til_fb_page_get(fb); if (!page) { r = -ENOMEM; -- cgit v1.2.3