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

Unified Diff: sdk/lib/io/secure_socket.dart

Issue 12313146: dart:io | Fix issue 8795, (Raw)SecureSocket loses data when close() is called. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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/raw_secure_socket_pause_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index c1f40db91ed87817ace2ad5633e1ae8b445d4660..b4db0ef6eac4c3c86c8ce9fa58d83a9c7b961e09 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -283,7 +283,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
})
.catchError((error) {
_handshakeComplete.completeError(error);
- close();
+ _close();
});
}
@@ -341,6 +341,10 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
}
void close() {
+ shutdown(SocketDirection.BOTH);
+ }
+
+ void _close() {
_closedWrite = true;
_closedRead = true;
if (_socket != null) {
@@ -360,24 +364,25 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
}
void shutdown(SocketDirection direction) {
- if (direction == SocketDirection.BOTH) {
- close();
- } else if (direction == SocketDirection.SEND) {
+ if (direction == SocketDirection.SEND ||
+ direction == SocketDirection.BOTH) {
_closedWrite = true;
_writeEncryptedData();
if (_filterWriteEmpty) {
_socket.shutdown(SocketDirection.SEND);
_socketClosedWrite = true;
if (_closedRead) {
- close();
+ _close();
}
}
- } else if (direction == SocketDirection.RECEIVE) {
+ }
+ if (direction == SocketDirection.RECEIVE ||
+ direction == SocketDirection.BOTH) {
_closedRead = true;
_socketClosedRead = true;
_socket.shutdown(SocketDirection.RECEIVE);
if (_socketClosedWrite) {
- close();
+ _close();
}
}
}
@@ -543,7 +548,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
void _doneHandler() {
if (_filterReadEmpty) {
- close();
+ _close();
}
}
@@ -568,7 +573,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
} else {
_controller.signalError(e);
}
- close();
+ _close();
}
void _closeHandler() {
@@ -579,7 +584,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
_closedRead = true;
_controller.add(RawSocketEvent.READ_CLOSED);
if (_socketClosedWrite) {
- close();
+ _close();
}
}
} else if (_status == HANDSHAKE) {
« no previous file with comments | « no previous file | tests/standalone/io/raw_secure_socket_pause_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698