Skip to content

Commit d21edf3

Browse files
committed
Dont increment count until pop succeeds, fixes #167
1 parent d72b5f5 commit d21edf3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/connection_pool.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ def checkout(**options)
154154
::Thread.current[@key_count] += 1
155155
::Thread.current[@key]
156156
else
157+
conn = @available.pop(timeout: options.fetch(:timeout, @timeout), **options)
158+
::Thread.current[@key] = conn
157159
::Thread.current[@key_count] = 1
158-
::Thread.current[@key] = @available.pop(timeout: options.fetch(:timeout, @timeout), **options)
160+
conn
159161
end
160162
end
161163

0 commit comments

Comments
 (0)