We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f8872f commit 50425d0Copy full SHA for 50425d0
GCD/GCDAsyncSocket.m
@@ -4371,10 +4371,20 @@ - (void)doReadData
4371
{
4372
bytesRead = result;
4373
4374
- if (socketFDBytesAvailable <= bytesRead)
+ if (bytesRead < bytesToRead)
4375
+ {
4376
+ // The read returned less data than requested.
4377
+ // This means socketFDBytesAvailable was a bit off due to timing,
4378
+ // because we read from the socket right when the readSource event was firing.
4379
socketFDBytesAvailable = 0;
4380
+ }
4381
else
- socketFDBytesAvailable -= bytesRead;
4382
4383
+ if (socketFDBytesAvailable <= bytesRead)
4384
+ socketFDBytesAvailable = 0;
4385
+ else
4386
+ socketFDBytesAvailable -= bytesRead;
4387
4388
4389
if (socketFDBytesAvailable == 0)
4390
0 commit comments