浏览代码

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()
 		p.makeOne()
 	}
 	}
 
 
-	deadline := time.After(timeout)
+	var deadline <-chan time.Time
+	if timeout < 0 {
+		deadline = nil
+	} else {
+		deadline = time.After(timeout)
+	}
+
 	for {
 	for {
 		select {
 		select {
 		case c := <-p.clients:
 		case c := <-p.clients: