From: Colin Walters Date: Fri, 4 Aug 2023 02:49:48 +0000 (-0400) Subject: deploy: Fix mutex locking for global sync timeout X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2^2~28^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=402e04280b54c058ad47be99fe6a9326caf2ae00;p=ostree.git deploy: Fix mutex locking for global sync timeout The locking here was always too long - by holding the mutex during the `sync()` call, it means `g_cond_wait_until()` can never wake up (because its API requires the mutex to be locked). Confusingly though of course we do still print the "timed out" message, and I think that tricked us when we were doing testing here. We only need to lock the mutex when we're manipulating shared state, which basically boils down to the `gboolean success`. --- diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 974d2336..91bccdc0 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -1606,11 +1606,10 @@ static void * sync_in_thread (void *ptr) { SyncData *syncdata = ptr; - // Ensure that the caller is blocked waiting - g_mutex_lock (&syncdata->mutex); ot_journal_print (LOG_INFO, "Starting global sync()"); sync (); ot_journal_print (LOG_INFO, "Completed global sync()"); + g_mutex_lock (&syncdata->mutex); // Signal success syncdata->success = true; g_cond_broadcast (&syncdata->cond);