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

Unified Diff: runtime/bin/socket_impl.dart

Issue 9382001: Another attempt at fixing the Socket tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | runtime/bin/socket_stream_impl.dart » ('j') | runtime/bin/socket_stream_impl.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_impl.dart
diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart
index 6b5293601a2e964728fcfe31f2d85f7fe6207a87..a4822d09d957c616a58af9fa8c3848d5ad3da0ea 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) {
@@ -161,6 +167,7 @@ class _SocketBase {
_handler = new ReceivePort();
_handler.receive((var message, ignored) { _multiplex(message); });
}
+ assert(_id >= 0);
_EventHandler._sendData(_id, _handler, data);
}
@@ -382,7 +389,7 @@ class _Socket extends _SocketBase implements Socket {
void set closeHandler(void callback()) {
if (_inputStream != null) throw new StreamException(
- "Cannot set data handler when input stream is used");
+ "Cannot set close handler when input stream is used");
_closeHandler = callback;
}
« no previous file with comments | « no previous file | runtime/bin/socket_stream_impl.dart » ('j') | runtime/bin/socket_stream_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698