Set callback after write can cause callback being skipped

When didWriteDataWithTag is called but callback is not yet pushed to
pendingSends dictionary, it will be skipped and cause stream to hang
forever.
This commit is contained in:
Snoy 2017-08-06 19:09:30 +07:00 committed by Andy Prock
parent ea1bb2e8a7
commit 95846a71fc
1 changed files with 1 additions and 1 deletions

View File

@ -180,10 +180,10 @@ NSString *const RCTTCPErrorDomain = @"RCTTCPErrorDomain";
- (void) writeData:(NSData *)data
callback:(RCTResponseSenderBlock)callback
{
[_tcpSocket writeData:data withTimeout:-1 tag:_sendTag];
if (callback) {
[self setPendingSend:callback forKey:@(_sendTag)];
}
[_tcpSocket writeData:data withTimeout:-1 tag:_sendTag];
_sendTag++;