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

Unified Diff: runtime/bin/http_impl.dart

Issue 10914200: Fix closing of server sockets. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/http_impl.dart
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
index cbfa7de120b8703120c8fb553f22789d0b0744d2..34f893cfd41fe7cc32f96a180d731ce1d9375397 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -690,7 +690,11 @@ class _HttpRequestResponseBase {
}
assert(_headResponse || _bodyBytesWritten == _contentLength);
}
- if (!persistentConnection) _httpConnection._close();
+ // If we are done writing the response and the client has closed
+ // or the connection is not persistent we can close.
+ if (!persistentConnection || _httpConnection._closing) {
+ _httpConnection._close();
+ }
return allWritten;
}
@@ -1351,6 +1355,9 @@ class _HttpConnection extends _HttpConnectionBase {
// If currently not processing any request just close the socket.
if (_httpParser.isIdle) {
+ // If the client closes and we are done writing the response
+ // the connection should be closed.
+ if (_response == null) _close();
Anders Johnsen 2012/09/11 12:49:40 Nice. Would it make sense to move this to below th
Mads Ager (google) 2012/09/11 14:43:11 I can do that. Thanks. :)
_socket.outputStream.onClosed = () {
_destroy();
if (onClosed != null && e == null) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698