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

Unified Diff: runtime/bin/socket_patch.dart

Issue 975723002: Fix issues with Socket shutdown. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | tests/standalone/io/issue_22637_test.dart » ('j') | tests/standalone/io/issue_22637_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index c866977f29ad60b7ac3b771a39e57f68add1782f..dfbd46589e564f18d875c00975941125320c3c9d 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -287,6 +287,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
bool isClosed = false;
bool isClosing = false;
bool isClosedRead = false;
+ bool closedReadEventSent = false;
bool isClosedWrite = false;
Completer closeCompleter = new Completer.sync();
@@ -694,6 +695,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
}
void issueReadEvent() {
+ if (closedReadEventSent) return;
if (readEventIssued) return;
readEventIssued = true;
void issue() {
@@ -701,10 +703,11 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
if (isClosing) return;
if (!sendReadEvents) return;
if (available == 0) {
- if (isClosedRead) {
+ if (isClosedRead && !closedReadEventSent) {
if (isClosedWrite) close();
var handler = eventHandlers[CLOSED_EVENT];
if (handler == null) return;
+ closedReadEventSent = true;
handler();
}
return;
@@ -860,7 +863,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
void shutdownWrite() {
if (!isClosing && !isClosed) {
- if (isClosedRead) {
+ if (closedReadEventSent) {
close();
} else {
sendToEventHandler(1 << SHUTDOWN_WRITE_COMMAND);
« no previous file with comments | « no previous file | tests/standalone/io/issue_22637_test.dart » ('j') | tests/standalone/io/issue_22637_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698