8080504: [macosx] SunToolkit.realSync() may hang
authoranashaty
Mon, 29 Jun 2015 13:47:28 +0300
changeset 31654 9f95289d9553
parent 31653 d88ff422c7fb
child 31655 6bc54745fef4
8080504: [macosx] SunToolkit.realSync() may hang Reviewed-by: serb, prr
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h
jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Mon Jun 29 01:27:08 2015 +0300
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Mon Jun 29 13:47:28 2015 +0300
@@ -376,7 +376,7 @@
     if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) {
         NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp;
         [theApp postDummyEvent];
-        [theApp waitForDummyEvent];
+        [theApp waitForDummyEvent:timeout];
     } else {
         // could happen if we are embedded inside SWT application,
         // in this case just spin a single empty block through 
--- a/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h	Mon Jun 29 01:27:08 2015 +0300
+++ b/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h	Mon Jun 29 13:47:28 2015 +0300
@@ -38,7 +38,7 @@
 - (void) setDockIconWithEnv:(JNIEnv *)env;
 - (void) postDummyEvent;
 - (void) postRunnableEvent:(void (^)())block;
-- (void) waitForDummyEvent;
+- (void) waitForDummyEvent:(long long) timeout;
 
 + (void) runAWTLoopWithApp:(NSApplication*)app;
 
--- a/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Mon Jun 29 01:27:08 2015 +0300
+++ b/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Mon Jun 29 13:47:28 2015 +0300
@@ -398,8 +398,14 @@
     [pool drain];
 }
 
-- (void)waitForDummyEvent {
-    [seenDummyEventLock lockWhenCondition:YES];
+- (void)waitForDummyEvent:(long long) timeout {
+    if (timeout >= 0) {
+        double sec = ((double) timeout)/1000;
+        [seenDummyEventLock lockWhenCondition:YES
+                               beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
+    } else {
+        [seenDummyEventLock lockWhenCondition:YES];
+    }
     [seenDummyEventLock unlock];
     [seenDummyEventLock release];