WebRTC sockets should be closed at destruction time if not closed explicitly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 00:29:38 +0000 (00:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 00:29:38 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173479

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-16
Reviewed by Eric Carlson.

Source/WebKit2:

* WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
(WebKit::LibWebRTCSocket::~LibWebRTCSocket):
(WebKit::LibWebRTCSocket::Close):

LayoutTests:

* webrtc/datachannel/multiple-connections-expected.txt: Added.
* webrtc/datachannel/multiple-connections.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/webrtc/datachannel/multiple-connections-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/datachannel/multiple-connections.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Network/webrtc/LibWebRTCSocket.cpp

index 5bfa512..a8020c9 100644 (file)
@@ -1,5 +1,15 @@
 2017-06-16  Youenn Fablet  <youenn@apple.com>
 
+        WebRTC sockets should be closed at destruction time if not closed explicitly
+        https://bugs.webkit.org/show_bug.cgi?id=173479
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/datachannel/multiple-connections-expected.txt: Added.
+        * webrtc/datachannel/multiple-connections.html: Added.
+
+2017-06-16  Youenn Fablet  <youenn@apple.com>
+
         addTransceiver should trigger mid generation in the SDP
         https://bugs.webkit.org/show_bug.cgi?id=173452
 
diff --git a/LayoutTests/webrtc/datachannel/multiple-connections-expected.txt b/LayoutTests/webrtc/datachannel/multiple-connections-expected.txt
new file mode 100644 (file)
index 0000000..c54b94c
--- /dev/null
@@ -0,0 +1,258 @@
+
+PASS Basic data channel exchange from offerer to receiver 0 
+PASS Basic data channel exchange from offerer to receiver 1 
+PASS Basic data channel exchange from offerer to receiver 2 
+PASS Basic data channel exchange from offerer to receiver 3 
+PASS Basic data channel exchange from offerer to receiver 4 
+PASS Basic data channel exchange from offerer to receiver 5 
+PASS Basic data channel exchange from offerer to receiver 6 
+PASS Basic data channel exchange from offerer to receiver 7 
+PASS Basic data channel exchange from offerer to receiver 8 
+PASS Basic data channel exchange from offerer to receiver 9 
+PASS Basic data channel exchange from offerer to receiver 10 
+PASS Basic data channel exchange from offerer to receiver 11 
+PASS Basic data channel exchange from offerer to receiver 12 
+PASS Basic data channel exchange from offerer to receiver 13 
+PASS Basic data channel exchange from offerer to receiver 14 
+PASS Basic data channel exchange from offerer to receiver 15 
+PASS Basic data channel exchange from offerer to receiver 16 
+PASS Basic data channel exchange from offerer to receiver 17 
+PASS Basic data channel exchange from offerer to receiver 18 
+PASS Basic data channel exchange from offerer to receiver 19 
+PASS Basic data channel exchange from offerer to receiver 20 
+PASS Basic data channel exchange from offerer to receiver 21 
+PASS Basic data channel exchange from offerer to receiver 22 
+PASS Basic data channel exchange from offerer to receiver 23 
+PASS Basic data channel exchange from offerer to receiver 24 
+PASS Basic data channel exchange from offerer to receiver 25 
+PASS Basic data channel exchange from offerer to receiver 26 
+PASS Basic data channel exchange from offerer to receiver 27 
+PASS Basic data channel exchange from offerer to receiver 28 
+PASS Basic data channel exchange from offerer to receiver 29 
+PASS Basic data channel exchange from offerer to receiver 30 
+PASS Basic data channel exchange from offerer to receiver 31 
+PASS Basic data channel exchange from offerer to receiver 32 
+PASS Basic data channel exchange from offerer to receiver 33 
+PASS Basic data channel exchange from offerer to receiver 34 
+PASS Basic data channel exchange from offerer to receiver 35 
+PASS Basic data channel exchange from offerer to receiver 36 
+PASS Basic data channel exchange from offerer to receiver 37 
+PASS Basic data channel exchange from offerer to receiver 38 
+PASS Basic data channel exchange from offerer to receiver 39 
+PASS Basic data channel exchange from offerer to receiver 40 
+PASS Basic data channel exchange from offerer to receiver 41 
+PASS Basic data channel exchange from offerer to receiver 42 
+PASS Basic data channel exchange from offerer to receiver 43 
+PASS Basic data channel exchange from offerer to receiver 44 
+PASS Basic data channel exchange from offerer to receiver 45 
+PASS Basic data channel exchange from offerer to receiver 46 
+PASS Basic data channel exchange from offerer to receiver 47 
+PASS Basic data channel exchange from offerer to receiver 48 
+PASS Basic data channel exchange from offerer to receiver 49 
+PASS Basic data channel exchange from offerer to receiver 50 
+PASS Basic data channel exchange from offerer to receiver 51 
+PASS Basic data channel exchange from offerer to receiver 52 
+PASS Basic data channel exchange from offerer to receiver 53 
+PASS Basic data channel exchange from offerer to receiver 54 
+PASS Basic data channel exchange from offerer to receiver 55 
+PASS Basic data channel exchange from offerer to receiver 56 
+PASS Basic data channel exchange from offerer to receiver 57 
+PASS Basic data channel exchange from offerer to receiver 58 
+PASS Basic data channel exchange from offerer to receiver 59 
+PASS Basic data channel exchange from offerer to receiver 60 
+PASS Basic data channel exchange from offerer to receiver 61 
+PASS Basic data channel exchange from offerer to receiver 62 
+PASS Basic data channel exchange from offerer to receiver 63 
+PASS Basic data channel exchange from offerer to receiver 64 
+PASS Basic data channel exchange from offerer to receiver 65 
+PASS Basic data channel exchange from offerer to receiver 66 
+PASS Basic data channel exchange from offerer to receiver 67 
+PASS Basic data channel exchange from offerer to receiver 68 
+PASS Basic data channel exchange from offerer to receiver 69 
+PASS Basic data channel exchange from offerer to receiver 70 
+PASS Basic data channel exchange from offerer to receiver 71 
+PASS Basic data channel exchange from offerer to receiver 72 
+PASS Basic data channel exchange from offerer to receiver 73 
+PASS Basic data channel exchange from offerer to receiver 74 
+PASS Basic data channel exchange from offerer to receiver 75 
+PASS Basic data channel exchange from offerer to receiver 76 
+PASS Basic data channel exchange from offerer to receiver 77 
+PASS Basic data channel exchange from offerer to receiver 78 
+PASS Basic data channel exchange from offerer to receiver 79 
+PASS Basic data channel exchange from offerer to receiver 80 
+PASS Basic data channel exchange from offerer to receiver 81 
+PASS Basic data channel exchange from offerer to receiver 82 
+PASS Basic data channel exchange from offerer to receiver 83 
+PASS Basic data channel exchange from offerer to receiver 84 
+PASS Basic data channel exchange from offerer to receiver 85 
+PASS Basic data channel exchange from offerer to receiver 86 
+PASS Basic data channel exchange from offerer to receiver 87 
+PASS Basic data channel exchange from offerer to receiver 88 
+PASS Basic data channel exchange from offerer to receiver 89 
+PASS Basic data channel exchange from offerer to receiver 90 
+PASS Basic data channel exchange from offerer to receiver 91 
+PASS Basic data channel exchange from offerer to receiver 92 
+PASS Basic data channel exchange from offerer to receiver 93 
+PASS Basic data channel exchange from offerer to receiver 94 
+PASS Basic data channel exchange from offerer to receiver 95 
+PASS Basic data channel exchange from offerer to receiver 96 
+PASS Basic data channel exchange from offerer to receiver 97 
+PASS Basic data channel exchange from offerer to receiver 98 
+PASS Basic data channel exchange from offerer to receiver 99 
+PASS Basic data channel exchange from offerer to receiver 100 
+PASS Basic data channel exchange from offerer to receiver 101 
+PASS Basic data channel exchange from offerer to receiver 102 
+PASS Basic data channel exchange from offerer to receiver 103 
+PASS Basic data channel exchange from offerer to receiver 104 
+PASS Basic data channel exchange from offerer to receiver 105 
+PASS Basic data channel exchange from offerer to receiver 106 
+PASS Basic data channel exchange from offerer to receiver 107 
+PASS Basic data channel exchange from offerer to receiver 108 
+PASS Basic data channel exchange from offerer to receiver 109 
+PASS Basic data channel exchange from offerer to receiver 110 
+PASS Basic data channel exchange from offerer to receiver 111 
+PASS Basic data channel exchange from offerer to receiver 112 
+PASS Basic data channel exchange from offerer to receiver 113 
+PASS Basic data channel exchange from offerer to receiver 114 
+PASS Basic data channel exchange from offerer to receiver 115 
+PASS Basic data channel exchange from offerer to receiver 116 
+PASS Basic data channel exchange from offerer to receiver 117 
+PASS Basic data channel exchange from offerer to receiver 118 
+PASS Basic data channel exchange from offerer to receiver 119 
+PASS Basic data channel exchange from offerer to receiver 120 
+PASS Basic data channel exchange from offerer to receiver 121 
+PASS Basic data channel exchange from offerer to receiver 122 
+PASS Basic data channel exchange from offerer to receiver 123 
+PASS Basic data channel exchange from offerer to receiver 124 
+PASS Basic data channel exchange from offerer to receiver 125 
+PASS Basic data channel exchange from offerer to receiver 126 
+PASS Basic data channel exchange from offerer to receiver 127 
+PASS Basic data channel exchange from offerer to receiver 128 
+PASS Basic data channel exchange from offerer to receiver 129 
+PASS Basic data channel exchange from offerer to receiver 130 
+PASS Basic data channel exchange from offerer to receiver 131 
+PASS Basic data channel exchange from offerer to receiver 132 
+PASS Basic data channel exchange from offerer to receiver 133 
+PASS Basic data channel exchange from offerer to receiver 134 
+PASS Basic data channel exchange from offerer to receiver 135 
+PASS Basic data channel exchange from offerer to receiver 136 
+PASS Basic data channel exchange from offerer to receiver 137 
+PASS Basic data channel exchange from offerer to receiver 138 
+PASS Basic data channel exchange from offerer to receiver 139 
+PASS Basic data channel exchange from offerer to receiver 140 
+PASS Basic data channel exchange from offerer to receiver 141 
+PASS Basic data channel exchange from offerer to receiver 142 
+PASS Basic data channel exchange from offerer to receiver 143 
+PASS Basic data channel exchange from offerer to receiver 144 
+PASS Basic data channel exchange from offerer to receiver 145 
+PASS Basic data channel exchange from offerer to receiver 146 
+PASS Basic data channel exchange from offerer to receiver 147 
+PASS Basic data channel exchange from offerer to receiver 148 
+PASS Basic data channel exchange from offerer to receiver 149 
+PASS Basic data channel exchange from offerer to receiver 150 
+PASS Basic data channel exchange from offerer to receiver 151 
+PASS Basic data channel exchange from offerer to receiver 152 
+PASS Basic data channel exchange from offerer to receiver 153 
+PASS Basic data channel exchange from offerer to receiver 154 
+PASS Basic data channel exchange from offerer to receiver 155 
+PASS Basic data channel exchange from offerer to receiver 156 
+PASS Basic data channel exchange from offerer to receiver 157 
+PASS Basic data channel exchange from offerer to receiver 158 
+PASS Basic data channel exchange from offerer to receiver 159 
+PASS Basic data channel exchange from offerer to receiver 160 
+PASS Basic data channel exchange from offerer to receiver 161 
+PASS Basic data channel exchange from offerer to receiver 162 
+PASS Basic data channel exchange from offerer to receiver 163 
+PASS Basic data channel exchange from offerer to receiver 164 
+PASS Basic data channel exchange from offerer to receiver 165 
+PASS Basic data channel exchange from offerer to receiver 166 
+PASS Basic data channel exchange from offerer to receiver 167 
+PASS Basic data channel exchange from offerer to receiver 168 
+PASS Basic data channel exchange from offerer to receiver 169 
+PASS Basic data channel exchange from offerer to receiver 170 
+PASS Basic data channel exchange from offerer to receiver 171 
+PASS Basic data channel exchange from offerer to receiver 172 
+PASS Basic data channel exchange from offerer to receiver 173 
+PASS Basic data channel exchange from offerer to receiver 174 
+PASS Basic data channel exchange from offerer to receiver 175 
+PASS Basic data channel exchange from offerer to receiver 176 
+PASS Basic data channel exchange from offerer to receiver 177 
+PASS Basic data channel exchange from offerer to receiver 178 
+PASS Basic data channel exchange from offerer to receiver 179 
+PASS Basic data channel exchange from offerer to receiver 180 
+PASS Basic data channel exchange from offerer to receiver 181 
+PASS Basic data channel exchange from offerer to receiver 182 
+PASS Basic data channel exchange from offerer to receiver 183 
+PASS Basic data channel exchange from offerer to receiver 184 
+PASS Basic data channel exchange from offerer to receiver 185 
+PASS Basic data channel exchange from offerer to receiver 186 
+PASS Basic data channel exchange from offerer to receiver 187 
+PASS Basic data channel exchange from offerer to receiver 188 
+PASS Basic data channel exchange from offerer to receiver 189 
+PASS Basic data channel exchange from offerer to receiver 190 
+PASS Basic data channel exchange from offerer to receiver 191 
+PASS Basic data channel exchange from offerer to receiver 192 
+PASS Basic data channel exchange from offerer to receiver 193 
+PASS Basic data channel exchange from offerer to receiver 194 
+PASS Basic data channel exchange from offerer to receiver 195 
+PASS Basic data channel exchange from offerer to receiver 196 
+PASS Basic data channel exchange from offerer to receiver 197 
+PASS Basic data channel exchange from offerer to receiver 198 
+PASS Basic data channel exchange from offerer to receiver 199 
+PASS Basic data channel exchange from offerer to receiver 200 
+PASS Basic data channel exchange from offerer to receiver 201 
+PASS Basic data channel exchange from offerer to receiver 202 
+PASS Basic data channel exchange from offerer to receiver 203 
+PASS Basic data channel exchange from offerer to receiver 204 
+PASS Basic data channel exchange from offerer to receiver 205 
+PASS Basic data channel exchange from offerer to receiver 206 
+PASS Basic data channel exchange from offerer to receiver 207 
+PASS Basic data channel exchange from offerer to receiver 208 
+PASS Basic data channel exchange from offerer to receiver 209 
+PASS Basic data channel exchange from offerer to receiver 210 
+PASS Basic data channel exchange from offerer to receiver 211 
+PASS Basic data channel exchange from offerer to receiver 212 
+PASS Basic data channel exchange from offerer to receiver 213 
+PASS Basic data channel exchange from offerer to receiver 214 
+PASS Basic data channel exchange from offerer to receiver 215 
+PASS Basic data channel exchange from offerer to receiver 216 
+PASS Basic data channel exchange from offerer to receiver 217 
+PASS Basic data channel exchange from offerer to receiver 218 
+PASS Basic data channel exchange from offerer to receiver 219 
+PASS Basic data channel exchange from offerer to receiver 220 
+PASS Basic data channel exchange from offerer to receiver 221 
+PASS Basic data channel exchange from offerer to receiver 222 
+PASS Basic data channel exchange from offerer to receiver 223 
+PASS Basic data channel exchange from offerer to receiver 224 
+PASS Basic data channel exchange from offerer to receiver 225 
+PASS Basic data channel exchange from offerer to receiver 226 
+PASS Basic data channel exchange from offerer to receiver 227 
+PASS Basic data channel exchange from offerer to receiver 228 
+PASS Basic data channel exchange from offerer to receiver 229 
+PASS Basic data channel exchange from offerer to receiver 230 
+PASS Basic data channel exchange from offerer to receiver 231 
+PASS Basic data channel exchange from offerer to receiver 232 
+PASS Basic data channel exchange from offerer to receiver 233 
+PASS Basic data channel exchange from offerer to receiver 234 
+PASS Basic data channel exchange from offerer to receiver 235 
+PASS Basic data channel exchange from offerer to receiver 236 
+PASS Basic data channel exchange from offerer to receiver 237 
+PASS Basic data channel exchange from offerer to receiver 238 
+PASS Basic data channel exchange from offerer to receiver 239 
+PASS Basic data channel exchange from offerer to receiver 240 
+PASS Basic data channel exchange from offerer to receiver 241 
+PASS Basic data channel exchange from offerer to receiver 242 
+PASS Basic data channel exchange from offerer to receiver 243 
+PASS Basic data channel exchange from offerer to receiver 244 
+PASS Basic data channel exchange from offerer to receiver 245 
+PASS Basic data channel exchange from offerer to receiver 246 
+PASS Basic data channel exchange from offerer to receiver 247 
+PASS Basic data channel exchange from offerer to receiver 248 
+PASS Basic data channel exchange from offerer to receiver 249 
+PASS Basic data channel exchange from offerer to receiver 250 
+PASS Basic data channel exchange from offerer to receiver 251 
+PASS Basic data channel exchange from offerer to receiver 252 
+PASS Basic data channel exchange from offerer to receiver 253 
+PASS Basic data channel exchange from offerer to receiver 254 
+PASS Basic data channel exchange from offerer to receiver 255 
+
diff --git a/LayoutTests/webrtc/datachannel/multiple-connections.html b/LayoutTests/webrtc/datachannel/multiple-connections.html
new file mode 100644 (file)
index 0000000..7c6ea2d
--- /dev/null
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Testing a lot of data channel connections on the same web process</title>
+    <script src="../../resources/testharness.js"></script>
+    <script src="../../resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script src ="../routines.js"></script>
+    <script>
+for (var cptr = 0;cptr < 256; cptr++) {
+  promise_test((test) => {
+    var localChannel;
+    var remoteChannel;
+
+    return new Promise((resolve, reject) => {
+        createConnections((localConnection) => {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () => {
+                localChannel.send("one");
+            }
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = () => { resolve(); }
+            };
+        });
+        setTimeout(() => { reject("Test timed out"); }, 1000);
+    }).then(() => {
+      localChannel.close();
+      remoteChannel.close();
+      closeConnections();
+    });
+  }, "Basic data channel exchange from offerer to receiver " + cptr);
+}
+    </script>
+  </body>
+</html>
index a035435..0b3c4c2 100644 (file)
@@ -1,3 +1,14 @@
+2017-06-16  Youenn Fablet  <youenn@apple.com>
+
+        WebRTC sockets should be closed at destruction time if not closed explicitly
+        https://bugs.webkit.org/show_bug.cgi?id=173479
+
+        Reviewed by Eric Carlson.
+
+        * WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
+        (WebKit::LibWebRTCSocket::~LibWebRTCSocket):
+        (WebKit::LibWebRTCSocket::Close):
+
 2017-06-16  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Add WKProcessPool SPI to efficiently reset all plugin load client policies
index 7713035..1a4c779 100644 (file)
@@ -58,6 +58,7 @@ LibWebRTCSocket::LibWebRTCSocket(LibWebRTCSocketFactory& factory, uint64_t ident
 
 LibWebRTCSocket::~LibWebRTCSocket()
 {
+    Close();
     m_factory.detach(*this);
 }
 
@@ -151,6 +152,10 @@ int LibWebRTCSocket::SendTo(const void *value, size_t size, const rtc::SocketAdd
 
 int LibWebRTCSocket::Close()
 {
+    if (m_state == STATE_CLOSED)
+        return 0;
+
+    m_state = STATE_CLOSED;
     auto identifier = this->identifier();
     sendOnMainThread([identifier](IPC::Connection& connection) {
         connection.send(Messages::NetworkRTCSocket::Close(), identifier);