Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Issue 2803543006: Added synchronous socket implementation to dart:io. (Closed)

Created:
3 years, 8 months ago by bkonyi
Modified:
3 years, 8 months ago
Reviewers:
zra, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Added synchronous socket implementation to dart:io. BUG= R=zra@google.com Committed: https://github.com/dart-lang/sdk/commit/a1f87ebdb835efdc91db5f18f81603658f1f7e32

Patch Set 1 #

Patch Set 2 : Small fix for MacOS #

Total comments: 113

Patch Set 3 : Addressed first round of comments #

Total comments: 82

Patch Set 4 : Addressed second round of comments #

Total comments: 26

Patch Set 5 : Added synchronous socket implementation to dart:io. #

Total comments: 14

Patch Set 6 : Updated io_patch files to include RawSynchronousSocket definitions #

Total comments: 4

Patch Set 7 : Changed signature for GetSocketIdNativeField #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1765 lines, -46 lines) Patch
M pkg/dev_compiler/tool/input_sdk/patch/io_patch.dart View 1 2 3 4 5 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/bin/io_impl_sources.gypi View 1 chunk +7 lines, -0 lines 0 comments Download
M runtime/bin/io_natives.cc View 1 2 1 chunk +11 lines, -0 lines 0 comments Download
M runtime/bin/io_sources.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/bin/socket_android.cc View 1 2 1 chunk +1 line, -10 lines 0 comments Download
M runtime/bin/socket_fuchsia.cc View 1 2 1 chunk +2 lines, -13 lines 0 comments Download
M runtime/bin/socket_linux.cc View 1 2 1 chunk +2 lines, -12 lines 0 comments Download
M runtime/bin/socket_macos.cc View 1 2 1 chunk +2 lines, -11 lines 0 comments Download
A runtime/bin/sync_socket.h View 1 2 3 4 5 6 1 chunk +48 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket.cc View 1 2 3 4 5 6 1 chunk +365 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_android.cc View 1 2 1 chunk +78 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_fuchsia.cc View 1 2 1 chunk +80 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_linux.cc View 1 2 1 chunk +80 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_macos.cc View 1 2 1 chunk +77 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_patch.dart View 1 2 3 1 chunk +347 lines, -0 lines 0 comments Download
A runtime/bin/sync_socket_win.cc View 1 2 3 1 chunk +50 lines, -0 lines 0 comments Download
M sdk/lib/_internal/js_runtime/lib/io_patch.dart View 1 2 3 4 5 1 chunk +8 lines, -0 lines 0 comments Download
M sdk/lib/io/io.dart View 1 chunk +1 line, -0 lines 0 comments Download
M sdk/lib/io/io_sources.gypi View 1 chunk +1 line, -0 lines 0 comments Download
A sdk/lib/io/sync_socket.dart View 1 2 3 1 chunk +108 lines, -0 lines 0 comments Download
A tests/standalone/io/raw_synchronous_socket_test.dart View 1 2 3 1 chunk +488 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (2 generated)
bkonyi
PTAL when you get a chance!
3 years, 8 months ago (2017-04-06 21:36:12 UTC) #2
zra
First round of comments. https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h File runtime/bin/eventhandler_win.h (right): https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h#newcode449 runtime/bin/eventhandler_win.h:449: explicit ClientSocket(intptr_t s, bool sync ...
3 years, 8 months ago (2017-04-07 05:29:28 UTC) #3
zra
https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h File runtime/bin/eventhandler_win.h (right): https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h#newcode449 runtime/bin/eventhandler_win.h:449: explicit ClientSocket(intptr_t s, bool sync = false) On 2017/04/07 ...
3 years, 8 months ago (2017-04-07 14:41:12 UTC) #4
zra
More comments... https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/sync_socket.cc#newcode172 runtime/bin/sync_socket.cc:172: Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); Above, you return an ArgumentError ...
3 years, 8 months ago (2017-04-07 16:29:42 UTC) #5
bkonyi
This should cover the first round of comments... PTAL. https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h File runtime/bin/eventhandler_win.h (right): https://codereview.chromium.org/2803543006/diff/10018/runtime/bin/eventhandler_win.h#newcode449 runtime/bin/eventhandler_win.h:449: ...
3 years, 8 months ago (2017-04-10 19:20:07 UTC) #6
zra
https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/eventhandler_win.h File runtime/bin/eventhandler_win.h (right): https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/eventhandler_win.h#newcode449 runtime/bin/eventhandler_win.h:449: explicit ClientSocket(intptr_t s, bool sync = false) Let's remove ...
3 years, 8 months ago (2017-04-10 21:39:44 UTC) #7
siva
https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/sync_socket.cc#newcode24 runtime/bin/sync_socket.cc:24: static const int kSocketIdNativeField = 0; I have one ...
3 years, 8 months ago (2017-04-10 22:51:46 UTC) #8
bkonyi
Addressed the latest round of comments. PTAL https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/eventhandler_win.h File runtime/bin/eventhandler_win.h (right): https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/eventhandler_win.h#newcode449 runtime/bin/eventhandler_win.h:449: explicit ClientSocket(intptr_t ...
3 years, 8 months ago (2017-04-11 01:30:52 UTC) #9
zra
We're getting close! https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/30001/runtime/bin/sync_socket.cc#newcode167 runtime/bin/sync_socket.cc:167: On 2017/04/11 01:30:50, bkonyi wrote: > ...
3 years, 8 months ago (2017-04-11 16:19:41 UTC) #10
bkonyi
Hopefully this should do it! PTAL :) https://codereview.chromium.org/2803543006/diff/50001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/50001/runtime/bin/sync_socket.cc#newcode50 runtime/bin/sync_socket.cc:50: char* host ...
3 years, 8 months ago (2017-04-11 18:11:18 UTC) #11
zra
To avoid angering dart2js and ddc, we also need to fill in dummy @patch implementations ...
3 years, 8 months ago (2017-04-11 20:08:28 UTC) #12
bkonyi
I think this covers the last set of comments... PTAL. https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.cc#newcode306 ...
3 years, 8 months ago (2017-04-11 21:10:17 UTC) #13
zra
https://codereview.chromium.org/2803543006/diff/90001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/90001/runtime/bin/sync_socket.cc#newcode24 runtime/bin/sync_socket.cc:24: Dart_SetReturnValue(args, DartUtils::NewDartOSError()); \ This will mask a Dart error ...
3 years, 8 months ago (2017-04-11 21:21:46 UTC) #14
bkonyi
Comments addressed. PTAL. https://codereview.chromium.org/2803543006/diff/90001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/90001/runtime/bin/sync_socket.cc#newcode24 runtime/bin/sync_socket.cc:24: Dart_SetReturnValue(args, DartUtils::NewDartOSError()); \ On 2017/04/11 21:21:45, ...
3 years, 8 months ago (2017-04-11 21:34:53 UTC) #15
zra
lgtm
3 years, 8 months ago (2017-04-11 21:37:44 UTC) #16
bkonyi
Committed patchset #7 (id:110001) manually as a1f87ebdb835efdc91db5f18f81603658f1f7e32 (presubmit successful).
3 years, 8 months ago (2017-04-11 21:41:19 UTC) #18
siva
https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.cc File runtime/bin/sync_socket.cc (right): https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.cc#newcode149 runtime/bin/sync_socket.cc:149: Dart_TypedDataReleaseData(buffer_obj); Dart_TypedDataReleaseData(buffer_obj); can be hoisted down to the end. ...
3 years, 8 months ago (2017-04-11 23:04:47 UTC) #19
bkonyi
3 years, 8 months ago (2017-04-12 18:21:09 UTC) #20
Message was sent while issue was closed.
Siva, I've addressed your comments in this CL here:
https://codereview.chromium.org/2814773004/

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.cc
File runtime/bin/sync_socket.cc (right):

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket...
runtime/bin/sync_socket.cc:149: Dart_TypedDataReleaseData(buffer_obj);
On 2017/04/11 23:04:47, siva wrote:
> Dart_TypedDataReleaseData(buffer_obj);
> 
> can be hoisted down to the end.

