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

SWIFT-1347 Fix memory leak in tests caused by ClientSession.pinnedServerAddress #675

Merged
merged 1 commit into from Sep 13, 2021

Conversation

kmahar
Copy link
Contributor

@kmahar kmahar commented Sep 13, 2021

As discovered via adding leaks to CI in my other PR. After this gets merged in I will rebase over there to get the new tasks passing.

@@ -94,8 +94,11 @@ public final class ClientSession {
return nil
}
return connection.withMongocConnection { client in
let serverDescription =
ServerDescription(mongoc_client_get_server_description(client, serverID))
guard let sd = mongoc_client_get_server_description(client, serverID) else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand why, but if the result of mongoc_client_get_server_description is passed directly into the ServerDescription initializer it doesn't need to be unwrapped. But if I assign it to a variable like this then I have to unwrap it to be able to pass it in.

This evolution proposal explains why the pointer is optional in the first place, and makes sense, but it doesn't make much sense to me that it gets coerced into a non-optional by passing it directly to the initializer... 🤷‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, yeah not sure what's going on there either.

@@ -94,8 +94,11 @@ public final class ClientSession {
return nil
}
return connection.withMongocConnection { client in
let serverDescription =
ServerDescription(mongoc_client_get_server_description(client, serverID))
guard let sd = mongoc_client_get_server_description(client, serverID) else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, yeah not sure what's going on there either.

@kmahar
Copy link
Contributor Author

kmahar commented Sep 13, 2021

(test failure is an unrelated issue caused by a server change, see my message in driver-devs)

@kmahar kmahar merged commit 53bc92d into main Sep 13, 2021
@kmahar kmahar deleted the fix-leaks branch September 13, 2021 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants