1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

peer: fix closed connection release

This commit is contained in:
Sergey Cherepanov 2025-03-27 14:16:10 +01:00
parent be1420aba0
commit 0f9a319e58
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C

View file

@ -159,10 +159,10 @@ func (p *peer) AcquireDrpcConn(ctx context.Context) (drpc.Conn, error) {
}
func (p *peer) ReleaseDrpcConn(conn drpc.Conn) {
// do nothing if it's closed connection
var closed bool
select {
case <-conn.Closed():
return
closed = true
default:
}
@ -183,7 +183,9 @@ func (p *peer) ReleaseDrpcConn(conn drpc.Conn) {
if _, ok = p.active[sc]; ok {
delete(p.active, sc)
}
p.inactive = append(p.inactive, sc)
if !closed {
p.inactive = append(p.inactive, sc)
}
return
}