SocketStreamHandle should not be destroyed in a background thread
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 18:14:31 +0000 (18:14 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 18:14:31 +0000 (18:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198781

Reviewed by Geoffrey Garen.

Make sure to destroy SocketStreamHandle on the main thread since it owns an URL created on the main thread.
Covered by WPT websocket tests from https://bugs.webkit.org/show_bug.cgi?id=198774.

* platform/network/SocketStreamHandle.cpp:
(WebCore::SocketStreamHandle::SocketStreamHandle):
* platform/network/SocketStreamHandle.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246405 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/SocketStreamHandle.cpp
Source/WebCore/platform/network/SocketStreamHandle.h

index b27cc75..3edf461 100644 (file)
@@ -1,3 +1,17 @@
+2019-06-13  Youenn Fablet  <youenn@apple.com>
+
+        SocketStreamHandle should not be destroyed in a background thread
+        https://bugs.webkit.org/show_bug.cgi?id=198781
+
+        Reviewed by Geoffrey Garen.
+
+        Make sure to destroy SocketStreamHandle on the main thread since it owns an URL created on the main thread.
+        Covered by WPT websocket tests from https://bugs.webkit.org/show_bug.cgi?id=198774.
+
+        * platform/network/SocketStreamHandle.cpp:
+        (WebCore::SocketStreamHandle::SocketStreamHandle):
+        * platform/network/SocketStreamHandle.h:
+
 2019-06-13  Antoine Quint  <graouts@apple.com>
 
         "display: contents" Content click does not trigger
index 35bee36..dba0f13 100644 (file)
@@ -42,6 +42,7 @@ SocketStreamHandle::SocketStreamHandle(const URL& url, SocketStreamHandleClient&
     , m_client(client)
     , m_state(Connecting)
 {
+    ASSERT(isMainThread());
 }
 
 SocketStreamHandle::SocketStreamState SocketStreamHandle::state() const
index 1569bda..68b502a 100644 (file)
@@ -47,7 +47,7 @@ typedef struct {
 #endif
 } SourceApplicationAuditToken;
 
-class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle> {
+class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle, WTF::DestructionThread::Main> {
 public:
     enum SocketStreamState { Connecting, Open, Closing, Closed };
     virtual ~SocketStreamHandle() = default;