Skip to content

Commit

Permalink
Adjust order of weakSelf
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Sep 29, 2018
1 parent 2d944ee commit 3a7d86d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Libraries/WebSocket/RCTSRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -1310,8 +1310,6 @@ - (void)_sendFrameWithOpcode:(RCTSROpCode)opcode data:(id)data;

- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode;
{
__weak typeof(self) wself = self;

if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) {
NSArray *sslCerts = _urlRequest.RCTSR_SSLPinnedCertificates;
if (sslCerts) {
Expand Down Expand Up @@ -1343,8 +1341,17 @@ - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode;
}
}

// _workQueue cannot be NULL
if (!_workQueue) {
return;
}
__weak typeof(self) weakSelf = self;
dispatch_async(_workQueue, ^{
[wself safeHandleEvent:eventCode stream:aStream];
typeof(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
[strongSelf safeHandleEvent:eventCode stream:aStream];
});
}

Expand Down

0 comments on commit 3a7d86d

Please sign in to comment.