[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

kbalazs at webkit.org kbalazs at webkit.org
Fri Jan 21 14:54:33 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 2ddfac981e3a8fb33dc8eddaa6acb1dcc5564945
Author: kbalazs at webkit.org <kbalazs at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 4 14:01:47 2011 +0000

    2011-01-04  Balazs Kelemen  <kbalazs at webkit.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt][WK2] Incomplete clean up on termination
            https://bugs.webkit.org/show_bug.cgi?id=51474
    
            Do not kill the web process to force it's termination.
            Fix object destruction and cleanup logic and make the cleanup more reliable.
            Do not try to cleanup on crash because it is not reliable.
    
            * Platform/CoreIPC/qt/ConnectionQt.cpp:
            (CoreIPC::Connection::platformInvalidate): Do not delete the socket if we
            do not own it. This is the case with a server connection.
            * Platform/qt/MappedMemoryPool.cpp:
            Turn MappedMemoryPool into a QObject so the CleanupHandler can destruct it
            in the same way as the other objects.
            (WebKit::MappedMemoryPool::instance):
            (WebKit::MappedMemoryPool::~MappedMemoryPool):
            * Platform/qt/MappedMemoryPool.h:
            (WebKit::MappedMemoryPool::MappedMemoryPool):
            * Platform/qt/SharedMemoryQt.cpp:
            (WebKit::SharedMemory::create): No need to care about QCoreApplication::aboutToQuit.
            It is handled by the CleanupHandler.
            (WebKit::SharedMemory::~SharedMemory): Ditto.
            * Shared/qt/CleanupHandler.cpp: Renamed from WebKit2/Shared/qt/CrashHandler.cpp.
            No longer try to handle crash but just normal termination.
            (WebKit::CleanupHandler::CleanupHandler): Connect deleteObjects with QCoreApplication::aboutToQuit.
            Ensure appropriate thread affinity.
            (WebKit::CleanupHandler::sigTermHandler): Stop the main event loop.
            (WebKit::CleanupHandler::deleteObjects): Use deleteLater instead of delete since it is more reliable.
            * Shared/qt/CleanupHandler.h: Renamed from WebKit2/Shared/qt/CrashHandler.h.
            (WebKit::CleanupHandler::instance):
            (WebKit::CleanupHandler::markForCleanup):
            (WebKit::CleanupHandler::unmark):
            * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
            Do not kill the web process immidiately but give it a chance to cleanup.
            Use QLocalServer::removeServer for assuring that the socket file will be removed.
            (WebKit::ProcessLauncherHelper::serverName):
            (WebKit::cleanupAtExit): Renamed from cleanupProcesses. Only kill the web process when it times
            out terminating. Fixed the bug of changing the list while iterating it over by disconnecting
            from the processStateChanged slot.
            (WebKit::QtWebProcess::QtWebProcess): Added missing meta type registration of QProcess::ProcessState.
            (WebKit::ProcessLauncherHelper::~ProcessLauncherHelper):
            (WebKit::ProcessLauncherHelper::ProcessLauncherHelper): No need to add the the instance to the
            CleanupHandler because we will remove the socket file in cleanupAtExit.
            (WebKit::ProcessLauncherHelper::instance):
            (WebKit::ProcessLauncher::terminateProcess):
            * WebKit2.pro:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index ba7087a..03c5f3c 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,53 @@
