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

Side by Side Diff: runtime/bin/socket_impl.dart

Issue 9368058: Revert "Fix potential flakiness of SocketStreamCloseTest." (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/standalone/src/SocketCloseTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 class _SocketBase { 6 class _SocketBase {
7 // Bit flags used when communicating between the eventhandler and 7 // Bit flags used when communicating between the eventhandler and
8 // dart code. The EVENT flags are used to indicate events of 8 // dart code. The EVENT flags are used to indicate events of
9 // interest when sending a message from dart code to the 9 // interest when sending a message from dart code to the
10 // eventhandler. When receiving a message from the eventhandler the 10 // eventhandler. When receiving a message from the eventhandler the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (_closedWrite) _close(); 51 if (_closedWrite) _close();
52 } 52 }
53 53
54 var eventHandler = _handlerMap[i]; 54 var eventHandler = _handlerMap[i];
55 if (eventHandler != null) { 55 if (eventHandler != null) {
56 // Unregister the out handler before executing it. 56 // Unregister the out handler before executing it.
57 if (i == _OUT_EVENT) _setHandler(i, null); 57 if (i == _OUT_EVENT) _setHandler(i, null);
58 58
59 // Don't call the in handler if there is no data available 59 // Don't call the in handler if there is no data available
60 // after all. 60 // after all.
61 if ((i == _IN_EVENT) && (this is _Socket) && (available() == 0)) { 61 if (i == _IN_EVENT && this is _Socket && available() == 0) {
62 continue; 62 continue;
63 } 63 }
64 eventHandler(); 64 eventHandler();
65 } 65 }
66 } 66 }
67 } 67 }
68 _canActivateHandlers = true; 68 _canActivateHandlers = true;
69 _activateHandlers(); 69 _activateHandlers();
70 } 70 }
71 71
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 } else if (_handler != null) { 126 } else if (_handler != null) {
127 // This is to support closing sockets created but never assigned 127 // This is to support closing sockets created but never assigned
128 // any actual socket. 128 // any actual socket.
129 _handler.close(); 129 _handler.close();
130 _handler = null; 130 _handler = null;
131 } 131 }
132 } 132 }
133 133
134 void _closeWrite() { 134 void _closeWrite() {
135 if (_id >= 0) { 135 if (_closedRead) {
136 if (_closedRead) { 136 _close();
137 _close(); 137 } else {
138 } else { 138 _sendToEventHandler(1 << _SHUTDOWN_WRITE_COMMAND);
139 _sendToEventHandler(1 << _SHUTDOWN_WRITE_COMMAND);
140 }
141 _closedWrite = true;
142 } 139 }
140 _closedWrite = true;
143 } 141 }
144 142
145 void _closeRead() { 143 void _closeRead() {
146 if (_id >= 0) { 144 if (_closedWrite) {
147 if (_closedWrite) { 145 _close();
148 _close(); 146 } else {
149 } else { 147 _sendToEventHandler(1 << _SHUTDOWN_READ_COMMAND);
150 _sendToEventHandler(1 << _SHUTDOWN_READ_COMMAND);
151 }
152 _closedRead = true;
153 } 148 }
149 _closedRead = true;
154 } 150 }
155 151
156 void _close() { 152 void _close() {
157 if (_id >= 0) { 153 _sendToEventHandler(1 << _CLOSE_COMMAND);
158 _sendToEventHandler(1 << _CLOSE_COMMAND); 154 _handler.close();
159 _handler.close(); 155 _handler = null;
160 _handler = null; 156 _id = -1;
161 _id = -1;
162 }
163 } 157 }
164 158
165 void _sendToEventHandler(int data) { 159 void _sendToEventHandler(int data) {
166 if (_handler === null) { 160 if (_handler === null) {
167 _handler = new ReceivePort(); 161 _handler = new ReceivePort();
168 _handler.receive((var message, ignored) { _multiplex(message); }); 162 _handler.receive((var message, ignored) { _multiplex(message); });
169 } 163 }
170 assert(_id >= 0);
171 _EventHandler._sendData(_id, _handler, data); 164 _EventHandler._sendData(_id, _handler, data);
172 } 165 }
173 166
174 abstract bool _isListenSocket(); 167 abstract bool _isListenSocket();
175 abstract bool _isPipe(); 168 abstract bool _isPipe();
176 169
177 // Socket id is set from native. -1 indicates that the socket was closed. 170 // Socket id is set from native. -1 indicates that the socket was closed.
178 int _id; 171 int _id;
179 172
180 // Dedicated ReceivePort for socket events. 173 // Dedicated ReceivePort for socket events.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 bool _seenFirstOutEvent = false; 458 bool _seenFirstOutEvent = false;
466 bool _closedRead = false; 459 bool _closedRead = false;
467 bool _closedWrite = false; 460 bool _closedWrite = false;
468 bool _pipe = false; 461 bool _pipe = false;
469 Function _clientConnectHandler; 462 Function _clientConnectHandler;
470 Function _clientWriteHandler; 463 Function _clientWriteHandler;
471 SocketInputStream _inputStream; 464 SocketInputStream _inputStream;
472 SocketOutputStream _outputStream; 465 SocketOutputStream _outputStream;
473 } 466 }
474 467
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/src/SocketCloseTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698