mirror of
https://github.com/golang/go
synced 2024-11-21 17:14:45 -07:00
http: optimization method tryDeliver
Reduce the scope of locks and make them more standardized
This commit is contained in:
parent
2707d42966
commit
1f9db0e3c5
@ -1296,18 +1296,19 @@ func (w *wantConn) getCtxForDial() context.Context {
|
||||
|
||||
// tryDeliver attempts to deliver pc, err to w and reports whether it succeeded.
|
||||
func (w *wantConn) tryDeliver(pc *persistConn, err error, idleAt time.Time) bool {
|
||||
if (pc == nil) == (err == nil) {
|
||||
panic("net/http: internal error: misuse of tryDeliver")
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
if w.done {
|
||||
return false
|
||||
}
|
||||
if (pc == nil) == (err == nil) {
|
||||
panic("net/http: internal error: misuse of tryDeliver")
|
||||
}
|
||||
|
||||
w.ctx = nil
|
||||
w.done = true
|
||||
|
||||
w.result <- connOrError{pc: pc, err: err, idleAt: idleAt}
|
||||
close(w.result)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user