Skip to content

Commit c5c05a3

Browse files
committed
address comments
1 parent 66e3dc4 commit c5c05a3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test.ci:
2929
(cd "$${dir}" && \
3030
go mod tidy -compat=1.18 && \
3131
go vet && \
32-
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -timeout 20m -skip Example); \
32+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example); \
3333
done
3434
cd internal/customvet && go build .
3535
go vet -vettool ./internal/customvet/customvet

hitless/notification_handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
118118
// do this in a goroutine to avoid blocking the notification handler
119119
go func() {
120120
time.Sleep(time.Duration(timeS/2) * time.Second)
121+
if poolConn == nil || poolConn.IsClosed() {
122+
return
123+
}
121124
if err := snh.markConnForHandoff(poolConn, newEndpoint, seqID, deadline); err != nil {
122125
// Log error but don't fail the goroutine
123126
internal.Logger.Printf(context.Background(), "hitless: failed to mark connection for handoff: %v", err)

internal/pool/conn.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Conn struct {
4545

4646
Inited atomic.Bool
4747
pooled bool
48+
closed atomic.Bool
4849
createdAt time.Time
4950
expiresAt time.Time
5051

@@ -542,7 +543,12 @@ func (cn *Conn) WithWriter(
542543
return cn.bw.Flush()
543544
}
544545

546+
func (cn *Conn) IsClosed() bool {
547+
return cn.closed.Load()
548+
}
549+
545550
func (cn *Conn) Close() error {
551+
cn.closed.Store(true)
546552
if cn.onClose != nil {
547553
// ignore error
548554
_ = cn.onClose()

0 commit comments

Comments
 (0)