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

Unified Diff: runtime/bin/socket_impl.dart

Issue 9361034: Fix potential flakiness of SocketStreamCloseTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add flags and fix close handling on sockets. Created 8 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
Index: runtime/bin/socket_impl.dart
diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart
index 6b5293601a2e964728fcfe31f2d85f7fe6207a87..04d5965e9780109ad418603ff8c667def631db55 100644
--- a/runtime/bin/socket_impl.dart
+++ b/runtime/bin/socket_impl.dart
@@ -58,7 +58,7 @@ class _SocketBase {
// Don't call the in handler if there is no data available
// after all.
- if (i == _IN_EVENT && this is _Socket && available() == 0) {
+ if ((i == _IN_EVENT) && (this is _Socket) && (available() == 0)) {
continue;
}
eventHandler();
@@ -132,28 +132,34 @@ class _SocketBase {
}
void _closeWrite() {
- if (_closedRead) {
- _close();
- } else {
- _sendToEventHandler(1 << _SHUTDOWN_WRITE_COMMAND);
+ if (_id >= 0) {
+ if (_closedRead) {
+ _close();
+ } else {
+ _sendToEventHandler(1 << _SHUTDOWN_WRITE_COMMAND);
+ }
+ _closedWrite = true;
}
- _closedWrite = true;
}
void _closeRead() {
- if (_closedWrite) {
- _close();
- } else {
- _sendToEventHandler(1 << _SHUTDOWN_READ_COMMAND);
+ if (_id >= 0) {
+ if (_closedWrite) {
+ _close();
+ } else {
+ _sendToEventHandler(1 << _SHUTDOWN_READ_COMMAND);
+ }
+ _closedRead = true;
}
- _closedRead = true;
}
void _close() {
- _sendToEventHandler(1 << _CLOSE_COMMAND);
- _handler.close();
- _handler = null;
- _id = -1;
+ if (_id >= 0) {
+ _sendToEventHandler(1 << _CLOSE_COMMAND);
+ _handler.close();
+ _handler = null;
+ _id = -1;
+ }
}
void _sendToEventHandler(int data) {
« no previous file with comments | « no previous file | tests/standalone/src/SocketCloseTest.dart » ('j') | tests/standalone/src/SocketStreamCloseTest.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698