Changeset 74967 in webkit
- Timestamp:
- Jan 4, 2011 6:01:47 AM (13 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r74964 r74967 1 2011-01-04 Balazs Kelemen <kbalazs@webkit.org> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt][WK2] Incomplete clean up on termination 6 https://bugs.webkit.org/show_bug.cgi?id=51474 7 8 Do not kill the web process to force it's termination. 9 Fix object destruction and cleanup logic and make the cleanup more reliable. 10 Do not try to cleanup on crash because it is not reliable. 11 12 * Platform/CoreIPC/qt/ConnectionQt.cpp: 13 (CoreIPC::Connection::platformInvalidate): Do not delete the socket if we 14 do not own it. This is the case with a server connection. 15 * Platform/qt/MappedMemoryPool.cpp: 16 Turn MappedMemoryPool into a QObject so the CleanupHandler can destruct it 17 in the same way as the other objects. 18 (WebKit::MappedMemoryPool::instance): 19 (WebKit::MappedMemoryPool::~MappedMemoryPool): 20 * Platform/qt/MappedMemoryPool.h: 21 (WebKit::MappedMemoryPool::MappedMemoryPool): 22 * Platform/qt/SharedMemoryQt.cpp: 23 (WebKit::SharedMemory::create): No need to care about QCoreApplication::aboutToQuit. 24 It is handled by the CleanupHandler. 25 (WebKit::SharedMemory::~SharedMemory): Ditto. 26 * Shared/qt/CleanupHandler.cpp: Renamed from WebKit2/Shared/qt/CrashHandler.cpp. 27 No longer try to handle crash but just normal termination. 28 (WebKit::CleanupHandler::CleanupHandler): Connect deleteObjects with QCoreApplication::aboutToQuit. 29 Ensure appropriate thread affinity. 30 (WebKit::CleanupHandler::sigTermHandler): Stop the main event loop. 31 (WebKit::CleanupHandler::deleteObjects): Use deleteLater instead of delete since it is more reliable. 32 * Shared/qt/CleanupHandler.h: Renamed from WebKit2/Shared/qt/CrashHandler.h. 33 (WebKit::CleanupHandler::instance): 34 (WebKit::CleanupHandler::markForCleanup): 35 (WebKit::CleanupHandler::unmark): 36 * UIProcess/Launcher/qt/ProcessLauncherQt.cpp: 37 Do not kill the web process immidiately but give it a chance to cleanup. 38 Use QLocalServer::removeServer for assuring that the socket file will be removed. 39 (WebKit::ProcessLauncherHelper::serverName): 40 (WebKit::cleanupAtExit): Renamed from cleanupProcesses. Only kill the web process when it times 41 out terminating. Fixed the bug of changing the list while iterating it over by disconnecting 42 from the processStateChanged slot. 43 (WebKit::QtWebProcess::QtWebProcess): Added missing meta type registration of QProcess::ProcessState. 44 (WebKit::ProcessLauncherHelper::~ProcessLauncherHelper): 45 (WebKit::ProcessLauncherHelper::ProcessLauncherHelper): No need to add the the instance to the 46 CleanupHandler because we will remove the socket file in cleanupAtExit. 47 (WebKit::ProcessLauncherHelper::instance): 48 (WebKit::ProcessLauncher::terminateProcess): 49 * WebKit2.pro: 50 1 51 2011-01-04 Benjamin Poulain <benjamin.poulain@nokia.com> 2 52 -
trunk/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp
r74355 r74967 51 51 void Connection::platformInvalidate() 52 52 { 53 delete m_socket; 53 m_socket->disconnect(); 54 if (!m_isServer) 55 m_socket->deleteLater(); 54 56 m_socket = 0; 55 57 } -
trunk/WebKit2/Platform/qt/MappedMemoryPool.cpp
r71919 r74967 28 28 #include "MappedMemoryPool.h" 29 29 30 #include "CleanupHandler.h" 30 31 #include "StdLibExtras.h" 31 32 #include <QDir> … … 35 36 namespace WebKit { 36 37 38 MappedMemoryPool* MappedMemoryPool::theInstance = 0; 39 40 MappedMemoryPool* MappedMemoryPool::instance() 41 { 42 if (!theInstance) { 43 theInstance = new MappedMemoryPool; 44 45 // Do not leave mapping files on the disk. 46 CleanupHandler::instance()->markForCleanup(theInstance); 47 } 48 49 return theInstance; 50 } 51 37 52 MappedMemoryPool::~MappedMemoryPool() 38 53 { 39 clear(); 40 } 54 CleanupHandler::instance()->unmark(theInstance); 41 55 42 void MappedMemoryPool::clear()43 {44 56 for (unsigned n = 0; n < m_pool.size(); ++n) { 45 57 MappedMemory& current = m_pool.at(n); -
trunk/WebKit2/Platform/qt/MappedMemoryPool.h
r71729 r74967 30 30 31 31 #include <QFile> 32 #include <QObject> 32 33 #include <wtf/StdLibExtras.h> 33 34 #include <wtf/Vector.h> … … 87 88 }; 88 89 89 class MappedMemoryPool { 90 class MappedMemoryPool : QObject { 91 Q_OBJECT 90 92 public: 91 static MappedMemoryPool* instance() 92 { 93 DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ()); 94 return &singleton; 95 } 93 static MappedMemoryPool* instance(); 96 94 97 95 MappedMemory* mapMemory(size_t size); 98 96 MappedMemory* mapFile(QString fileName, size_t size); 99 97 100 void clear(); 98 private: 99 MappedMemoryPool() { } 100 ~MappedMemoryPool(); 101 101 102 private: 103 MappedMemoryPool() { }; 104 ~MappedMemoryPool(); 102 static MappedMemoryPool* theInstance; 105 103 106 104 Vector<MappedMemory> m_pool; -
trunk/WebKit2/Platform/qt/SharedMemoryQt.cpp
r71638 r74967 30 30 #include "ArgumentDecoder.h" 31 31 #include "ArgumentEncoder.h" 32 #include "C rashHandler.h"32 #include "CleanupHandler.h" 33 33 #include "WebCoreArgumentCoders.h" 34 34 #include <unistd.h> … … 100 100 sharedMemory->m_data = impl->data(); 101 101 102 impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater())); 103 104 // Release the shared memory segment even on crash! 105 CrashHandler::instance()->markForDeletionOnCrash(impl); 102 // Do not leave the shared memory segment behind. 103 CleanupHandler::instance()->markForCleanup(impl); 106 104 107 105 return sharedMemory.release(); … … 139 137 sharedMemory->m_data = impl->data(); 140 138 141 impl->connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater())); 142 143 // Release the shared memory segment even on crash! 144 CrashHandler::instance()->markForDeletionOnCrash(impl); 139 // Do not leave the shared memory segment behind. 140 CleanupHandler::instance()->markForCleanup(impl); 145 141 146 142 return sharedMemory.release(); … … 149 145 SharedMemory::~SharedMemory() 150 146 { 151 // Avoid double deletion when deleteLater has already been called through the signal-slot connection. 152 if (QCoreApplication::instance()->disconnect(m_impl)) { 153 // m_impl must be non-null and it must point to a valid QSharedMemory object. 154 ASSERT(qobject_cast<QSharedMemory*>(m_impl)); 155 delete m_impl; 156 } 157 158 CrashHandler::instance()->didDelete(m_impl); 147 CleanupHandler::instance()->unmark(m_impl); 148 delete m_impl; 159 149 } 160 150 -
trunk/WebKit2/Shared/qt/CleanupHandler.cpp
r74966 r74967 24 24 */ 25 25 26 #include "C rashHandler.h"26 #include "CleanupHandler.h" 27 27 28 28 #include "MappedMemoryPool.h" 29 #include "RunLoop.h" 29 30 #include <csignal> 30 31 #include <cstdlib> 31 #include < wtf/AlwaysInline.h>32 #include <QApplication> 32 33 33 34 namespace WebKit { 34 35 35 C rashHandler* CrashHandler::theInstance = 0;36 CleanupHandler* CleanupHandler::theInstance = 0; 36 37 37 C rashHandler::CrashHandler()38 CleanupHandler::CleanupHandler() 38 39 : m_inDeleteObjects(false) 39 40 { 40 signal(SIGABRT, &CrashHandler::signalHandler); 41 signal(SIGBUS, &CrashHandler::signalHandler); 42 signal(SIGILL, &CrashHandler::signalHandler); 43 signal(SIGINT, &CrashHandler::signalHandler); 44 signal(SIGFPE, &CrashHandler::signalHandler); 45 signal(SIGQUIT, &CrashHandler::signalHandler); 46 signal(SIGSEGV, &CrashHandler::signalHandler); 47 signal(SIGTRAP, &CrashHandler::signalHandler); 41 moveToThread(qApp->thread()); // Ensure that we are acting on the main thread. 42 connect(qApp, SIGNAL(aboutToQuit()), SLOT(deleteObjects()), Qt::DirectConnection); 43 signal(SIGTERM, &CleanupHandler::sigTermHandler); 48 44 } 49 45 50 NO_RETURN void CrashHandler::signalHandler(int)46 void CleanupHandler::sigTermHandler(int) 51 47 { 52 CrashHandler::theInstance->deleteObjects(); 53 exit(EXIT_FAILURE); 48 ::RunLoop::main()->stop(); 54 49 } 55 50 56 void C rashHandler::deleteObjects()51 void CleanupHandler::deleteObjects() 57 52 { 58 53 m_inDeleteObjects = true; 59 qDeleteAll(m_objects); 60 61 MappedMemoryPool::instance()->clear(); 54 for (unsigned i = 0; i < m_objects.size(); ++i) 55 m_objects[i]->deleteLater(); 62 56 } 63 57 -
trunk/WebKit2/Shared/qt/CleanupHandler.h
r74966 r74967 24 24 */ 25 25 26 #ifndef C rashHandler_h27 #define C rashHandler_h26 #ifndef CleanupHandler_h 27 #define CleanupHandler_h 28 28 29 #include <QCoreApplication> 29 30 #include <QList> 30 31 #include <QObject> … … 34 35 namespace WebKit { 35 36 36 class C rashHandler : private QObject {37 class CleanupHandler : private QObject { 37 38 Q_OBJECT 38 39 public: 39 static C rashHandler* instance()40 static CleanupHandler* instance() 40 41 { 41 42 if (!theInstance) 42 theInstance = new C rashHandler();43 theInstance = new CleanupHandler(); 43 44 return theInstance; 44 45 } 45 46 46 void markFor DeletionOnCrash(QObject* object)47 void markForCleanup(QObject* object) 47 48 { 48 theInstance->m_objects.append(object);49 m_objects.append(object); 49 50 } 50 51 51 void didDelete(QObject* object)52 void unmark(QObject* object) 52 53 { 53 54 if (m_inDeleteObjects) 54 55 return; 55 theInstance->m_objects.removeOne(object);56 m_objects.removeOne(object); 56 57 } 57 58 59 private slots: 60 void deleteObjects(); 61 58 62 private: 59 static void sig nalHandler(int);60 static C rashHandler* theInstance;63 static void sigTermHandler(int); 64 static CleanupHandler* theInstance; 61 65 62 CrashHandler(); 63 64 void deleteObjects(); 66 CleanupHandler(); 65 67 66 68 QList<QObject*> m_objects; … … 70 72 } // namespace WebKit 71 73 72 #endif // C rashHandler_h74 #endif // CleanupHandler_h -
trunk/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
r74108 r74967 28 28 29 29 #include "Connection.h" 30 #include "CleanupHandler.h" 30 31 #include "NotImplemented.h" 31 32 #include "RunLoop.h" 32 #include "CrashHandler.h"33 33 #include "WebProcess.h" 34 34 #include <runtime/InitializeThreading.h> … … 43 43 #include <QFile> 44 44 #include <QLocalServer> 45 #include <QMetaType> 45 46 #include <QProcess> 47 #include <QString> 46 48 47 49 #include <QtCore/qglobal.h> … … 61 63 QLocalSocket* takePendingConnection(); 62 64 static ProcessLauncherHelper* instance(); 65 66 const QString serverName() const { return m_server.serverName(); } 67 63 68 private: 64 69 ProcessLauncherHelper(); … … 71 76 Q_GLOBAL_STATIC(WTF::HashSet<QProcess*>, processes); 72 77 73 static void cleanupProcesses() 74 { 75 WTF::HashSet<QProcess*>::const_iterator it = processes()->begin(); 76 while (it != processes()->end()) { 77 (*it)->kill(); 78 ++it; 79 } 78 static void cleanupAtExit() 79 { 80 // Terminate our web process(es). 81 WTF::HashSet<QProcess*>::const_iterator end = processes()->end(); 82 for (WTF::HashSet<QProcess*>::const_iterator it = processes()->begin(); it != end; ++it) { 83 QProcess* process = *it; 84 process->disconnect(process); 85 process->terminate(); 86 if (!process->waitForFinished(200)) 87 process->kill(); 88 } 89 90 // Do not leave the socket file behind. 91 QLocalServer::removeServer(ProcessLauncherHelper::instance()->serverName()); 80 92 } 81 93 … … 87 99 : QProcess(parent) 88 100 { 101 static bool isRegistered = false; 102 if (!isRegistered) { 103 qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); 104 isRegistered = true; 105 } 106 89 107 connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState))); 90 108 } … … 142 160 { 143 161 m_server.close(); 144 CrashHandler::instance()->didDelete(this);145 162 } 146 163 … … 153 170 } 154 171 connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnection())); 155 connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(deleteLater()), Qt::QueuedConnection);156 157 // Do not leave socket files on the disk even on crash!158 CrashHandler::instance()->markForDeletionOnCrash(this);159 172 } 160 173 … … 168 181 processes()->clear(); 169 182 170 atexit(cleanup Processes);183 atexit(cleanupAtExit); 171 184 } 172 185 return result; … … 193 206 194 207 QObject::connect(m_processIdentifier, SIGNAL(finished(int)), m_processIdentifier, SLOT(deleteLater()), Qt::QueuedConnection); 195 m_processIdentifier-> kill();208 m_processIdentifier->terminate(); 196 209 } 197 210 -
trunk/WebKit2/WebKit2.pro
r74862 r74967 278 278 Shared/WebUserContentURLPattern.h \ 279 279 Shared/Plugins/Netscape/NetscapePluginModule.h \ 280 Shared/qt/C rashHandler.h \280 Shared/qt/CleanupHandler.h \ 281 281 Shared/qt/PlatformCertificateInfo.h \ 282 282 Shared/qt/UpdateChunk.h \ … … 488 488 Shared/WebWheelEvent.cpp \ 489 489 Shared/qt/BackingStoreQt.cpp \ 490 Shared/qt/C rashHandler.cpp \490 Shared/qt/CleanupHandler.cpp \ 491 491 Shared/qt/NativeWebKeyboardEventQt.cpp \ 492 492 Shared/qt/UpdateChunk.cpp \
Note: See TracChangeset
for help on using the changeset viewer.