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:
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) {
|
func (p *peer) ReleaseDrpcConn(conn drpc.Conn) {
|
||||||
// do nothing if it's closed connection
|
var closed bool
|
||||||
select {
|
select {
|
||||||
case <-conn.Closed():
|
case <-conn.Closed():
|
||||||
return
|
closed = true
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,9 @@ func (p *peer) ReleaseDrpcConn(conn drpc.Conn) {
|
||||||
if _, ok = p.active[sc]; ok {
|
if _, ok = p.active[sc]; ok {
|
||||||
delete(p.active, sc)
|
delete(p.active, sc)
|
||||||
}
|
}
|
||||||
|
if !closed {
|
||||||
p.inactive = append(p.inactive, sc)
|
p.inactive = append(p.inactive, sc)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue