Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If requestTLS fails, a PostgresConnection will be leaked, which asserts. #133

Closed
Lukasa opened this issue Nov 23, 2020 · 0 comments · Fixed by #134
Closed

If requestTLS fails, a PostgresConnection will be leaked, which asserts. #133

Lukasa opened this issue Nov 23, 2020 · 0 comments · Fixed by #134
Labels
bug Something isn't working

Comments

@Lukasa
Copy link

Lukasa commented Nov 23, 2020

A client requesting TLS will hit this branch of code:

}.flatMap { (conn: PostgresConnection) in
if let tlsConfiguration = tlsConfiguration {
return conn.requestTLS(
using: tlsConfiguration,
serverHostname: serverHostname,
logger: logger
).map { conn }
} else {
return eventLoop.makeSucceededFuture(conn)
}
}

If the requestTLS call fails, the returned future will be failed. This will send us down an error path, meaning the PostgresConnection will never make it to user code. However, the PostgresConnection is not closed on that path: nothing in here closes the connection. This triggers the assert in deinit:

deinit {
assert(self.isClosed, "PostgresConnection deinitialized before being closed.")
}

This should be handled more gracefully, by closing the connection on error.

@Lukasa Lukasa added the bug Something isn't working label Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant