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

Commit ec3977c

Browse files
committed
transport: conn, abort OpenShardConn faster when context is done
1 parent c1ccaf4 commit ec3977c

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
@@ -383,6 +383,10 @@ func OpenShardConn(ctx context.Context, addr string, si ShardInfo, cfg ConnConfi
383383
it := ShardPortIterator(si)
384384
maxTries := (maxPort-minPort+1)/int(si.NrShards) + 1
385385
for i := 0; i < maxTries; i++ {
386+
if err := ctx.Err(); err != nil {
387+
return nil, fmt.Errorf("aborted opening connection on shard %d: %w", si.Shard, err)
388+
}
389+
386390
conn, err := OpenLocalPortConn(ctx, addr, it(), cfg)
387391
if err != nil {
388392
cfg.Logger.Infof("%s dial error: %s (try %d/%d)", addr, err, i, maxTries)

0 commit comments

Comments
 (0)