Done.

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket...
runtime/bin/sync_socket.cc:175: DART_CHECK_ERROR(result);
On 2017/04/11 23:04:47, siva wrote:
> If byte_read is 0 then there is nothing to set in the List...

That's right. I've gone ahead and changed the check to > 0 and then if
bytes_read == 0 we just set the return value instead of making the
Dart_ListSetAsBytes call for no reason.

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket...
runtime/bin/sync_socket.cc:226: }
On 2017/04/11 23:04:47, siva wrote:
> is SocketBase::Read guaranteed to never return 0? In ReadList above it seems
to
> account for 0.

Read can return 0 if asked to read 0 bytes or if the connection is closed. If
bytes_read == 0, we just return null for this call.

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket.h
File runtime/bin/sync_socket.h (right):

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket...
runtime/bin/sync_socket.h:10: #endif
On 2017/04/11 23:04:47, siva wrote:
> The socket* files seem to use
> #if !defined(DART_IO_DISABLED)
> ...
> ...
> ...
> #endif  // !defined(DART_IO_DISABLED)
> 
> why not use the same pattern here too?

That pattern is only used in the socket*.cc files, and the pattern here matches
socket.h. Is this something we want to change in both files?

https://codereview.chromium.org/2803543006/diff/70001/runtime/bin/sync_socket...
runtime/bin/sync_socket.h:31: static SynchronousSocket*
GetSocketIdNativeField(Dart_Handle socket);
On 2017/04/11 23:04:47, siva wrote:
> The get/set API is not uniform
> set takes an intptr_t id
> get returns SynchronousSocket*
> 
> Maybe we should make them consistent (I see that the async socket API is also
> similar, something to consider for another CL).

Done.

Powered by Google App Engine
This is Rietveld 408576698