-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
fix promise leak #57
Conversation
@@ -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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
thanks @tanner0101 |
Fixes a promise leak caused by chaining the request completion promise to the channel write.