aboutsummaryrefslogtreecommitdiff
path: root/client_test.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2020-11-06 12:00:12 +0100
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2020-11-06 12:00:12 +0100
commitdf87e7089a2518a51d1f3bf2a603c09292dcec7a (patch)
tree0d0c401582f326a9789494f2789e4733552fd05c /client_test.go
parentAdd ppc64le support (diff)
downloadfasthttp-df87e7089a2518a51d1f3bf2a603c09292dcec7a.tar.gz
fasthttp-df87e7089a2518a51d1f3bf2a603c09292dcec7a.tar.bz2
fasthttp-df87e7089a2518a51d1f3bf2a603c09292dcec7a.zip
Fix race condition in TestCloseIdleConnections
On really slow machines. when the test takes longer than 10 seconds, mCleaner can already delete the connection from the map before we check it again.
Diffstat (limited to 'client_test.go')
-rw-r--r--client_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/client_test.go b/client_test.go
index 95b102a..d29eb6e 100644
--- a/client_test.go
+++ b/client_test.go
@@ -47,6 +47,10 @@ func TestCloseIdleConnections(t *testing.T) {
c.mLock.Lock()
defer c.mLock.Unlock()
+ if _, ok := c.m["google.com"]; !ok {
+ return 0
+ }
+
c.m["google.com"].connsLock.Lock()
defer c.m["google.com"].connsLock.Unlock()