1
0
Fork 0
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:
Roman Khafizianov 2025-05-07 19:23:34 +02:00
parent b9192f1cd2
commit 943e151406
No known key found for this signature in database
GPG key ID: F07A7D55A2684852

View file

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