THRIFT-5499: Use blocking Read/Write calls to make sure the Receive/SendTimeout is checked.

Client: netstd
This commit is contained in:
TeinRnD 2022-02-08 10:50:41 +01:00 committed by Jens Geyer
parent 0b29261a4f
commit 52d263e77c

View File

@ -80,11 +80,8 @@ namespace Thrift.Transport.Client
"Cannot read from null inputstream");
}
#if NETSTANDARD2_0
return await InputStream.ReadAsync(buffer, offset, length, cancellationToken);
#else
return await InputStream.ReadAsync(new Memory<byte>(buffer, offset, length), cancellationToken);
#endif
// The ReadAsync method should not be used since it does not check the ReceiveTimeout property.
return await Task.Run( () => InputStream.Read( buffer, offset, length ), cancellationToken );
}
public override async Task WriteAsync(byte[] buffer, int offset, int length, CancellationToken cancellationToken)
@ -95,11 +92,8 @@ namespace Thrift.Transport.Client
"Cannot write to null outputstream");
}
#if NETSTANDARD2_0
await OutputStream.WriteAsync(buffer, offset, length, cancellationToken);
#else
await OutputStream.WriteAsync(buffer.AsMemory(offset, length), cancellationToken);
#endif
// The WriteAsync method should not be used since it does not check the SendTimeout property.
await Task.Run( () => OutputStream.Write( buffer, offset, length ), cancellationToken );
}
public override async Task FlushAsync(CancellationToken cancellationToken)