mirror of
https://github.com/minio/minio.git
synced 2025-04-28 21:58:01 -04:00
Fix shared error buffer (#21203)
v.cancelFn(RemoteErr(m.Payload)) would use an already returned buffer. Simplify code a bit as well by returning on errors.
This commit is contained in:
parent
7ee75368e0
commit
fb3f67a597
@ -1625,23 +1625,28 @@ func (c *Connection) handleMuxServerMsg(ctx context.Context, m message) {
|
|||||||
Msg: nil,
|
Msg: nil,
|
||||||
Err: RemoteErr(m.Payload),
|
Err: RemoteErr(m.Payload),
|
||||||
})
|
})
|
||||||
|
if v.cancelFn != nil {
|
||||||
|
v.cancelFn(RemoteErr(m.Payload))
|
||||||
|
}
|
||||||
PutByteBuffer(m.Payload)
|
PutByteBuffer(m.Payload)
|
||||||
} else if m.Payload != nil {
|
v.close()
|
||||||
|
c.outgoing.Delete(m.MuxID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Return payload.
|
||||||
|
if m.Payload != nil {
|
||||||
v.response(m.Seq, Response{
|
v.response(m.Seq, Response{
|
||||||
Msg: m.Payload,
|
Msg: m.Payload,
|
||||||
Err: nil,
|
Err: nil,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// Close when EOF.
|
||||||
if m.Flags&FlagEOF != 0 {
|
if m.Flags&FlagEOF != 0 {
|
||||||
if v.cancelFn != nil && m.Flags&FlagPayloadIsErr == 0 {
|
|
||||||
// We must obtain the lock before closing
|
// We must obtain the lock before closing
|
||||||
// Otherwise others may pick up the error before close is called.
|
// Otherwise others may pick up the error before close is called.
|
||||||
v.respMu.Lock()
|
v.respMu.Lock()
|
||||||
v.closeLocked()
|
v.closeLocked()
|
||||||
v.respMu.Unlock()
|
v.respMu.Unlock()
|
||||||
} else {
|
|
||||||
v.close()
|
|
||||||
}
|
|
||||||
if debugReqs {
|
if debugReqs {
|
||||||
fmt.Println(m.MuxID, c.String(), "handleMuxServerMsg: DELETING MUX")
|
fmt.Println(m.MuxID, c.String(), "handleMuxServerMsg: DELETING MUX")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user