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

Unified Diff: dart/runtime/bin/socket_patch.dart

Issue 665823007: Several bugfixes in dart:io's handing of sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added two spaces as requested Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/runtime/bin/socket_patch.dart
diff --git a/dart/runtime/bin/socket_patch.dart b/dart/runtime/bin/socket_patch.dart
index d2dfc1433a2d7dd884e720baf89d99bd1817b54b..ab5019bffbbcc4dee46f0f56cc759ed877a8fb86 100644
--- a/dart/runtime/bin/socket_patch.dart
+++ b/dart/runtime/bin/socket_patch.dart
@@ -805,7 +805,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
if (write) issueWriteEvent();
if (!flagsSent && !isClosing) {
flagsSent = true;
- int flags = typeFlags & TYPE_TYPE_MASK;
+ int flags = 0;
if (!isClosedRead) flags |= 1 << READ_EVENT;
if (!isClosedWrite) flags |= 1 << WRITE_EVENT;
sendToEventHandler(flags);
@@ -861,9 +861,10 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
}
void sendToEventHandler(int data) {
+ int fullData = (typeFlags & TYPE_TYPE_MASK) | data;
assert(!isClosing);
connectToEventHandler();
- _EventHandler._sendData(this, eventPort.sendPort, data);
+ _EventHandler._sendData(this, eventPort.sendPort, fullData);
}
void connectToEventHandler() {
@@ -1182,6 +1183,7 @@ class _RawServerSocket extends Stream<RawSocket>
_controller.close();
if (_referencePort != null) {
_referencePort.close();
+ _referencePort = null;
}
});
return _controller.stream.listen(
@@ -1195,7 +1197,15 @@ class _RawServerSocket extends Stream<RawSocket>
InternetAddress get address => _socket.address;
- Future close() => _socket.close().then((_) => this);
+ Future close() {
+ return _socket.close().then((_) {
+ if (_referencePort != null) {
+ _referencePort.close();
+ _referencePort = null;
+ }
+ return this;
+ });
+ }
void _pause() {
_socket.setListening(read: false, write: false);

Powered by Google App Engine
This is Rietveld 408576698