Ken Thomases : winemac: Move CVDisplayLink operations out of @synchronized blocks to avoid potential deadlock.

Alexandre Julliard julliard at winehq.org
Mon May 8 17:21:23 CDT 2017


Module: wine
Branch: master
Commit: 24d3795285102170834ee624e3d07036c87005ca
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=24d3795285102170834ee624e3d07036c87005ca

Author: Ken Thomases <ken at codeweavers.com>
Date:   Mon May  8 12:52:02 2017 -0500

winemac: Move CVDisplayLink operations out of @synchronized blocks to avoid potential deadlock.

The -fire method called by the display link callback also synchronizes on self
(while accessing the windows array).  Display link operations use a lock to
synchronize, too, and it's held while the callback is running.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/cocoa_window.m | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 1150322..7cb3459 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -218,22 +218,26 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
 
     - (void) addWindow:(WineWindow*)window
     {
+        BOOL needsStart;
         @synchronized(self) {
-            BOOL needsStart = !_windows.count;
+            needsStart = !_windows.count;
             [_windows addObject:window];
-            if (needsStart)
-                CVDisplayLinkStart(_link);
         }
+        if (needsStart)
+            CVDisplayLinkStart(_link);
     }
 
     - (void) removeWindow:(WineWindow*)window
     {
+        BOOL shouldStop = FALSE;
         @synchronized(self) {
             BOOL wasRunning = _windows.count > 0;
             [_windows removeObject:window];
             if (wasRunning && !_windows.count)
-                CVDisplayLinkStop(_link);
+                shouldStop = TRUE;
         }
+        if (shouldStop)
+            CVDisplayLinkStop(_link);
     }
 
     - (void) fire




More information about the wine-cvs mailing list