Просмотр исходного кода

Avoid ErrTooManyTimeouts if TimeoutLimit is 0

matope 9 лет назад
Родитель
Сommit
adec9dda56
1 измененных файлов с 2 добавлено и 2 удалено
  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)
 	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
 // and restarted. This is to prevent a single query timeout from killing a connection
 // which may be serving more queries just fine.
 // which may be serving more queries just fine.
 // Default is 10, should not be changed concurrently with queries.
 // Default is 10, should not be changed concurrently with queries.
@@ -522,7 +522,7 @@ func (c *Conn) releaseStream(stream int) {
 }
 }
 
 
 func (c *Conn) handleTimeout() {
 func (c *Conn) handleTimeout() {
-	if atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
+	if TimeoutLimit > 0 && atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
 		c.closeWithError(ErrTooManyTimeouts)
 		c.closeWithError(ErrTooManyTimeouts)
 	}
 	}
 }
 }