Skip to content

Commit

Permalink
Cleanup proxy connect reference when socket is opened asynchronously.
Browse files Browse the repository at this point in the history
  • Loading branch information
nlutsenko committed Aug 22, 2016
1 parent fb14fc1 commit 02d04dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions SocketRocket/SRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ - (void)open

- (void)_connectionDoneWithError:(NSError *)error readStream:(NSInputStream *)readStream writeStream:(NSOutputStream *)writeStream
{
_proxyConnect = nil; // Job's done! This is not longer required.

if (error != nil) {
[self _failWithError:error];
} else {
Expand All @@ -350,6 +348,11 @@ - (void)_connectionDoneWithError:(NSError *)error readStream:(NSInputStream *)re
});
}
}
// Schedule to run on a work queue, to make sure we don't run this inline and deallocate `self` inside `SRProxyConnect`.
// TODO: (nlutsenko) Find a better structure for this, maybe Bolts Tasks?
dispatch_async(_workQueue, ^{
_proxyConnect = nil;
});
}

- (BOOL)_checkHandshake:(CFHTTPMessageRef)httpMessage;
Expand Down

0 comments on commit 02d04dc

Please sign in to comment.