(PUP-744) Ensure connections do not leak
Previously, the dummy and caching pools allowed the caller to take a
connection from the pool and retain ownership of the connection. This is
undesirable because if the caller encounters an exception while using
the connection, then they have to remember to close it, otherwise the
underlying socket will leak.
There is also the issue that a caller may forget to add it back to the
pool before the pool is closed, in which case the socket will again
leak.
This commit changes the api to a block form to ensure connections are
always returned to the pool or closed.
Note the reuse flag is used to ensure the connection is returned to
the pool even if the caller does a non-local return:
with_connection(..) { |conn| return }