[Cocoa] WKObject seems to be initializing its target in a thread-safe manner, but...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Nov 2013 22:14:38 +0000 (22:14 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Nov 2013 22:14:38 +0000 (22:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123640

Reviewed by Darin Adler.

* Shared/Cocoa/WKObject.mm:
(initializeTargetIfNeeded): Removed misleading incorrect code.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158460 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Cocoa/WKObject.mm

index fffa7e8..15b4aaa 100644 (file)
@@ -1,3 +1,13 @@
+2013-11-01  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] WKObject seems to be initializing its target in a thread-safe manner, but really is not
+        https://bugs.webkit.org/show_bug.cgi?id=123640
+
+        Reviewed by Darin Adler.
+
+        * Shared/Cocoa/WKObject.mm:
+        (initializeTargetIfNeeded): Removed misleading incorrect code.
+
 2013-11-01  Benjamin Poulain  <benjamin@webkit.org>
 
         [WK2] Create a unique identifier for WebPageGroup if the input name is empty
index 49fdeca..3cf33c5 100644 (file)
@@ -33,7 +33,7 @@
 using namespace WebKit;
 
 @implementation WKObject {
-    dispatch_once_t _targetInitializationToken;
+    BOOL _hasInitializedTarget;
     NSObject *_target;
 }
 
@@ -47,9 +47,11 @@ using namespace WebKit;
 
 static inline void initializeTargetIfNeeded(WKObject *self)
 {
-    dispatch_once(&self->_targetInitializationToken, ^{
-        self->_target = [self _web_createTarget];
-    });
+    if (self->_hasInitializedTarget)
+        return;
+
+    self->_hasInitializedTarget = YES;
+    self->_target = [self _web_createTarget];
 }
 
 - (BOOL)isEqual:(id)object