浏览代码

Merge pull request #751 from Highstead/abort-retry

Stop retrying to connect on permanent failure
Chris Bannister 9 年之前
父节点
当前提交
9924437647
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 1 0
      AUTHORS
  2. 7 0
      connectionpool.go

+ 1 - 0
AUTHORS

@@ -69,3 +69,4 @@ Alexander Inozemtsev <alexander.inozemtsev@gmail.com>
 Rob McColl <rob@robmccoll.com>; <rmccoll@ionicsecurity.com>
 Viktor Tönköl <viktor.toenkoel@motionlogic.de>
 Ian Lozinski <ian.lozinski@gmail.com>
+Michael Highstead <highstead@gmail.com>

+ 7 - 0
connectionpool.go

@@ -481,6 +481,13 @@ func (pool *hostConnPool) connect() (err error) {
 		if err == nil {
 			break
 		}
+		if opErr, isOpErr := err.(*net.OpError); isOpErr {
+			// if the error is not a temporary error (ex: network unreachable) don't
+			//  retry
+			if !opErr.Temporary() {
+				break
+			}
+		}
 	}
 
 	if err != nil {