+2011-01-04  Balazs Kelemen  <kbalazs at webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt][WK2] Incomplete clean up on termination
+        https://bugs.webkit.org/show_bug.cgi?id=51474
+
+        Do not kill the web process to force it's termination.
+        Fix object destruction and cleanup logic and make the cleanup more reliable.
+        Do not try to cleanup on crash because it is not reliable.
+
+        * Platform/CoreIPC/qt/ConnectionQt.cpp:
+        (CoreIPC::Connection::platformInvalidate): Do not delete the socket if we
+        do not own it. This is the case with a server connection.
+        * Platform/qt/MappedMemoryPool.cpp:
+        Turn MappedMemoryPool into a QObject so the CleanupHandler can destruct it
+        in the same way as the other objects.
+        (WebKit::MappedMemoryPool::instance):
+        (WebKit::MappedMemoryPool::~MappedMemoryPool):
+        * Platform/qt/MappedMemoryPool.h:
+        (WebKit::MappedMemoryPool::MappedMemoryPool):
+        * Platform/qt/SharedMemoryQt.cpp:
+        (WebKit::SharedMemory::create): No need to care about QCoreApplication::aboutToQuit.
+        It is handled by the CleanupHandler.
+        (WebKit::SharedMemory::~SharedMemory): Ditto.
+        * Shared/qt/CleanupHandler.cpp: Renamed from WebKit2/Shared/qt/CrashHandler.cpp.
+        No longer try to handle crash but just normal termination.
+        (WebKit::CleanupHandler::CleanupHandler): Connect deleteObjects with QCoreApplication::aboutToQuit.
+        Ensure appropriate thread affinity.
+        (WebKit::CleanupHandler::sigTermHandler): Stop the main event loop.
+        (WebKit::CleanupHandler::deleteObjects): Use deleteLater instead of delete since it is more reliable.
+        * Shared/qt/CleanupHandler.h: Renamed from WebKit2/Shared/qt/CrashHandler.h.
+        (WebKit::CleanupHandler::instance):
+        (WebKit::CleanupHandler::markForCleanup):
+        (WebKit::CleanupHandler::unmark):
+        * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
+        Do not kill the web process immidiately but give it a chance to cleanup.
+        Use QLocalServer::removeServer for assuring that the socket file will be removed.
+        (WebKit::ProcessLauncherHelper::serverName):
+        (WebKit::cleanupAtExit): Renamed from cleanupProcesses. Only kill the web process when it times
+        out terminating. Fixed the bug of changing the list while iterating it over by disconnecting
+        from the processStateChanged slot.
+        (WebKit::QtWebProcess::QtWebProcess): Added missing meta type registration of QProcess::ProcessState.
+        (WebKit::ProcessLauncherHelper::~ProcessLauncherHelper):
+        (WebKit::ProcessLauncherHelper::ProcessLauncherHelper): No need to add the the instance to the
+        CleanupHandler because we will remove the socket file in cleanupAtExit.
+        (WebKit::ProcessLauncherHelper::instance):
+        (WebKit::ProcessLauncher::terminateProcess):
+        * WebKit2.pro:
+
 2011-01-04  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp b/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp
index e3d965c..c0736b8 100644
--- a/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp
+++ b/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp
@@ -50,7 +50,9 @@ void Connection::platformInitialize(Identifier identifier)
 
 void Connection::platformInvalidate()
 {
-    delete m_socket;
+    m_socket->disconnect();
+    if (!m_isServer)
+        m_socket->deleteLater();
     m_socket = 0;
 }
 
diff --git a/WebKit2/Platform/qt/MappedMemoryPool.cpp b/WebKit2/Platform/qt/MappedMemoryPool.cpp
index 622f93a..d36d82b 100644
--- a/WebKit2/Platform/qt/MappedMemoryPool.cpp
+++ b/WebKit2/Platform/qt/MappedMemoryPool.cpp
@@ -27,6 +27,7 @@
 
 #include "MappedMemoryPool.h"
 
+#include "CleanupHandler.h"
 #include "StdLibExtras.h"
 #include <QDir>
 #include <QIODevice>
@@ -34,13 +35,24 @@
 
 namespace WebKit {
 
-MappedMemoryPool::~MappedMemoryPool()
+MappedMemoryPool* MappedMemoryPool::theInstance = 0;
+
+MappedMemoryPool* MappedMemoryPool::instance()
 {
-    clear();
+    if (!theInstance) {
+        theInstance = new MappedMemoryPool;
+
+        // Do not leave mapping files on the disk.
+        CleanupHandler::instance()->markForCleanup(theInstance);
+    }
+
+    return theInstance;
 }
 
-void MappedMemoryPool::clear()
+MappedMemoryPool::~MappedMemoryPool()
 {
+    CleanupHandler::instance()->unmark(theInstance);
+
     for (unsigned n = 0; n < m_pool.size(); ++n) {
         MappedMemory& current = m_pool.at(n);
         if (!current.file)
diff --git a/WebKit2/Platform/qt/MappedMemoryPool.h b/WebKit2/Platform/qt/MappedMemoryPool.h
index 4b3413b..8d6af8c 100644
--- a/WebKit2/Platform/qt/MappedMemoryPool.h
+++ b/WebKit2/Platform/qt/MappedMemoryPool.h
@@ -29,6 +29,7 @@
 #define MappedMemoryPool_h
 
 #include <QFile>
+#include <QObject>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
 
@@ -86,23 +87,20 @@ private:
     size_t dataSize;
 };
 
-class MappedMemoryPool {
+class MappedMemoryPool : QObject {
+    Q_OBJECT
 public:
-    static MappedMemoryPool* instance()
-    {
-        DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ());
-        return &singleton;
-    }
+    static MappedMemoryPool* instance();
 
     MappedMemory* mapMemory(size_t size);
     MappedMemory* mapFile(QString fileName, size_t size);
 
-    void clear();
-
 private:
-    MappedMemoryPool() { };
+    MappedMemoryPool() { }
     ~MappedMemoryPool();
 
+    static MappedMemoryPool* theInstance;
+
     Vector<MappedMemory> m_pool;
 };
 
diff --git a/WebKit2/Platform/qt/SharedMemoryQt.cpp b/WebKit2/Platform/qt/SharedMemoryQt.cpp
index e5341ec..08f5695 100644
--- a/WebKit2/Platform/qt/SharedMemoryQt.cpp
+++ b/WebKit2/Platform/qt/SharedMemoryQt.cpp
@@ -29,7 +29,7 @@
 
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
-#include "CrashHandler.h"
+#include "CleanupHandler.h"
 #include "WebCoreArgumentCoders.h"
 #include <unistd.h>
 #include <QCoreApplication>
@@ -99,10 +99,8 @@ PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
     sharedMemory->m_size = size;
     sharedMemory->m_data = impl->data();
 
-    impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()));
-
-    // Release the shared memory segment even on crash!
-    CrashHandler::instance()->markForDeletionOnCrash(impl);
+    // Do not leave the shared memory segment behind.
+    CleanupHandler::instance()->markForCleanup(impl);
 
     return sharedMemory.release();
 }
@@ -138,24 +136,16 @@ PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection p
     sharedMemory->m_size = handle.m_size;
     sharedMemory->m_data = impl->data();
 
-    impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()));
-
-    // Release the shared memory segment even on crash!
-    CrashHandler::instance()->markForDeletionOnCrash(impl);
+    // Do not leave the shared memory segment behind.
+    CleanupHandler::instance()->markForCleanup(impl);
 
     return sharedMemory.release();
 }
 
 SharedMemory::~SharedMemory()
 {
-    // Avoid double deletion when deleteLater has already been called through the signal-slot connection.
-    if (QCoreApplication::instance()->disconnect(m_impl)) {
-        // m_impl must be non-null and it must point to a valid QSharedMemory object.
-        ASSERT(qobject_cast<QSharedMemory*>(m_impl));
-        delete m_impl;
-    }
-
-    CrashHandler::instance()->didDelete(m_impl);
+    CleanupHandler::instance()->unmark(m_impl);
+    delete m_impl;
 }
 
 bool SharedMemory::createHandle(Handle& handle, Protection protection)
diff --git a/WebKit2/Shared/qt/CleanupHandler.cpp b/WebKit2/Shared/qt/CleanupHandler.cpp
new file mode 100644
index 0000000..c033cba
--- /dev/null
+++ b/WebKit2/Shared/qt/CleanupHandler.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 University of Szeged. 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 "CleanupHandler.h"
+
+#include "MappedMemoryPool.h"
+#include "RunLoop.h"
+#include <csignal>
+#include <cstdlib>
+#include <QApplication>
+
+namespace WebKit {
+
+CleanupHandler* CleanupHandler::theInstance = 0;
+
+CleanupHandler::CleanupHandler()
+    : m_inDeleteObjects(false)
+{
+    moveToThread(qApp->thread()); // Ensure that we are acting on the main thread.
+    connect(qApp, SIGNAL(aboutToQuit()), SLOT(deleteObjects()), Qt::DirectConnection);
+    signal(SIGTERM, &CleanupHandler::sigTermHandler);
+}
+
+void CleanupHandler::sigTermHandler(int)
+{
+    ::RunLoop::main()->stop();
+}
+
+void CleanupHandler::deleteObjects()
+{
+    m_inDeleteObjects = true;
+    for (unsigned i = 0; i < m_objects.size(); ++i)
+        m_objects[i]->deleteLater();
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/qt/CleanupHandler.h b/WebKit2/Shared/qt/CleanupHandler.h
new file mode 100644
index 0000000..ca94a5c
--- /dev/null
+++ b/WebKit2/Shared/qt/CleanupHandler.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 University of Szeged. 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 CleanupHandler_h
+#define CleanupHandler_h
+
+#include <QCoreApplication>
+#include <QList>
+#include <QObject>
+#include <wtf/HashSet.h>
+#include <wtf/StdLibExtras.h>
+
+namespace WebKit {
+
+class CleanupHandler : private QObject {
+    Q_OBJECT
+public:
+    static CleanupHandler* instance()
+    {
+        if (!theInstance)
+            theInstance = new CleanupHandler();
+        return theInstance;
+    }
+
+    void markForCleanup(QObject* object)
+    {
+        m_objects.append(object);
+    }
+
+    void unmark(QObject* object)
+    {
+        if (m_inDeleteObjects)
+            return;
+        m_objects.removeOne(object);
+    }
+
+private slots:
+    void deleteObjects();
+
+private:
+    static void sigTermHandler(int);
+    static CleanupHandler* theInstance;
+
+    CleanupHandler();
+
+    QList<QObject*> m_objects;
+    bool m_inDeleteObjects;
+};
+
+} // namespace WebKit
+
+#endif // CleanupHandler_h
diff --git a/WebKit2/Shared/qt/CrashHandler.cpp b/WebKit2/Shared/qt/CrashHandler.cpp
deleted file mode 100644
index 9eb7d3d..0000000
--- a/WebKit2/Shared/qt/CrashHandler.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 University of Szeged. 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 "CrashHandler.h"
-
-#include "MappedMemoryPool.h"
-#include <csignal>
-#include <cstdlib>
-#include <wtf/AlwaysInline.h>
-
-namespace WebKit {
-
-CrashHandler* CrashHandler::theInstance = 0;
-
-CrashHandler::CrashHandler()
-    : m_inDeleteObjects(false)
-{
-    signal(SIGABRT, &CrashHandler::signalHandler);
-    signal(SIGBUS, &CrashHandler::signalHandler);
-    signal(SIGILL, &CrashHandler::signalHandler);
-    signal(SIGINT, &CrashHandler::signalHandler);
-    signal(SIGFPE, &CrashHandler::signalHandler);
-    signal(SIGQUIT, &CrashHandler::signalHandler);
-    signal(SIGSEGV, &CrashHandler::signalHandler);
-    signal(SIGTRAP, &CrashHandler::signalHandler);
-}
-
-NO_RETURN void CrashHandler::signalHandler(int)
-{
-    CrashHandler::theInstance->deleteObjects();
-    exit(EXIT_FAILURE);
-}
-
-void CrashHandler::deleteObjects()
-{
-    m_inDeleteObjects = true;
-    qDeleteAll(m_objects);
-
-    MappedMemoryPool::instance()->clear();
-}
-
-} // namespace WebKit
diff --git a/WebKit2/Shared/qt/CrashHandler.h b/WebKit2/Shared/qt/CrashHandler.h
deleted file mode 100644
index 672f95c..0000000
--- a/WebKit2/Shared/qt/CrashHandler.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2010 University of Szeged. 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 CrashHandler_h
-#define CrashHandler_h
-
-#include <QList>
-#include <QObject>
-#include <wtf/HashSet.h>
-#include <wtf/StdLibExtras.h>
-
-namespace WebKit {
-
-class CrashHandler : private QObject {
-    Q_OBJECT
-public:
-    static CrashHandler* instance()
-    {
-        if (!theInstance)
-            theInstance = new CrashHandler();
-        return theInstance;
-    }
-
-    void markForDeletionOnCrash(QObject* object)
-    {
-        theInstance->m_objects.append(object);
-    }
-
-    void didDelete(QObject* object)
-    {
-        if (m_inDeleteObjects)
-            return;
-        theInstance->m_objects.removeOne(object);
-    }
-
-private:
-    static void signalHandler(int);
-    static CrashHandler* theInstance;
-
-    CrashHandler();
-
-    void deleteObjects();
-
-    QList<QObject*> m_objects;
-    bool m_inDeleteObjects;
-};
-
-} // namespace WebKit
-
-#endif // CrashHandler_h
diff --git a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
index 674d7e1..7dff894 100644
--- a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
+++ b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -27,9 +27,9 @@
 #include "ProcessLauncher.h"
 
 #include "Connection.h"
+#include "CleanupHandler.h"
 #include "NotImplemented.h"
 #include "RunLoop.h"
-#include "CrashHandler.h"
 #include "WebProcess.h"
 #include <runtime/InitializeThreading.h>
 #include <string>
@@ -42,7 +42,9 @@
 #include <QDebug>
 #include <QFile>
 #include <QLocalServer>
+#include <QMetaType>
 #include <QProcess>
+#include <QString>
 
 #include <QtCore/qglobal.h>
 
@@ -60,6 +62,9 @@ public:
     void launch(WebKit::ProcessLauncher*);
     QLocalSocket* takePendingConnection();
     static ProcessLauncherHelper* instance();
+
+    const QString serverName() const { return m_server.serverName(); }
+
 private:
     ProcessLauncherHelper();
     QLocalServer m_server;
@@ -70,13 +75,20 @@ private:
 
 Q_GLOBAL_STATIC(WTF::HashSet<QProcess*>, processes);
 
-static void cleanupProcesses()
+static void cleanupAtExit()
 {
-    WTF::HashSet<QProcess*>::const_iterator it = processes()->begin();
-    while (it != processes()->end()) {
-        (*it)->kill();
-        ++it;
+    // Terminate our web process(es).
+    WTF::HashSet<QProcess*>::const_iterator end = processes()->end();
+    for (WTF::HashSet<QProcess*>::const_iterator it = processes()->begin(); it != end; ++it) {
+        QProcess* process = *it;
+        process->disconnect(process);
+        process->terminate();
+        if (!process->waitForFinished(200))
+            process->kill();
     }
+
+    // Do not leave the socket file behind.
+    QLocalServer::removeServer(ProcessLauncherHelper::instance()->serverName());
 }
 
 class QtWebProcess : public QProcess
@@ -86,6 +98,12 @@ public:
     QtWebProcess(QObject* parent = 0)
         : QProcess(parent)
     {
+        static bool isRegistered = false;
+        if (!isRegistered) {
+            qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
+            isRegistered = true;
+        }
+
         connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
     }
 
@@ -141,7 +159,6 @@ QLocalSocket* ProcessLauncherHelper::takePendingConnection()
 ProcessLauncherHelper::~ProcessLauncherHelper()
 {
     m_server.close();
-    CrashHandler::instance()->didDelete(this);
 }
 
 ProcessLauncherHelper::ProcessLauncherHelper()
@@ -152,10 +169,6 @@ ProcessLauncherHelper::ProcessLauncherHelper()
         ASSERT_NOT_REACHED();
     }
     connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
-    connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()), Qt::QueuedConnection);
-
-    // Do not leave socket files on the disk even on crash!
-    CrashHandler::instance()->markForDeletionOnCrash(this);
 }
 
 ProcessLauncherHelper* ProcessLauncherHelper::instance()
