From 8800decca48b7062f2f7a862c7605c5efff0f6e4 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 13 Apr 2021 13:52:06 +0000 Subject: [PATCH] [io] Move OSError::isInprogressCode to implementation patch class. This addresses comments on https://dart-review.googlesource.com/c/sdk/+/193221. TEST=ci Change-Id: I0eaac9f640b172e37da6199f7353de8b066f854e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195059 Reviewed-by: Lasse R.H. Nielsen Reviewed-by: Jonas Termansen Commit-Queue: Alexander Aprelev --- sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart | 8 -------- sdk/lib/_internal/js_runtime/lib/io_patch.dart | 8 -------- sdk/lib/_internal/vm/bin/socket_patch.dart | 5 ++++- sdk/lib/io/common.dart | 3 --- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart b/sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart index d0e0ba2f2a3..041dfd54c18 100644 --- a/sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart +++ b/sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart @@ -219,14 +219,6 @@ bool _isDirectIOCapableTypedList(List buffer) { throw UnsupportedError("_isDirectIOCapableTypedList"); } -@patch -class OSError { - @patch - static int inProgressErrorCode() { - throw new UnsupportedError("OSError.inProgressErrorCode"); - } -} - @patch class _IOCrypto { @patch diff --git a/sdk/lib/_internal/js_runtime/lib/io_patch.dart b/sdk/lib/_internal/js_runtime/lib/io_patch.dart index fb7052f7436..77a253027ff 100644 --- a/sdk/lib/_internal/js_runtime/lib/io_patch.dart +++ b/sdk/lib/_internal/js_runtime/lib/io_patch.dart @@ -227,14 +227,6 @@ class _IOCrypto { } } -@patch -class OSError { - @patch - static int inProgressErrorCode() { - throw new UnsupportedError("OSError.inProgressErrorCode"); - } -} - @patch class _Platform { @patch diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart index a20a0bb9a6c..6c3a77a0d05 100644 --- a/sdk/lib/_internal/vm/bin/socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/socket_patch.dart @@ -374,6 +374,9 @@ class _NetworkInterface implements NetworkInterface { // implicit constructor. class _NativeSocketNativeWrapper extends NativeFieldWrapperClass1 {} +/// Returns error code that corresponds to EINPROGRESS OS error. +int get _inProgressErrorCode native "OSError_inProgressErrorCode"; + // The _NativeSocket class encapsulates an OS socket. class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { // Bit flags used when communicating between the eventhandler and @@ -802,7 +805,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { try { socket.port; } catch (e) { - if (e is OSError && e.errorCode == OSError.inProgressErrorCode()) { + if (e is OSError && e.errorCode == _inProgressErrorCode) { // Ignore the error, proceed with waiting for a socket to become open. // In non-blocking mode connect might not be established away, socket // have to be waited for. diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart index a2d4d733ec5..252d602b115 100644 --- a/sdk/lib/io/common.dart +++ b/sdk/lib/io/common.dart @@ -48,9 +48,6 @@ class OSError implements Exception { /// Constant used to indicate that no OS error code is available. static const int noErrorCode = -1; - /// Returns error code that corresponds to EINPROGRESS OS error. - external static int inProgressErrorCode(); - /// Error message supplied by the operating system. This will be empty if no /// message is associated with the error. final String message;