vapor / async-kit

Sugary extensions for the SwiftNIO library
MIT License
71 stars 25 forks source link

add ConnectionPool.close() + fix connect error bug #35

Closed tanner0101 closed 5 years ago

tanner0101 commented 5 years ago

This PR adds a new close() method to ConnectionPool. This method is used to close all of the pool's active connections. In Vapor 4, connections must be closed before they deinitialize to ensure no memory is leaked. This change allows for connections created from a pool to follow this rule.

To help catch bugs early, connection pool will behave similarly to connections and cause an assertion failure if it deinitializes without being closed first.

Some other notes:

I noticed that flatten() to EventLoopFuture<Void> was missing, so I added it.

There was a bug that caused connect failures to increment the active connection count without returning a connection. This has been fixed by decrementing the active connection count if creating a connection ever fails.

penny-coin commented 5 years ago

Hey @tanner0101, you just merged a pull request, have a coin!

You now have 1158 coins.