Skip to content

Commit

Permalink
Merge pull request apache#728 from matope/avoid-timeoutlimit-if-zero
Browse files Browse the repository at this point in the history
Avoid ErrTooManyTimeouts if TimeoutLimit is 0
  • Loading branch information
Zariel committed May 10, 2016
2 parents b21054e + adec9dd commit 6c91092
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (fn connErrorHandlerFn) HandleError(conn *Conn, err error, closed bool) {
fn(conn, err, closed)
}

// How many timeouts we will allow to occur before the connection is closed
// If not zero, how many timeouts we will allow to occur before the connection is closed
// and restarted. This is to prevent a single query timeout from killing a connection
// which may be serving more queries just fine.
// Default is 10, should not be changed concurrently with queries.
Expand Down Expand Up @@ -522,7 +522,7 @@ func (c *Conn) releaseStream(stream int) {
}

func (c *Conn) handleTimeout() {
if atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
if TimeoutLimit > 0 && atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
c.closeWithError(ErrTooManyTimeouts)
}
}
Expand Down

0 comments on commit 6c91092

Please sign in to comment.