Dealloc safety improvement

Summary:
From a different diff, it was pointed out that calling methods on self are discouraged:

Generally you want to avoid calling methods on self in dealloc because it allows you to accidentally capture references to self in dealloc, which leads to zombies.

In this case, a disconnect effectively invalidates a timer and disconnect the underlying socket. Both take place either way when the members are deallocated too. The only thing is not done is notify the caller via the event handler of a close event.

In our case, the caller actually manually disconnects before deallocating so this is not an issue.

Reviewed By: fabiomassimo

Differential Revision: D35547600

fbshipit-source-id: 9b5b9892b657a69585943613bc81344b38dbef30
This commit is contained in:
Lorenzo Blasa
2022-04-12 02:30:02 -07:00
committed by Facebook GitHub Bot
parent fd2d7bc1a4
commit 30a1d09a83

View File

@@ -135,10 +135,6 @@ static constexpr int connectionKeepaliveSeconds = 10;
return self; return self;
} }
- (void)dealloc {
[self disconnect];
}
- (void)connect { - (void)connect {
if (_socket) { if (_socket) {
return; return;