Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
1aa56a23
Commit
1aa56a23
authored
Jan 30, 2013
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/http: fix race
Fixes #4724 R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/7225071
parent
6d2d2ae4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
transport.go
src/pkg/net/http/transport.go
+10
-10
No files found.
src/pkg/net/http/transport.go
View file @
1aa56a23
...
...
@@ -529,14 +529,13 @@ type persistConn struct {
closech
chan
struct
{}
// broadcast close when readLoop (TCP connection) closes
isProxy
bool
lk
sync
.
Mutex
// guards following 3 fields
numExpectedResponses
int
broken
bool
// an error has happened on this connection; marked broken so it's not reused.
// mutateHeaderFunc is an optional func to modify extra
// headers on each outbound request before it's written. (the
// original Request given to RoundTrip is not modified)
mutateHeaderFunc
func
(
Header
)
lk
sync
.
Mutex
// guards numExpectedResponses and broken
numExpectedResponses
int
broken
bool
// an error has happened on this connection; marked broken so it's not reused.
}
func
(
pc
*
persistConn
)
isBroken
()
bool
{
...
...
@@ -711,8 +710,13 @@ type writeRequest struct {
}
func
(
pc
*
persistConn
)
roundTrip
(
req
*
transportRequest
)
(
resp
*
Response
,
err
error
)
{
if
pc
.
mutateHeaderFunc
!=
nil
{
pc
.
mutateHeaderFunc
(
req
.
extraHeaders
())
pc
.
lk
.
Lock
()
pc
.
numExpectedResponses
++
headerFn
:=
pc
.
mutateHeaderFunc
pc
.
lk
.
Unlock
()
if
headerFn
!=
nil
{
headerFn
(
req
.
extraHeaders
())
}
// Ask for a compressed version if the caller didn't set their
...
...
@@ -728,10 +732,6 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
req
.
extraHeaders
()
.
Set
(
"Accept-Encoding"
,
"gzip"
)
}
pc
.
lk
.
Lock
()
pc
.
numExpectedResponses
++
pc
.
lk
.
Unlock
()
// Write the request concurrently with waiting for a response,
// in case the server decides to reply before reading our full
// request body.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment