[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 14:31:45 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 1c16ac80d544f5f5b8c69c439e7cfbb8728a3b5e
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 12 16:29:28 2010 +0000

    Add BinarySemaphore class to CoreIPC and use it in Connection::waitForSyncReply
    https://bugs.webkit.org/show_bug.cgi?id=47526
    
    Reviewed by Sam Weinig.
    
    * Platform/CoreIPC/BinarySemaphore.cpp: Added.
    * Platform/CoreIPC/BinarySemaphore.h: Added.
    Add BinarySemaphore class.
    
    * Platform/CoreIPC/Connection.cpp:
    (CoreIPC::Connection::sendSyncMessage):
    (CoreIPC::Connection::waitForSyncReply):
    (CoreIPC::Connection::processIncomingMessage):
    Use the binary semaphore and the newly added m_pendingSyncRepliesMutex.
    
    * WebKit2.pro:
    * WebKit2.xcodeproj/project.pbxproj:
    * win/WebKit2.vcproj:
    Add new files.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69584 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index e18b814..1da5314 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-11  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Add BinarySemaphore class to CoreIPC and use it in Connection::waitForSyncReply
+        https://bugs.webkit.org/show_bug.cgi?id=47526
+
+        * Platform/CoreIPC/BinarySemaphore.cpp: Added.
+        * Platform/CoreIPC/BinarySemaphore.h: Added.
+        Add BinarySemaphore class.
+
+        * Platform/CoreIPC/Connection.cpp:
+        (CoreIPC::Connection::sendSyncMessage):
+        (CoreIPC::Connection::waitForSyncReply):
+        (CoreIPC::Connection::processIncomingMessage):
+        Use the binary semaphore and the newly added m_pendingSyncRepliesMutex.
+
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add new files.
+
 2010-10-12  Adam Roben  <aroben at apple.com>
 
         Bring WebKit2 .vcproj files up-to-date with reality
diff --git a/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp b/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp
new file mode 100644
index 0000000..c975dff
--- /dev/null
+++ b/WebKit2/Platform/CoreIPC/BinarySemaphore.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "BinarySemaphore.h"
+
+namespace CoreIPC {
+
+BinarySemaphore::BinarySemaphore()
+    : m_isSet(false)
+{
+}
+    
+BinarySemaphore::~BinarySemaphore()
+{
+}
+
+void BinarySemaphore::signal()
+{
+    MutexLocker locker(m_mutex);
+
+    m_isSet = true;
+    m_condition.signal();
+}
+
+bool BinarySemaphore::wait(double absoluteTime)
+{
+    MutexLocker locker(m_mutex);
+
+    bool timedOut = false;
+    while (!m_isSet) {
+        timedOut = !m_condition.timedWait(m_mutex, absoluteTime);
+        if (timedOut)
+            return false;
+    }
+
+    // Reset the semaphore.
+    m_isSet = false;
+    return true;
+}
+
+
+} // namespace CoreIPC
diff --git a/WebKit2/Platform/CoreIPC/BinarySemaphore.h b/WebKit2/Platform/CoreIPC/BinarySemaphore.h
new file mode 100644
index 0000000..8113236
--- /dev/null
+++ b/WebKit2/Platform/CoreIPC/BinarySemaphore.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BinarySemaphore_h
+#define BinarySemaphore_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/ThreadingPrimitives.h>
+
+namespace CoreIPC {
+
+class BinarySemaphore {
+    WTF_MAKE_NONCOPYABLE(BinarySemaphore);
+
+public:
+    BinarySemaphore();
+    ~BinarySemaphore();
+
+    void signal();
+    bool wait(double absoluteTime);
+
+private:
+    bool m_isSet;
+
+    Mutex m_mutex;
+    ThreadCondition m_condition;
+};
+
+} // namespace CoreIPC
+
+
+#endif // BinarySemaphore_h
diff --git a/WebKit2/Platform/CoreIPC/Connection.cpp b/WebKit2/Platform/CoreIPC/Connection.cpp
index f9ed097..027d7d4 100644
--- a/WebKit2/Platform/CoreIPC/Connection.cpp
+++ b/WebKit2/Platform/CoreIPC/Connection.cpp
@@ -165,7 +165,7 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
     
     // Push the pending sync reply information on our stack.
     {
-        MutexLocker locker(m_waitForSyncReplyMutex);
+        MutexLocker locker(m_pendingSyncRepliesMutex);
         m_pendingSyncReplies.append(PendingSyncReply(syncRequestID));
     }
     
@@ -177,7 +177,7 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
 
     // Finally, pop the pending sync reply information.
     {
-        MutexLocker locker(m_waitForSyncReplyMutex);
+        MutexLocker locker(m_pendingSyncRepliesMutex);
         ASSERT(m_pendingSyncReplies.last().syncRequestID == syncRequestID);
         m_pendingSyncReplies.removeLast();
     }
@@ -191,20 +191,22 @@ PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID,
 
     bool timedOut = false;
     while (!timedOut) {
-        MutexLocker locker(m_waitForSyncReplyMutex);
+        {
+            MutexLocker locker(m_pendingSyncRepliesMutex);
 
-        // First, check if there is a sync reply at the top of the stack.
-        ASSERT(!m_pendingSyncReplies.isEmpty());
+            // First, check if there is a sync reply at the top of the stack.
+            ASSERT(!m_pendingSyncReplies.isEmpty());
             
-        PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
-        ASSERT(pendingSyncReply.syncRequestID == syncRequestID);
+            PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
+            ASSERT(pendingSyncReply.syncRequestID == syncRequestID);
             
-        // We found the sync reply, return it.
-        if (pendingSyncReply.didReceiveReply)
-            return pendingSyncReply.releaseReplyDecoder();
+            // We found the sync reply, return it.
+            if (pendingSyncReply.didReceiveReply)
+                return pendingSyncReply.releaseReplyDecoder();
+        }
 
         // We didn't find a sync reply yet, keep waiting.
-        timedOut = !m_waitForSyncReplyCondition.timedWait(m_waitForSyncReplyMutex, absoluteTime);
+        timedOut = !m_waitForSyncReplySemaphore.wait(absoluteTime);
     }
 
     // We timed out.
@@ -215,7 +217,7 @@ void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<Argument
 {
     // Check if this is a sync reply.
     if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
-        MutexLocker locker(m_waitForSyncReplyMutex);
+        MutexLocker locker(m_pendingSyncRepliesMutex);
         ASSERT(!m_pendingSyncReplies.isEmpty());
 
         PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
@@ -224,7 +226,7 @@ void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<Argument
         pendingSyncReply.replyDecoder = arguments.leakPtr();
         pendingSyncReply.didReceiveReply = true;
 
-        m_waitForSyncReplyCondition.signal();
+        m_waitForSyncReplySemaphore.signal();
         return;
     }
     
diff --git a/WebKit2/Platform/CoreIPC/Connection.h b/WebKit2/Platform/CoreIPC/Connection.h
index a6b2161..7b3bbff 100644
--- a/WebKit2/Platform/CoreIPC/Connection.h
+++ b/WebKit2/Platform/CoreIPC/Connection.h
@@ -30,6 +30,7 @@
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
 #include "Arguments.h"
+#include "BinarySemaphore.h"
 #include "MessageID.h"
 #include "WorkQueue.h"
 #include <wtf/HashMap.h>
@@ -224,12 +225,10 @@ private:
             return reply.release();
         }
     };
