Browse Source

Merge pull request #728 from matope/avoid-timeoutlimit-if-zero

Avoid ErrTooManyTimeouts if TimeoutLimit is 0
Chris Bannister 9 years ago
parent
commit
6c910921fa
1 changed files with 2 additions and 2 deletions
  1. 2 2
      conn.go

+ 2 - 2
conn.go

@@ -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.
@@ -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)
 	}
 }