@@ -167,7 +180,7 @@ ProcessLauncherHelper* ProcessLauncherHelper::instance()
         // The purpose of the following line is to ensure that our static is initialized before the exit handler is installed.
         processes()->clear();
 
-        atexit(cleanupProcesses);
+        atexit(cleanupAtExit);
     }
     return result;
 }
@@ -192,7 +205,7 @@ void ProcessLauncher::terminateProcess()
         return;
 
     QObject::connect(m_processIdentifier, SIGNAL(finished(int)), m_processIdentifier, SLOT(deleteLater()), Qt::QueuedConnection);
-    m_processIdentifier->kill();
+    m_processIdentifier->terminate();
 }
 
 QLocalSocket* ProcessLauncher::takePendingConnection()
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 64938d7..261ece7 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -277,7 +277,7 @@ HEADERS += \
     Shared/WebURLResponse.h \
     Shared/WebUserContentURLPattern.h \
     Shared/Plugins/Netscape/NetscapePluginModule.h \
-    Shared/qt/CrashHandler.h \
+    Shared/qt/CleanupHandler.h \
     Shared/qt/PlatformCertificateInfo.h \
     Shared/qt/UpdateChunk.h \
     Shared/qt/WebEventFactoryQt.h \
@@ -487,7 +487,7 @@ SOURCES += \
     Shared/WebURLResponse.cpp \
     Shared/WebWheelEvent.cpp \
     Shared/qt/BackingStoreQt.cpp \
-    Shared/qt/CrashHandler.cpp \
+    Shared/qt/CleanupHandler.cpp \
     Shared/qt/NativeWebKeyboardEventQt.cpp \
     Shared/qt/UpdateChunk.cpp \
     Shared/qt/WebCoreArgumentCodersQt.cpp \

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list