Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeButters committed Jul 26, 2023
1 parent bd1b4dd commit fb22198
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion source/Halibut/Transport/Protocol/MessageSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public void WriteMessage<T>(Stream stream, T message)

public T ReadMessage<T>(Stream stream)
{
if (stream is StreamAndRecord streamAndRecord)
{
if (streamAndRecord.stream is IRewindableBuffer rewindable2)
{
return ReadCompressedMessageRewindable<T>(stream, rewindable2);
}
}

if (stream is IRewindableBuffer rewindable)
{
return ReadCompressedMessageRewindable<T>(stream, rewindable);
Expand Down Expand Up @@ -118,11 +126,24 @@ T ReadCompressedMessageRewindable<T>(Stream stream, IRewindableBuffer rewindable
var messageEnvelope = DeserializeMessage<T>(bson);

// May be needed with no compression
ReallyEndReading(zip);
//ReallyEndReading(zip);

// Find the unused bytes in the DeflateStream input buffer
if (deflateReflector.TryGetAvailableInputBufferSize(zip, out var unusedBytesCount))
{
if (unusedBytesCount == 0)
{
// Chance of a fix here:
var b = new byte[1024];
var res = zip.Read(b, 0, b.Length);
// Chance of fix END.
deflateReflector.TryGetAvailableInputBufferSize(zip, out unusedBytesCount);
if (unusedBytesCount != 0)
{
// Fix used.
}
}

rewindable.FinishAndRewind(unusedBytesCount);
}
else
Expand Down

0 comments on commit fb22198

Please sign in to comment.