Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2833)

Issue 148970043: code review 148970043: net/http: make Transport.CloseIdleConnections also clos... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 7 months ago by bradfitz
Modified:
9 years, 7 months ago
Reviewers:
adg
CC:
golang-codereviews, dvyukov, adg, rsc
Visibility:
Public.

Description

net/http: make Transport.CloseIdleConnections also close pending dials See comment 4 of https://code.google.com/p/go/issues/detail?id=8483#c4: "So if a user creates a http.Client, issues a bunch of requests and then wants to shutdown it and all opened connections; what is she intended to do? The report suggests that just waiting for all pending requests and calling CloseIdleConnections won't do, as there can be new racing connections. Obviously she can't do what you've done in the test, as it uses the unexported function. If this happens periodically, it can lead to serious resource leaks (the transport is also preserved alive). Am I missing something?" This CL tracks the user's intention to close all idle connections (CloseIdleConnections sets it true; and making a new request sets it false). If a pending dial finishes and nobody wants it, before it's retained for a future caller, the "wantIdle" bool is checked and it's closed if the user has called CloseIdleConnections without a later call to make a new request. Fixes Issue 8483

Patch Set 1 #

Patch Set 2 : diff -r 1e2b51e32781fe475a580ffc8a7776507dfec1d5 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 1e2b51e32781fe475a580ffc8a7776507dfec1d5 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 3d8bc2ff5bcfcc766f9388c47e8a1f162ae57522 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 70456f183225fc8faaf381c696b3fd0c9dfd951b https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+74 lines, -5 lines) Patch
M src/net/http/export_test.go View 1 2 3 1 chunk +20 lines, -0 lines 0 comments Download
M src/net/http/transport.go View 1 2 3 4 chunks +15 lines, -5 lines 0 comments Download
M src/net/http/transport_test.go View 1 2 3 1 chunk +39 lines, -0 lines 0 comments Download

Messages

Total messages: 8
bradfitz
Hello golang-codereviews@googlegroups.com (cc: adg@golang.org, dvyukov@google.com, rsc@golang.org), I'd like you to review this change to https://go.googlecode.com/hg/
9 years, 7 months ago (2014-09-24 17:32:59 UTC) #1
dvyukov
Can we revert the test changes and test hooks now? The idea is that the ...
9 years, 7 months ago (2014-09-24 18:36:39 UTC) #2
bradfitz
No. This CL only says that the pending connections will eventually be shut down (when ...
9 years, 7 months ago (2014-09-24 18:45:49 UTC) #3
adg
LGTM
9 years, 7 months ago (2014-09-25 00:02:47 UTC) #4
bradfitz
I'll wait to add a test for this first, and then ask for another review. ...
9 years, 7 months ago (2014-09-25 00:05:24 UTC) #5
bradfitz
PTAL Andrew (or anybody) now with tests. Nothing too interesting. On Wed, Sep 24, 2014 ...
9 years, 7 months ago (2014-09-29 18:28:29 UTC) #6
adg
LGTM
9 years, 7 months ago (2014-09-30 00:56:06 UTC) #7
bradfitz
9 years, 7 months ago (2014-09-30 01:16:04 UTC) #8
*** Submitted as https://code.google.com/p/go/source/detail?r=6573961dc33e ***

net/http: make Transport.CloseIdleConnections also close pending dials

See comment 4 of https://code.google.com/p/go/issues/detail?id=8483#c4:

"So if a user creates a http.Client, issues a bunch of
requests and then wants to shutdown it and all opened connections;
what is she intended to do? The report suggests that just waiting for
all pending requests and calling CloseIdleConnections won't do, as
there can be new racing connections. Obviously she can't do what
you've done in the test, as it uses the unexported function.  If this
happens periodically, it can lead to serious resource leaks (the
transport is also preserved alive).  Am I missing something?"

This CL tracks the user's intention to close all idle
connections (CloseIdleConnections sets it true; and making a
new request sets it false). If a pending dial finishes and
nobody wants it, before it's retained for a future caller, the
"wantIdle" bool is checked and it's closed if the user has
called CloseIdleConnections without a later call to make a new
request.

Fixes Issue 8483

LGTM=adg
R=golang-codereviews, dvyukov, adg
CC=golang-codereviews, rsc
https://codereview.appspot.com/148970043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b