Skip to content

Commit

Permalink
Relieve unwanted pressure on the web socket wrapper queue that caused…
Browse files Browse the repository at this point in the history
… huge memory spikes (this loop would be very fast and cause tons of actions to be scheduled when there should be none). Issue #990
  • Loading branch information
borrrden committed Mar 12, 2018
1 parent d8e7646 commit c18ebea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Couchbase.Lite.Shared/Sync/WebSocketWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ private void PerformRead()

// Phew, at this point we are clear to actually read from the stream
var received = stream.Read(_buffer, 0, _buffer.Length);
if (received == 0) {
// Should only happen on a closed stream, but just in case let's continue
// after a small delay (wait for cancellation to confirm)
Thread.Sleep(200);
continue;
}

var data = _buffer.Take(received).ToArray();
Receive(data);
} catch (Exception e) {
Expand Down

0 comments on commit c18ebea

Please sign in to comment.