mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-23 21:44:41 +02:00
fix http_transport Recv and Close race condition on buff (#2374)
fix rpc_stream panic override with the "Unlock of unlocked RWMutex" panic Co-authored-by: Hunyadvári Péter <peter.hunyadvari@vcc.live>
This commit is contained in:
@@ -75,10 +75,10 @@ func (r *rpcStream) Send(msg interface{}) error {
|
||||
|
||||
func (r *rpcStream) Recv(msg interface{}) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
if r.isClosed() {
|
||||
r.err = errShutdown
|
||||
r.Unlock()
|
||||
return errShutdown
|
||||
}
|
||||
|
||||
@@ -90,9 +90,12 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
||||
if err != nil {
|
||||
if err == io.EOF && !r.isClosed() {
|
||||
r.err = io.ErrUnexpectedEOF
|
||||
r.Unlock()
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
r.err = err
|
||||
|
||||
r.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -121,6 +124,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
||||
}
|
||||
}
|
||||
|
||||
r.Unlock()
|
||||
return r.err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user