+    
+    BinarySemaphore m_waitForSyncReplySemaphore;
 
-
-    Mutex m_waitForSyncReplyMutex;
-    ThreadCondition m_waitForSyncReplyCondition;
-
-    // This is protected by the m_waitForSyncReply mutex.    
+    Mutex m_pendingSyncRepliesMutex;
     Vector<PendingSyncReply> m_pendingSyncReplies;
 
 #if PLATFORM(MAC)
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 5fbd32a..d5f69f7 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -155,6 +155,7 @@ HEADERS += \
     Platform/CoreIPC/ArgumentEncoder.h \
     Platform/CoreIPC/Arguments.h \
     Platform/CoreIPC/Attachment.h \
+    Platform/CoreIPC/BinarySemaphore.h \
     Platform/CoreIPC/Connection.h \
     Platform/CoreIPC/CoreIPCMessageKinds.h \
     Platform/CoreIPC/DataReference.h \
@@ -304,6 +305,7 @@ SOURCES += \
     Platform/CoreIPC/ArgumentDecoder.cpp \
     Platform/CoreIPC/ArgumentEncoder.cpp \
     Platform/CoreIPC/Attachment.cpp \
+    Platform/CoreIPC/BinarySemaphore.cpp \
     Platform/CoreIPC/Connection.cpp \
     Platform/CoreIPC/DataReference.cpp \
     Platform/CoreIPC/qt/ConnectionQt.cpp \
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 255cfdb..6f0265d 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -126,6 +126,8 @@
 		1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA5889011EE70400061B882 /* NetscapePluginStream.h */; };
 		1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */; };
 		1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
