1
0
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:
Ak-Army
2021-12-05 12:56:17 +01:00
committed by GitHub
parent 81244a41f1
commit 97f169c424
3 changed files with 94 additions and 6 deletions

View File

@@ -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
}