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

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

Issue 10037003: Actually close socket, on eviction timeout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | no next file » | 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 class _HttpRequestResponseBase { 5 class _HttpRequestResponseBase {
6 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection) 6 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection)
7 : _contentLength = -1, 7 : _contentLength = -1,
8 _keepAlive = false, 8 _keepAlive = false,
9 _headers = new Map(); 9 _headers = new Map();
10 10
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 Date now = new Date.now(); 1206 Date now = new Date.now();
1207 _openSockets.forEach( 1207 _openSockets.forEach(
1208 void _(String key, Queue<_SocketConnection> connections) { 1208 void _(String key, Queue<_SocketConnection> connections) {
1209 // As returned connections are added at the head of the 1209 // As returned connections are added at the head of the
1210 // list remove from the tail. 1210 // list remove from the tail.
1211 while (!connections.isEmpty()) { 1211 while (!connections.isEmpty()) {
1212 _SocketConnection socketConn = connections.last(); 1212 _SocketConnection socketConn = connections.last();
1213 if (socketConn._idleTime(now).inMilliseconds > 1213 if (socketConn._idleTime(now).inMilliseconds >
1214 DEFAULT_EVICTION_TIMEOUT) { 1214 DEFAULT_EVICTION_TIMEOUT) {
1215 connections.removeLast(); 1215 connections.removeLast();
1216 socketConn._socket.close();
1216 } else { 1217 } else {
1217 break; 1218 break;
1218 } 1219 }
1219 } 1220 }
1220 }); 1221 });
1221 } 1222 }
1222 _evictionTimer = new Timer.repeating(10000, _handleEviction); 1223 _evictionTimer = new Timer.repeating(10000, _handleEviction);
1223 } 1224 }
1224 1225
1225 // Return connection. 1226 // Return connection.
1226 _activeSockets.remove(socketConn); 1227 _activeSockets.remove(socketConn);
1227 sockets.addFirst(socketConn); 1228 sockets.addFirst(socketConn);
1228 socketConn._markReturned(); 1229 socketConn._markReturned();
1229 } 1230 }
1230 1231
1231 Function _onOpen; 1232 Function _onOpen;
1232 Map<String, Queue<_SocketConnection>> _openSockets; 1233 Map<String, Queue<_SocketConnection>> _openSockets;
1233 Set<_SocketConnection> _activeSockets; 1234 Set<_SocketConnection> _activeSockets;
1234 Timer _evictionTimer; 1235 Timer _evictionTimer;
1235 bool _shutdown; // Has this HTTP client been shutdown? 1236 bool _shutdown; // Has this HTTP client been shutdown?
1236 } 1237 }
OLDNEW
« 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