Title: [113414] trunk/Source/WebCore
- Revision
- 113414
- Author
- [email protected]
- Date
- 2012-04-05 22:16:05 -0700 (Thu, 05 Apr 2012)
Log Message
Leak in WebSocketChannel with workers/worker-reload.html
https://bugs.webkit.org/show_bug.cgi?id=83345
Reviewed by David Levin.
A speculative fix of memory leaks caused by worker-reload.html.
No new tests, as this change imposes no functional change.
* Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::mainThreadDestroy):
Receive the peer as PassOwnPtr<> so the destructor of the task object can
delete the peer even if the task didn't run before main thread's cleanup period.
(WebCore::WorkerThreadableWebSocketChannel::Bridge::disconnect):
* Modules/websockets/WorkerThreadableWebSocketChannel.h:
(WorkerThreadableWebSocketChannel):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (113413 => 113414)
--- trunk/Source/WebCore/ChangeLog 2012-04-06 04:57:45 UTC (rev 113413)
+++ trunk/Source/WebCore/ChangeLog 2012-04-06 05:16:05 UTC (rev 113414)
@@ -1,3 +1,22 @@
+2012-04-05 Yuta Kitamura <[email protected]>
+
+ Leak in WebSocketChannel with workers/worker-reload.html
+ https://bugs.webkit.org/show_bug.cgi?id=83345
+
+ Reviewed by David Levin.
+
+ A speculative fix of memory leaks caused by worker-reload.html.
+
+ No new tests, as this change imposes no functional change.
+
+ * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
+ (WebCore::WorkerThreadableWebSocketChannel::mainThreadDestroy):
+ Receive the peer as PassOwnPtr<> so the destructor of the task object can
+ delete the peer even if the task didn't run before main thread's cleanup period.
+ (WebCore::WorkerThreadableWebSocketChannel::Bridge::disconnect):
+ * Modules/websockets/WorkerThreadableWebSocketChannel.h:
+ (WorkerThreadableWebSocketChannel):
+
2012-04-05 Lu Guanqun <[email protected]>
combine two arrays (coreExceptionNames and coreExceptionDescriptions) into one array
Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp (113413 => 113414)
--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2012-04-06 04:57:45 UTC (rev 113413)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2012-04-06 05:16:05 UTC (rev 113414)
@@ -568,22 +568,23 @@
m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadFail, AllowCrossThreadAccess(m_peer), reason));
}
-void WorkerThreadableWebSocketChannel::mainThreadDestroy(ScriptExecutionContext* context, Peer* peer)
+void WorkerThreadableWebSocketChannel::mainThreadDestroy(ScriptExecutionContext* context, PassOwnPtr<Peer> peer)
{
ASSERT(isMainThread());
ASSERT_UNUSED(context, context->isDocument());
- ASSERT(peer);
+ ASSERT_UNUSED(peer, peer);
- delete peer;
+ // Peer object will be deleted even if the task does not run in the main thread's cleanup period, because
+ // the destructor for the task object (created by createCallbackTask()) will automatically delete the peer.
}
void WorkerThreadableWebSocketChannel::Bridge::disconnect()
{
clearClientWrapper();
if (m_peer) {
- Peer* peer = m_peer;
+ OwnPtr<Peer> peer = adoptPtr(m_peer);
m_peer = 0;
- m_loaderProxy.postTaskToLoader(createCallbackTask(&mainThreadDestroy, AllowCrossThreadAccess(peer)));
+ m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadDestroy, peer.release()));
}
m_workerContext = 0;
}
Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h (113413 => 113414)
--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h 2012-04-06 04:57:45 UTC (rev 113413)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h 2012-04-06 05:16:05 UTC (rev 113414)
@@ -177,7 +177,7 @@
static void mainThreadBufferedAmount(ScriptExecutionContext*, Peer*);
static void mainThreadClose(ScriptExecutionContext*, Peer*, int code, const String& reason);
static void mainThreadFail(ScriptExecutionContext*, Peer*, const String& reason);
- static void mainThreadDestroy(ScriptExecutionContext*, Peer*);
+ static void mainThreadDestroy(ScriptExecutionContext*, PassOwnPtr<Peer>);
static void mainThreadSuspend(ScriptExecutionContext*, Peer*);
static void mainThreadResume(ScriptExecutionContext*, Peer*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes