Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit e78bfd2

Browse files
committed
transport: conn, abort OpenShardConn faster when context is done
1 parent 88fc8ef commit e78bfd2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

transport/conn.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ func OpenShardConn(ctx context.Context, addr string, si ShardInfo, cfg ConnConfi
376376
it := ShardPortIterator(si)
377377
maxTries := (maxPort-minPort+1)/int(si.NrShards) + 1
378378
for i := 0; i < maxTries; i++ {
379+
if err := ctx.Err(); err != nil {
380+
return nil, fmt.Errorf("aborted opening connection on shard %d: %w", si.Shard, err)
381+
}
382+
379383
conn, err := OpenLocalPortConn(ctx, addr, it(), cfg)
380384
if err != nil {
381385
log.Printf("%s dial error: %s (try %d/%d)", addr, err, i, maxTries)

0 commit comments

Comments
 (0)