<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[209575] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/209575">209575</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2016-12-08 14:53:58 -0800 (Thu, 08 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Defer sending Mach messages if the queue is full
https://bugs.webkit.org/show_bug.cgi?id=165622
rdar://problem/29518036

Reviewed by Brady Eidson.

Source/WebKit2:

* Platform/IPC/Connection.cpp:
Include MachMessage.h so the Connection destructor can do its thing.

* Platform/IPC/Connection.h:
Add new members.

* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::platformInvalidate):
Null out the pending outgoing mach message.

(IPC::Connection::sendMessage):
New helper that will send a Mach message. If we time out, store the message in m_pendingOutgoingMachMessage.
When our send source will be triggered we'll try to send the message again.

(IPC::Connection::platformCanSendOutgoingMessages):
We can only send messages if we don't have a pending outgoing message.

(IPC::Connection::sendOutgoingMessage):
Call the newly added sendMessage function.

(IPC::Connection::initializeSendSource):
Add the DISPATCH_MACH_SEND_POSSIBLE mask (and DISPATCH_MACH_SEND_DEAD which was previously implicit).
In our event handler, check for DISPATCH_MACH_SEND_POSSIBLE and try to send the pending outgoing message again.

* Platform/IPC/mac/MachMessage.cpp:
(IPC::MachMessage::create):
Rename length to size.

(IPC::MachMessage::MachMessage):
Initialize m_shouldFreeDescriptors.

(IPC::MachMessage::~MachMessage):
Call mach_msg_destroy, which will free the descriptors.

(IPC::MachMessage::leakDescriptors):
Set m_shouldFreeDescriptors to false.

* Platform/IPC/mac/MachMessage.h:
(IPC::MachMessage::size):
(IPC::MachMessage::length): Deleted.

Source/WTF:

Add new SPI.

* wtf/spi/darwin/XPCSPI.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfspidarwinXPCSPIh">trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCConnectioncpp">trunk/Source/WebKit2/Platform/IPC/Connection.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCConnectionh">trunk/Source/WebKit2/Platform/IPC/Connection.h</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCmacConnectionMacmm">trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCmacMachMessagecpp">trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCmacMachMessageh">trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WTF/ChangeLog        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-12-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Defer sending Mach messages if the queue is full
+        https://bugs.webkit.org/show_bug.cgi?id=165622
+        rdar://problem/29518036
+
+        Reviewed by Brady Eidson.
+
+        Add new SPI.
+
+        * wtf/spi/darwin/XPCSPI.h:
+
</ins><span class="cx"> 2016-12-06  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Concurrent GC should be stable enough to land enabled on X86_64
</span></span></pre></div>
<a id="trunkSourceWTFwtfspidarwinXPCSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -23,8 +23,7 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef XPCSPI_h
-#define XPCSPI_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include &lt;dispatch/dispatch.h&gt;
</span><span class="cx"> #include &lt;os/object.h&gt;
</span><span class="lines">@@ -77,6 +76,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> #include &lt;xpc/private.h&gt;
</span><ins>+#else
+enum {
+    DISPATCH_MACH_SEND_POSSIBLE = 0x8,
+};
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> WTF_EXTERN_C_BEGIN
</span><span class="lines">@@ -157,5 +160,3 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> WTF_EXTERN_C_END
</span><del>-
-#endif // XPCSPI_h
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/ChangeLog        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2016-12-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Defer sending Mach messages if the queue is full
+        https://bugs.webkit.org/show_bug.cgi?id=165622
+        rdar://problem/29518036
+
+        Reviewed by Brady Eidson.
+
+        * Platform/IPC/Connection.cpp:
+        Include MachMessage.h so the Connection destructor can do its thing.
+
+        * Platform/IPC/Connection.h:
+        Add new members.
+
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::Connection::platformInvalidate):
+        Null out the pending outgoing mach message.
+
+        (IPC::Connection::sendMessage):
+        New helper that will send a Mach message. If we time out, store the message in m_pendingOutgoingMachMessage.
+        When our send source will be triggered we'll try to send the message again.
+
+        (IPC::Connection::platformCanSendOutgoingMessages):
+        We can only send messages if we don't have a pending outgoing message.
+
+        (IPC::Connection::sendOutgoingMessage):
+        Call the newly added sendMessage function.
+
+        (IPC::Connection::initializeSendSource):
+        Add the DISPATCH_MACH_SEND_POSSIBLE mask (and DISPATCH_MACH_SEND_DEAD which was previously implicit).
+        In our event handler, check for DISPATCH_MACH_SEND_POSSIBLE and try to send the pending outgoing message again.
+
+        * Platform/IPC/mac/MachMessage.cpp:
+        (IPC::MachMessage::create):
+        Rename length to size.
+
+        (IPC::MachMessage::MachMessage):
+        Initialize m_shouldFreeDescriptors.
+
+        (IPC::MachMessage::~MachMessage):
+        Call mach_msg_destroy, which will free the descriptors.
+
+        (IPC::MachMessage::leakDescriptors):
+        Set m_shouldFreeDescriptors to false.
+
+        * Platform/IPC/mac/MachMessage.h:
+        (IPC::MachMessage::size):
+        (IPC::MachMessage::length): Deleted.
+
</ins><span class="cx"> 2016-12-08  Chelsea Pugh  &lt;cpugh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] WKWebView should not allow app links to be opened on back or forward navigation
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -35,6 +35,10 @@
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> #include &lt;wtf/threads/BinarySemaphore.h&gt;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+#include &quot;MachMessage.h&quot;
+#endif
+
</ins><span class="cx"> namespace IPC {
</span><span class="cx"> 
</span><span class="cx"> struct Connection::ReplyHandler {
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.h        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx">     } \
</span><span class="cx"> while (0)
</span><span class="cx"> 
</span><ins>+class MachMessage;
+
</ins><span class="cx"> class Connection : public ThreadSafeRefCounted&lt;Connection&gt; {
</span><span class="cx"> public:
</span><span class="cx">     class Client : public MessageReceiver {
</span><span class="lines">@@ -239,7 +241,11 @@
</span><span class="cx">     void didReceiveSyncReply(OptionSet&lt;SendSyncOption&gt;);
</span><span class="cx"> 
</span><span class="cx">     Seconds timeoutRespectingIgnoreTimeoutsForTesting(Seconds) const;
</span><del>-    
</del><ins>+
+#if PLATFORM(COCOA)
+    bool sendMessage(std::unique_ptr&lt;MachMessage&gt;);
+#endif
+
</ins><span class="cx">     Client&amp; m_client;
</span><span class="cx">     bool m_isServer;
</span><span class="cx">     std::atomic&lt;bool&gt; m_isValid { true };
</span><span class="lines">@@ -320,6 +326,7 @@
</span><span class="cx">     mach_port_t m_receivePort;
</span><span class="cx">     dispatch_source_t m_receiveSource;
</span><span class="cx"> 
</span><ins>+    std::unique_ptr&lt;MachMessage&gt; m_pendingOutgoingMachMessage;
</ins><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &lt;= 101000
</span><span class="cx">     void exceptionSourceEventHandler();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacConnectionMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -126,6 +126,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    m_pendingOutgoingMachMessage = nullptr;
</ins><span class="cx">     m_isConnected = false;
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_sendPort);
</span><span class="lines">@@ -134,12 +135,12 @@
</span><span class="cx">     // Unregister our ports.
</span><span class="cx">     dispatch_source_cancel(m_sendSource);
</span><span class="cx">     dispatch_release(m_sendSource);
</span><del>-    m_sendSource = 0;
</del><ins>+    m_sendSource = nullptr;
</ins><span class="cx">     m_sendPort = MACH_PORT_NULL;
</span><span class="cx"> 
</span><span class="cx">     dispatch_source_cancel(m_receiveSource);
</span><span class="cx">     dispatch_release(m_receiveSource);
</span><del>-    m_receiveSource = 0;
</del><ins>+    m_receiveSource = nullptr;
</ins><span class="cx">     m_receivePort = MACH_PORT_NULL;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &lt;= 101000
</span><span class="lines">@@ -259,13 +260,41 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Connection::sendMessage(std::unique_ptr&lt;MachMessage&gt; message)
+{
+    ASSERT(!m_pendingOutgoingMachMessage);
+
+    // Send the message.
+    kern_return_t kr = mach_msg(message-&gt;header(), MACH_SEND_MSG | MACH_SEND_TIMEOUT | MACH_SEND_NOTIFY, message-&gt;size(), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+    switch (kr) {
+    case MACH_MSG_SUCCESS:
+        // The kernel has already adopted the descriptors.
+        message-&gt;leakDescriptors();
+        return true;
+
+    case MACH_SEND_TIMED_OUT:
+        // We timed out, stash away the message for later.
+        m_pendingOutgoingMachMessage = WTFMove(message);
+        return false;
+
+    case MACH_SEND_INVALID_DEST:
+        // The other end has disappeared, we'll get a dead name notification which will cause us to be invalidated.
+        return false;
+
+    default:
+        CRASH();
+    }
+}
+
</ins><span class="cx"> bool Connection::platformCanSendOutgoingMessages() const
</span><span class="cx"> {
</span><del>-    return true;
</del><ins>+    return !m_pendingOutgoingMachMessage;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Connection::sendOutgoingMessage(std::unique_ptr&lt;Encoder&gt; encoder)
</span><span class="cx"> {
</span><ins>+    ASSERT(!m_pendingOutgoingMachMessage);
+
</ins><span class="cx">     Vector&lt;Attachment&gt; attachments = encoder-&gt;releaseAttachments();
</span><span class="cx">     
</span><span class="cx">     size_t numberOfPortDescriptors = 0;
</span><span class="lines">@@ -347,22 +376,29 @@
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_sendPort);
</span><span class="cx"> 
</span><del>-    // Send the message.
-    kern_return_t kr = mach_msg(header, MACH_SEND_MSG, messageSize, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
-    if (kr != KERN_SUCCESS) {
-        // FIXME: What should we do here?
-    }
-
-    return true;
</del><ins>+    return sendMessage(WTFMove(message));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Connection::initializeSendSource()
</span><span class="cx"> {
</span><del>-    m_sendSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, 0, m_connectionQueue-&gt;dispatchQueue());
</del><ins>+    m_sendSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, DISPATCH_MACH_SEND_DEAD | DISPATCH_MACH_SEND_POSSIBLE, m_connectionQueue-&gt;dispatchQueue());
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Connection&gt; connection(this);
</span><span class="cx">     dispatch_source_set_event_handler(m_sendSource, [connection] {
</span><del>-        connection-&gt;connectionDidClose();
</del><ins>+        if (!connection-&gt;m_sendSource)
+            return;
+
+        unsigned long data = dispatch_source_get_data(connection-&gt;m_sendSource);
+
+        if (data &amp; DISPATCH_MACH_SEND_DEAD) {
+            connection-&gt;connectionDidClose();
+            return;
+        }
+
+        if (data &amp; DISPATCH_MACH_SEND_POSSIBLE) {
+            connection-&gt;sendMessage(WTFMove(connection-&gt;m_pendingOutgoingMachMessage));
+            return;
+        }
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     mach_port_t sendPort = m_sendPort;
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacMachMessagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.cpp (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.cpp        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.cpp        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -28,19 +28,22 @@
</span><span class="cx"> 
</span><span class="cx"> namespace IPC {
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;MachMessage&gt; MachMessage::create(size_t length)
</del><ins>+std::unique_ptr&lt;MachMessage&gt; MachMessage::create(size_t size)
</ins><span class="cx"> {
</span><del>-    void* memory = WTF::fastMalloc(sizeof(MachMessage) + length);
-    return std::unique_ptr&lt;MachMessage&gt; { new (NotNull, memory) MachMessage { length } };
</del><ins>+    void* memory = WTF::fastMalloc(sizeof(MachMessage) + size);
+    return std::unique_ptr&lt;MachMessage&gt; { new (NotNull, memory) MachMessage { size } };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-MachMessage::MachMessage(size_t length)
-    : m_length { length }
</del><ins>+MachMessage::MachMessage(size_t size)
+    : m_size { size }
+    , m_shouldFreeDescriptors { true }
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MachMessage::~MachMessage()
</span><span class="cx"> {
</span><ins>+    if (m_shouldFreeDescriptors)
+        ::mach_msg_destroy(header());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> size_t MachMessage::messageSize(size_t bodySize, size_t portDescriptorCount, size_t memoryDescriptorCount)
</span><span class="lines">@@ -64,4 +67,9 @@
</span><span class="cx">     return reinterpret_cast&lt;mach_msg_header_t*&gt;(m_buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MachMessage::leakDescriptors()
+{
+    m_shouldFreeDescriptors = false;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacMachMessageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.h (209574 => 209575)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.h        2016-12-08 22:52:37 UTC (rev 209574)
+++ trunk/Source/WebKit2/Platform/IPC/mac/MachMessage.h        2016-12-08 22:53:58 UTC (rev 209575)
</span><span class="lines">@@ -32,18 +32,21 @@
</span><span class="cx"> class MachMessage {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;MachMessage&gt; create(size_t length);
</del><ins>+    static std::unique_ptr&lt;MachMessage&gt; create(size_t);
</ins><span class="cx">     ~MachMessage();
</span><span class="cx"> 
</span><span class="cx">     static size_t messageSize(size_t bodySize, size_t portDescriptorCount, size_t memoryDescriptorCount);
</span><span class="cx"> 
</span><del>-    size_t length() const { return m_length; }
</del><ins>+    size_t size() const { return m_size; }
</ins><span class="cx">     mach_msg_header_t* header();
</span><span class="cx"> 
</span><ins>+    void leakDescriptors();
+
</ins><span class="cx"> private:
</span><del>-    MachMessage(size_t length);
</del><ins>+    explicit MachMessage(size_t);
</ins><span class="cx"> 
</span><del>-    size_t m_length;
</del><ins>+    size_t m_size;
+    bool m_shouldFreeDescriptors;
</ins><span class="cx">     uint8_t m_buffer[0];
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>