Bug 160889 - Clean up WebSockets
Summary: Clean up WebSockets
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-15 20:06 PDT by Alex Christensen
Modified: 2016-08-16 11:13 PDT (History)
3 users (show)

See Also:


Attachments
Patch (12.95 KB, patch)
2016-08-15 20:11 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (16.58 KB, patch)
2016-08-15 20:20 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (19.30 KB, patch)
2016-08-15 20:26 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (19.75 KB, patch)
2016-08-15 20:32 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (19.93 KB, patch)
2016-08-15 20:43 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (20.07 KB, patch)
2016-08-15 21:03 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (22.78 KB, patch)
2016-08-16 00:14 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-yosemite (933.43 KB, application/zip)
2016-08-16 01:04 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-yosemite-wk2 (1.00 MB, application/zip)
2016-08-16 01:07 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews116 for mac-yosemite (1.55 MB, application/zip)
2016-08-16 01:16 PDT, Build Bot
no flags Details
Patch (23.87 KB, patch)
2016-08-16 09:37 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-08-15 20:06:03 PDT
Clean up WebSockets
Comment 1 Alex Christensen 2016-08-15 20:11:04 PDT
Created attachment 286140 [details]
Patch
Comment 2 Alex Christensen 2016-08-15 20:20:36 PDT
Created attachment 286141 [details]
Patch
Comment 3 Alex Christensen 2016-08-15 20:26:31 PDT
Created attachment 286142 [details]
Patch
Comment 4 Alex Christensen 2016-08-15 20:32:46 PDT
Created attachment 286143 [details]
Patch
Comment 5 Alex Christensen 2016-08-15 20:43:21 PDT
Created attachment 286145 [details]
Patch
Comment 6 Alex Christensen 2016-08-15 21:03:10 PDT
Created attachment 286146 [details]
Patch
Comment 7 Darin Adler 2016-08-15 22:53:21 PDT
Comment on attachment 286146 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=286146&action=review

Looks OK, but could be improved more. Seems that it introduces some small amount of new sloppiness.

> Source/WebCore/Modules/websockets/WebSocketChannel.cpp:313
> +    LOG(Network, "WebSocketChannel %p didReceiveSocketStreamData() Received %zu bytes", this, len);

This is going to look crazy when len is std::numeric_limits<size_t>::max().

> Source/WebCore/Modules/websockets/WebSocketChannel.cpp:319
> +    if (len == std::numeric_limits<size_t>::max()) {

Why do we need this magic value here? Isn’t there a cleaner way to do this, like using a separate function for the "need to disconnect" case. Or using Optional to indicate there is no length? Or could we at least make this magic value a named constant?

I don’t see the patch changing the call site, so I am concerned that this might not even be the correct value.

> Source/WebCore/platform/network/SocketStreamHandle.cpp:69
> -    if (bytesWritten < 0)
> +    if (bytesWritten == sendError)
>          return false;

This should be nested inside the if statement above.

> Source/WebCore/platform/network/SocketStreamHandle.h:58
> +    const size_t sendError = std::numeric_limits<size_t>::max();
> +    virtual size_t platformSend(const char* data, size_t length) = 0;

Why use a magic value to indicate a send error? To indicate an error we could use Optional or some other technique without a magic number.

> Source/WebCore/platform/network/soup/SocketStreamHandleImplSoup.cpp:192
> +    return static_cast<size_t>(written);

This relies on casting a -1 to size_t yielding std::numeric_limits<size_t>::max(), something I believe the patch avoids in the CFNetwork version.

> Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.h:74
> +    void didOpenSocketStream(WebCore::SocketStreamHandle&) override { }
>      void didCloseSocketStream(WebCore::SocketStreamHandle&) override;
> -    void didReceiveSocketStreamData(WebCore::SocketStreamHandle&, const char* data, int length) override;
> +    void didReceiveSocketStreamData(WebCore::SocketStreamHandle&, const char* data, size_t length) override;
>      void didUpdateBufferedAmount(WebCore::SocketStreamHandle&, size_t bufferedAmount) override;
> +    void didFailSocketStream(WebCore::SocketStreamHandle&, const WebCore::SocketStreamError&) override { }

Should use final instead of override.
Comment 8 Alex Christensen 2016-08-16 00:14:53 PDT
Created attachment 286158 [details]
Patch
Comment 9 Alex Christensen 2016-08-16 00:59:46 PDT
Comment on attachment 286158 [details]
Patch

This patch changes something.  Will look into later.
Comment 10 Build Bot 2016-08-16 01:04:15 PDT
Comment on attachment 286158 [details]
Patch

Attachment 286158 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1879909

New failing tests:
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-sec-websocket-response-headers.html
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-websocket-response-headers.html
Comment 11 Build Bot 2016-08-16 01:04:18 PDT
Created attachment 286165 [details]
Archive of layout-test-results from ews101 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 12 Build Bot 2016-08-16 01:07:55 PDT
Comment on attachment 286158 [details]
Patch

Attachment 286158 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1879917

New failing tests:
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-sec-websocket-response-headers.html
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-websocket-response-headers.html
Comment 13 Build Bot 2016-08-16 01:07:58 PDT
Created attachment 286166 [details]
Archive of layout-test-results from ews106 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 14 Build Bot 2016-08-16 01:16:05 PDT
Comment on attachment 286158 [details]
Patch

Attachment 286158 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1879925

New failing tests:
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-sec-websocket-response-headers.html
http/tests/websocket/tests/hybi/handshake-ok-with-legacy-websocket-response-headers.html
Comment 15 Build Bot 2016-08-16 01:16:08 PDT
Created attachment 286168 [details]
Archive of layout-test-results from ews116 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 16 Alex Christensen 2016-08-16 09:37:21 PDT
Created attachment 286180 [details]
Patch
Comment 17 Alex Christensen 2016-08-16 11:13:09 PDT
https://trac.webkit.org/changeset/204512