mirror of
https://github.com/golang/go
synced 2024-11-21 22:14:41 -07:00
Update server.go
The original writing method may cause deadlocks as it affects lock copies
This commit is contained in:
parent
87ec2c959c
commit
14afcb3dc5
@ -315,6 +315,8 @@ func (c *conn) hijacked() bool {
|
|||||||
|
|
||||||
// c.mu must be held.
|
// c.mu must be held.
|
||||||
func (c *conn) hijackLocked() (rwc net.Conn, buf *bufio.ReadWriter, err error) {
|
func (c *conn) hijackLocked() (rwc net.Conn, buf *bufio.ReadWriter, err error) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
if c.hijackedv {
|
if c.hijackedv {
|
||||||
return nil, nil, ErrHijacked
|
return nil, nil, ErrHijacked
|
||||||
}
|
}
|
||||||
@ -2161,13 +2163,9 @@ func (w *response) Hijack() (rwc net.Conn, buf *bufio.ReadWriter, err error) {
|
|||||||
w.cw.flush()
|
w.cw.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
c := w.conn
|
|
||||||
c.mu.Lock()
|
|
||||||
defer c.mu.Unlock()
|
|
||||||
|
|
||||||
// Release the bufioWriter that writes to the chunk writer, it is not
|
// Release the bufioWriter that writes to the chunk writer, it is not
|
||||||
// used after a connection has been hijacked.
|
// used after a connection has been hijacked.
|
||||||
rwc, buf, err = c.hijackLocked()
|
rwc, buf, err = w.conn.hijackLocked()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
putBufioWriter(w.w)
|
putBufioWriter(w.w)
|
||||||
w.w = nil
|
w.w = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user