mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
fix select order
This commit is contained in:
parent
b9192f1cd2
commit
943e151406
1 changed files with 3 additions and 2 deletions
|
@ -174,12 +174,13 @@ func (p *peer) AcquireDrpcConn(ctx context.Context) (drpc.Conn, error) {
|
|||
func (p *peer) ReleaseDrpcConn(ctx context.Context, conn drpc.Conn) {
|
||||
var closed bool
|
||||
select {
|
||||
case <-conn.Closed():
|
||||
closed = true
|
||||
case <-ctx.Done():
|
||||
// in case ctx is closed the connection may be not yet closed because of the signal logic in the drpc manager
|
||||
// but, we want to shortcut to avoid race conditions
|
||||
_ = conn.Close()
|
||||
closed = true
|
||||
case <-conn.Closed():
|
||||
closed = true
|
||||
default:
|
||||
// make sure this connection doesn't have an unfinished work
|
||||
if connCasted, ok := conn.(connUnblocked); ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue