Skip to content

Commit

Permalink
Set callback after write can cause callback being skipped
Browse files Browse the repository at this point in the history
When didWriteDataWithTag is called but callback is not yet pushed to
pendingSends dictionary, it will be skipped and cause stream to hang
forever.
  • Loading branch information
snoyiatk authored and aprock committed Aug 16, 2017
1 parent ea1bb2e commit 95846a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ios/TcpSocketClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)msgTag
- (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++;

Expand Down

0 comments on commit 95846a7

Please sign in to comment.