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

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: Address review comments 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..31c3fac0375ec7af110ad3f5838bd8f7fec0fc9b 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;
}
@@ -1349,7 +1353,8 @@ class _HttpConnection extends _HttpConnectionBase {
}
}
- // If currently not processing any request just close the socket.
+ // If currently not processing any request close the socket when
+ // we are done writing the response.
if (_httpParser.isIdle) {
_socket.outputStream.onClosed = () {
_destroy();
@@ -1358,6 +1363,9 @@ class _HttpConnection extends _HttpConnectionBase {
onClosed();
}
};
+ // If the client closes and we are done writing the response
+ // the connection should be closed.
+ if (_response == null) _close();
return;
}
« 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