Skip to content

Commit

Permalink
Merge pull request #3120 from lucas-clemente/fix-handshake-idle-timeout
Browse files Browse the repository at this point in the history
fix calculation of the handshake idle timeout
  • Loading branch information
marten-seemann authored Apr 2, 2021
2 parents 7f55fc7 + 63e810f commit 431a1fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@ func (s *session) nextKeepAliveTime() time.Time {
func (s *session) maybeResetTimer() {
var deadline time.Time
if !s.handshakeComplete {
deadline = s.sessionCreationTime.Add(utils.MinDuration(s.config.handshakeTimeout(), s.config.HandshakeIdleTimeout))
deadline = utils.MinTime(
s.sessionCreationTime.Add(s.config.handshakeTimeout()),
s.idleTimeoutStartTime().Add(s.config.HandshakeIdleTimeout),
)
} else {
if keepAliveTime := s.nextKeepAliveTime(); !keepAliveTime.IsZero() {
deadline = keepAliveTime
Expand Down
1 change: 1 addition & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,7 @@ var _ = Describe("Session", func() {
})

It("doesn't send a PING if the handshake isn't completed yet", func() {
sess.config.HandshakeIdleTimeout = time.Hour
sess.handshakeComplete = false
// Needs to be shorter than our idle timeout.
// Otherwise we'll try to send a CONNECTION_CLOSE.
Expand Down

0 comments on commit 431a1fa

Please sign in to comment.