Title: [168585] trunk/Source/WebKit2
Revision
168585
Author
[email protected]
Date
2014-05-10 15:41:17 -0700 (Sat, 10 May 2014)

Log Message

Use xpc_connection_kill for killing child processes where appropriate
https://bugs.webkit.org/show_bug.cgi?id=132788
<rdar://problem/16664185>

Reviewed by Sam Weinig.

* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::kill):
* Platform/IPC/mac/XPCPtr.h:
(IPC::XPCPtr::operator bool):
* Shared/ChildProcessProxy.cpp:
(WebKit::ChildProcessProxy::terminate):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (168584 => 168585)


--- trunk/Source/WebKit2/ChangeLog	2014-05-10 22:17:24 UTC (rev 168584)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-10 22:41:17 UTC (rev 168585)
@@ -1,5 +1,21 @@
 2014-05-10  Anders Carlsson  <[email protected]>
 
+        Use xpc_connection_kill for killing child processes where appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=132788
+        <rdar://problem/16664185>
+
+        Reviewed by Sam Weinig.
+
+        * Platform/IPC/Connection.h:
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::Connection::kill):
+        * Platform/IPC/mac/XPCPtr.h:
+        (IPC::XPCPtr::operator bool):
+        * Shared/ChildProcessProxy.cpp:
+        (WebKit::ChildProcessProxy::terminate):
+
+2014-05-10  Anders Carlsson  <[email protected]>
+
         WebKit2 is leaking an xpc_connection per web process it creates
         https://bugs.webkit.org/show_bug.cgi?id=132785
         <rdar://problem/14912160>

Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (168584 => 168585)


--- trunk/Source/WebKit2/Platform/IPC/Connection.h	2014-05-10 22:17:24 UTC (rev 168584)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h	2014-05-10 22:41:17 UTC (rev 168585)
@@ -172,7 +172,9 @@
     bool inSendSync() const { return m_inSendSyncCount; }
 
     Identifier identifier() const;
-    
+
+    bool kill();
+
 private:
     Connection(Identifier, bool isServer, Client*, WTF::RunLoop& clientRunLoop);
     void platformInitialize(Identifier);

Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (168584 => 168585)


--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm	2014-05-10 22:17:24 UTC (rev 168584)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm	2014-05-10 22:41:17 UTC (rev 168585)
@@ -37,9 +37,11 @@
 
 #if __has_include(<xpc/private.h>)
 #include <xpc/private.h>
+#else
+extern "C" void xpc_connection_get_audit_token(xpc_connection_t, audit_token_t*);
+extern "C" void xpc_connection_kill(xpc_connection_t, int);
 #endif
 
-extern "C" void xpc_connection_get_audit_token(xpc_connection_t, audit_token_t*);
 
 namespace IPC {
 
@@ -522,5 +524,17 @@
     xpc_connection_get_audit_token(m_xpcConnection.get(), &auditToken);
     return true;
 }
-    
+
+bool Connection::kill()
+{
+#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+    if (m_xpcConnection) {
+        xpc_connection_kill(m_xpcConnection.get(), SIGKILL);
+        return true;
+    }
+#endif
+
+    return false;
+}
+
 } // namespace IPC

Modified: trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h (168584 => 168585)


--- trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h	2014-05-10 22:17:24 UTC (rev 168584)
+++ trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h	2014-05-10 22:41:17 UTC (rev 168585)
@@ -52,6 +52,7 @@
 
     T get() const { return m_ptr; }
 
+    explicit operator bool() const { return m_ptr; }
     bool operator!() const { return !m_ptr; }
 
     XPCPtr(const XPCPtr& other)

Modified: trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp (168584 => 168585)


--- trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp	2014-05-10 22:17:24 UTC (rev 168584)
+++ trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp	2014-05-10 22:41:17 UTC (rev 168585)
@@ -65,6 +65,10 @@
 
 void ChildProcessProxy::terminate()
 {
+    if (m_connection && m_connection->kill())
+        return;
+
+    // FIXME: We should really merge process launching into IPC connection creation and get rid of the process launcher.
     if (m_processLauncher)
         m_processLauncher->terminateProcess();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to