Skip to content

Commit

Permalink
event/event: reset read deadline
Browse files Browse the repository at this point in the history
To make sure we can re-use the connection.
  • Loading branch information
thiagokokada committed Sep 1, 2024
1 parent 0021720 commit 4292eee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ func readWithContext(ctx context.Context, conn net.Conn, buf []byte) (int, error
case <-ctx.Done():
// Set a short deadline to unblock the Read()
conn.SetReadDeadline(time.Now())
<-done // Make sure that the goroutine is done to avoid leaks
// Reset read deadline
defer conn.SetReadDeadline(time.Time{})
// Make sure that the goroutine is done to avoid leaks
<-done
return 0, ctx.Err()
}
}
Expand Down

0 comments on commit 4292eee

Please sign in to comment.