Do not wait forever to get fast enumeration state from file provider extension service
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 9 Jul 2024 06:48:17 +0000 (14:48 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 9 Jul 2024 06:48:17 +0000 (14:48 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileproviderxpc_mac.mm

index 9ccade29f6d5c8896cdd04f1500691644a907bb3..5db62867fb139395062398d43fd964e0562b4904 100644 (file)
 #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 @@ std::optional<std::pair<bool, bool>> FileProviderXPC::fastEnumerationStateForExt
         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<std::pair<bool, bool>>{{receivedFastEnumerationEnabled, receivedFastEnumerationSet}};
 }