+		1AC41AC71263C88300054E94 /* BinarySemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC41AC51263C88300054E94 /* BinarySemaphore.h */; };
+		1AC41AC81263C88300054E94 /* BinarySemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC41AC61263C88300054E94 /* BinarySemaphore.cpp */; };
 		1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE117F511DBB30900981615 /* ProcessLauncher.cpp */; };
 		1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4976611FF658E0048B464 /* NPJSObject.h */; };
 		1AE4976911FF658E0048B464 /* NPJSObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE4976711FF658E0048B464 /* NPJSObject.cpp */; };
@@ -584,6 +586,8 @@
 		1AA5889011EE70400061B882 /* NetscapePluginStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginStream.h; sourceTree = "<group>"; };
 		1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginStream.cpp; sourceTree = "<group>"; };
 		1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
+		1AC41AC51263C88300054E94 /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; };
+		1AC41AC61263C88300054E94 /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; };
 		1AE117F511DBB30900981615 /* ProcessLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessLauncher.cpp; sourceTree = "<group>"; };
 		1AE4976611FF658E0048B464 /* NPJSObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPJSObject.h; sourceTree = "<group>"; };
 		1AE4976711FF658E0048B464 /* NPJSObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPJSObject.cpp; sourceTree = "<group>"; };
@@ -1192,6 +1196,8 @@
 				BC032DA110F437D10058C15A /* Arguments.h */,
 				BCEE966A112FAF57006BCC24 /* Attachment.cpp */,
 				BCEE966B112FAF57006BCC24 /* Attachment.h */,
+				1AC41AC61263C88300054E94 /* BinarySemaphore.cpp */,
+				1AC41AC51263C88300054E94 /* BinarySemaphore.h */,
 				BC032DA210F437D10058C15A /* Connection.cpp */,
 				BC032DA310F437D10058C15A /* Connection.h */,
 				1A8EFDFD1253CB6E00F7067F /* DataReference.cpp */,
@@ -1987,6 +1993,7 @@
 				1A3DD206125E5A2F004515E6 /* APIClient.h in Headers */,
 				BCC8B374125FB69000DE46A4 /* WKGeometry.h in Headers */,
 				BC57450C1263B155006F0F12 /* WKBundleNodeHandlePrivate.h in Headers */,
+				1AC41AC71263C88300054E94 /* BinarySemaphore.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2289,6 +2296,7 @@
 				51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */,
 				BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */,
 				1A3DD1FD125E59F3004515E6 /* WebFindClient.cpp in Sources */,
+				1AC41AC81263C88300054E94 /* BinarySemaphore.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index 0abc555..56b77cb 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -1952,6 +1952,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\Platform\CoreIPC\BinarySemaphore.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Platform\CoreIPC\BinarySemaphore.h"
+					>
+				</File>
+				<File
 					RelativePath="..\Platform\CoreIPC\Connection.cpp"
 					>
 				</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list