From aa0ecd512d4247e6de33c34a2b7fb93fce1d258c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 9 Jul 2024 14:47:42 +0800 Subject: [PATCH 1/3] Fix _Generic C11 extension compile warning under clang Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderxpc_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index fb956030bde5..9ccade29f6d5 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -154,7 +154,7 @@ receivedFastEnumerationSet = set; dispatch_semaphore_signal(semaphore); }]; - dispatch_wait(semaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); return std::optional>{{receivedFastEnumerationEnabled, receivedFastEnumerationSet}}; } From 1f243c3bfc6a57c43bcdd988d66ab9c75346b71c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 9 Jul 2024 14:48:17 +0800 Subject: [PATCH 2/3] Do not wait forever to get fast enumeration state from file provider extension service Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderxpc_mac.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index 9ccade29f6d5..5db62867fb13 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -20,6 +20,10 @@ #include "gui/macOS/fileproviderdomainmanager.h" #include "gui/macOS/fileproviderxpc_mac_utils.h" +namespace { + constexpr int64_t semaphoreWaitDelta = 3000000000; // 3 seconds +} + namespace OCC::Mac { Q_LOGGING_CATEGORY(lcFileProviderXPC, "nextcloud.gui.macos.fileprovider.xpc", QtInfoMsg) @@ -154,7 +158,7 @@ receivedFastEnumerationSet = set; dispatch_semaphore_signal(semaphore); }]; - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta)); return std::optional>{{receivedFastEnumerationEnabled, receivedFastEnumerationSet}}; } From 953b1035320c94de60c23a52b61f6d9c8599fe54 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 9 Jul 2024 14:48:47 +0800 Subject: [PATCH 3/3] Add check to detect if we timed out wait for file provider extension service response on fast enumeration state Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderxpc_mac.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index 5db62867fb13..cc0b7b467923 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -152,13 +152,19 @@ __block BOOL receivedFastEnumerationEnabled; // What is the value of the setting being used by the extension? __block BOOL receivedFastEnumerationSet; // Has the setting been set by the user? + __block BOOL receivedResponse = NO; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [service getFastEnumerationStateWithCompletionHandler:^(BOOL enabled, BOOL set) { receivedFastEnumerationEnabled = enabled; receivedFastEnumerationSet = set; + receivedResponse = YES; dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta)); + if (!receivedResponse) { + qCWarning(lcFileProviderXPC) << "Did not receive response for fast enumeration state"; + return std::nullopt; + } return std::optional>{{receivedFastEnumerationEnabled, receivedFastEnumerationSet}}; }