mirror of
https://github.com/golang/go
synced 2024-11-22 03:14:41 -07:00
net/http: fix hijack hang at abortPendingRead
When concurrent many http requests which need hijack the connenction, hijack may hang at abortPendingRead() on cr.cond.Wait(). The read can be from readRequest() from conn.serve() or w.conn.r.startBackgroundRead(). especially in startBackgroundRead() which always set the deadline time.Time{}. This problem seems easy reproduce on arm. Signed-off-by: jingrui <jingrui@huawei.com>
This commit is contained in:
parent
6c1c055d1e
commit
78770c121e
@ -736,9 +736,25 @@ func (cr *connReader) abortPendingRead() {
|
|||||||
}
|
}
|
||||||
cr.aborted = true
|
cr.aborted = true
|
||||||
cr.conn.rwc.SetReadDeadline(aLongTimeAgo)
|
cr.conn.rwc.SetReadDeadline(aLongTimeAgo)
|
||||||
for cr.inRead {
|
done := make(chan struct{})
|
||||||
cr.cond.Wait()
|
go func() {
|
||||||
}
|
for cr.inRead {
|
||||||
|
cr.cond.Wait()
|
||||||
|
}
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
|
||||||
|
func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case <-time.After(100*time.Millisecond):
|
||||||
|
cr.conn.rwc.SetReadDeadline(aLongTimeAgo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
cr.conn.rwc.SetReadDeadline(time.Time{})
|
cr.conn.rwc.SetReadDeadline(time.Time{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user