From 8b66b22895115954dca2f1a6c5ab67172b6a6a1c Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 19 Oct 2024 02:25:51 -0700 Subject: [PATCH] Fix Windows build break. (#2935) Use `withLockPrimitive` to access the underlying lock. ### Motivation: The current method of accessing the lock doesn't build. This fixes bug #2934. ### Modifications: Access the lock via `withLockPrimitive`. ### Result: Now it builds! :) --- Sources/NIOConcurrencyHelpers/lock.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Sources/NIOConcurrencyHelpers/lock.swift b/Sources/NIOConcurrencyHelpers/lock.swift index 42e2a3533c..3b985afaa6 100644 --- a/Sources/NIOConcurrencyHelpers/lock.swift +++ b/Sources/NIOConcurrencyHelpers/lock.swift @@ -229,12 +229,10 @@ public final class ConditionLock { } let dwWaitStart = timeGetTime() - if !SleepConditionVariableSRW( - self.cond, - self.mutex._storage.mutex, - dwMilliseconds, - 0 - ) { + let result = self.mutex.withLockPrimitive { mutex in + SleepConditionVariableSRW(self.cond, mutex, dwMilliseconds, 0) + } + if !result { let dwError = GetLastError() if dwError == ERROR_TIMEOUT { self.unlock() @@ -242,7 +240,6 @@ public final class ConditionLock { } fatalError("SleepConditionVariableSRW: \(dwError)") } - // NOTE: this may be a spurious wakeup, adjust the timeout accordingly dwMilliseconds = dwMilliseconds - (timeGetTime() - dwWaitStart) }