Unreviewed, rolling out r211535, r211566, and r211568.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2017 23:39:57 +0000 (23:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2017 23:39:57 +0000 (23:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167765

Causing timeouts? (Requested by andersca_ on #webkit).

Reverted changesets:

"IPC::Connection receive ports should be guarded"
https://bugs.webkit.org/show_bug.cgi?id=167704
http://trac.webkit.org/changeset/211535

"<rdar://problem/30323148> Webkit Nightly on 10.10 broken"
http://trac.webkit.org/changeset/211566

"<rdar://problem/30323148> Webkit Nightly on 10.10 broken"
http://trac.webkit.org/changeset/211568

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

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm

index 158aee9..008db10 100644 (file)
@@ -1,3 +1,22 @@
+2017-02-02  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r211535, r211566, and r211568.
+        https://bugs.webkit.org/show_bug.cgi?id=167765
+
+        Causing timeouts? (Requested by andersca_ on #webkit).
+
+        Reverted changesets:
+
+        "IPC::Connection receive ports should be guarded"
+        https://bugs.webkit.org/show_bug.cgi?id=167704
+        http://trac.webkit.org/changeset/211535
+
+        "<rdar://problem/30323148> Webkit Nightly on 10.10 broken"
+        http://trac.webkit.org/changeset/211566
+
+        "<rdar://problem/30323148> Webkit Nightly on 10.10 broken"
+        http://trac.webkit.org/changeset/211568
+
 2017-02-02  Megan Gardner  <megan_gardner@apple.com>
 
         Don't attempt wide gammut on older OSes
index 81ae5ed..72b3aa8 100644 (file)
@@ -120,7 +120,7 @@ void Connection::platformInvalidate()
         }
 
         if (m_receivePort) {
-            mach_port_destruct(mach_task_self(), m_receivePort, 0, reinterpret_cast<mach_port_context_t>(this));
+            mach_port_mod_refs(mach_task_self(), m_receivePort, MACH_PORT_RIGHT_RECEIVE, -1);
             m_receivePort = MACH_PORT_NULL;
         }
 
@@ -170,8 +170,6 @@ void Connection::platformInitialize(Identifier identifier)
     if (m_isServer) {
         m_receivePort = identifier.port;
         m_sendPort = MACH_PORT_NULL;
-
-        mach_port_guard(mach_task_self(), m_receivePort, reinterpret_cast<mach_port_context_t>(this), true);
     } else {
         m_receivePort = MACH_PORT_NULL;
         m_sendPort = identifier.port;
@@ -183,6 +181,19 @@ void Connection::platformInitialize(Identifier identifier)
     m_xpcConnection = identifier.xpcConnection;
 }
 
+template<typename Function>
+static dispatch_source_t createReceiveSource(mach_port_t receivePort, WorkQueue& workQueue, Function&& function)
+{
+    dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, receivePort, 0, workQueue.dispatchQueue());
+    dispatch_source_set_event_handler(source, function);
+
+    dispatch_source_set_cancel_handler(source, ^{
+        mach_port_mod_refs(mach_task_self(), receivePort, MACH_PORT_RIGHT_RECEIVE, -1);
+    });
+
+    return source;
+}
+
 bool Connection::open()
 {
     if (m_isServer) {
@@ -194,45 +205,37 @@ bool Connection::open()
         ASSERT(m_sendPort);
 
         // Create the receive port.
-        uint32_t flags = MPO_CONTEXT_AS_GUARD | MPO_QLIMIT |  MPO_STRICT | MPO_INSERT_SEND_RIGHT;
+        mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_receivePort);
 
 #if PLATFORM(MAC)
-        flags |= MPO_DENAP_RECEIVER;
+        mach_port_set_attributes(mach_task_self(), m_receivePort, MACH_PORT_DENAP_RECEIVER, (mach_port_info_t)0, 0);
 #endif
 
-        mach_port_options_t portOptions;
-        portOptions.flags = flags;
-        portOptions.mpl.mpl_qlimit = MACH_PORT_QLIMIT_LARGE;
-        mach_port_construct(mach_task_self(), &portOptions, reinterpret_cast<mach_port_context_t>(this), &m_receivePort);
-
         m_isConnected = true;
         
+        // Send the initialize message, which contains a send right for the server to use.
         auto encoder = std::make_unique<Encoder>("IPC", "InitializeConnection", 0);
-        encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MOVE_SEND));
+        encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND));
 
         initializeSendSource();
 
         sendMessage(WTFMove(encoder), { });
     }
 
+    // Change the message queue length for the receive port.
+    setMachPortQueueLength(m_receivePort, MACH_PORT_QLIMIT_LARGE);
+
+    // Register the data available handler.
     RefPtr<Connection> connection(this);
-    m_receiveSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, m_receivePort, 0, m_connectionQueue->dispatchQueue());
-    dispatch_source_set_event_handler(m_receiveSource, [connection] {
+    m_receiveSource = createReceiveSource(m_receivePort, m_connectionQueue, [connection] {
         connection->receiveSourceEventHandler();
     });
-    dispatch_source_set_cancel_handler(m_receiveSource, [connection, receivePort = m_receivePort] {
-        mach_port_destruct(mach_task_self(), receivePort, 0, reinterpret_cast<mach_port_context_t>(connection.get()));
-    });
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
     if (m_exceptionPort) {
-        m_exceptionPortDataAvailableSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, m_exceptionPort, 0, m_connectionQueue->dispatchQueue());
-        dispatch_source_set_event_handler(m_exceptionPortDataAvailableSource, [connection] {
+        m_exceptionPortDataAvailableSource = createReceiveSource(m_exceptionPort, m_connectionQueue, [connection] {
             connection->exceptionSourceEventHandler();
         });
-        dispatch_source_set_cancel_handler(m_exceptionPortDataAvailableSource, [connection, exceptionPort = connection->m_exceptionPort] {
-            mach_port_mod_refs(mach_task_self(), exceptionPort, MACH_PORT_RIGHT_RECEIVE, -1);
-        });
 
         auto encoder = std::make_unique<Encoder>("IPC", "SetExceptionPort", 0);
         encoder->encode(MachPort(m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND));