mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-07 21:47:02 +09:00
peer: fix closed connection release
This commit is contained in:
parent
be1420aba0
commit
0f9a319e58
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue