소스 검색

allow <0 timeout to mean "no timeout"

Travis J Parker 10 년 전
부모
커밋
6fcdc1dbbf
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      pool.go

+ 7 - 1
pool.go

@@ -53,7 +53,13 @@ func (p *Pool) get(timeout time.Duration) *client {
 		p.makeOne()
 	}
 
-	deadline := time.After(timeout)
+	var deadline <-chan time.Time
+	if timeout < 0 {
+		deadline = nil
+	} else {
+		deadline = time.After(timeout)
+	}
+
 	for {
 		select {
 		case c := <-p.clients: