Skip to content

fix promise leak #57

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

Merged
merged 3 commits into from
Nov 18, 2019
Merged

fix promise leak #57

merged 3 commits into from
Nov 18, 2019

Conversation

tanner0101
Copy link
Member

@tanner0101 tanner0101 commented Nov 7, 2019

Fixes a promise leak caused by chaining the request completion promise to the channel write.

@tanner0101 tanner0101 added the bug Something isn't working label Nov 7, 2019
@@ -5,7 +5,7 @@ extension PostgresConnection: PostgresClient {
request.log(to: self.logger)
let promise = self.channel.eventLoop.makePromise(of: Void.self)
let request = PostgresRequestContext(delegate: request, promise: promise)
self.channel.write(request).cascadeFailure(to: promise)
Copy link
Contributor

@weissi weissi Nov 7, 2019

Choose a reason for hiding this comment

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

hmm, I don't think this can fix a promise leak, right? If anything this will make it more likely that the promise is never fulfilled. Also, this is missing a test I think?

sorry, misunderstood you. I thought you meant you leaked the unfulfilled promise but I think you mean that the old code causes a memory leak involving the promise. I still don't think this change would make that go away. The reference to promise should be dropped as soon as the self.channel.write(request) future is either fulfilled or failed.

I really don't think this can fix a memory leak. It might however cause promise to be deallocated quicker as the new code doesn't keep it around until self.channel.write(request) future is done.

@@ -31,3 +31,20 @@ extension PostgresData {
}
}
}

extension Double: PostgresDataConvertible {
Copy link
Contributor

Choose a reason for hiding this comment

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

this and the change below seem unrelated?

@tomerd
Copy link

tomerd commented Nov 7, 2019

thanks @tanner0101

@tanner0101 tanner0101 merged commit 3f3b361 into master Nov 18, 2019
@tanner0101 tanner0101 deleted the tn-promise-leak branch November 18, 2019 18:47
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 this pull request may close these issues.

3 participants