Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Avoid unnecessary exception in TimeoutStream #1015

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/ClassLibraryCommon/Core/TimeoutStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private void StopTimeout(CancellationTokenSource source, bool dispose)

private void UpdateReadTimeout()
{
if (this.wrappedStream.CanTimeout)
if (this.wrappedStream.CanTimeout && this.wrappedStream.CanRead)
{
try
{
Expand All @@ -283,7 +283,7 @@ private void UpdateReadTimeout()

private void UpdateWriteTimeout()
{
if (this.wrappedStream.CanTimeout)
if (this.wrappedStream.CanTimeout && this.wrappedStream.CanWrite)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions Lib/WindowsRuntime/Core/TimeoutStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void StopTimeout(CancellationTokenSource source, bool dispose)

private void UpdateReadTimeout()
{
if (this.wrappedStream.CanTimeout)
if (this.wrappedStream.CanTimeout && this.wrappedStream.CanRead)
{
try
{
Expand All @@ -229,7 +229,7 @@ private void UpdateReadTimeout()

private void UpdateWriteTimeout()
{
if (this.wrappedStream.CanTimeout)
if (this.wrappedStream.CanTimeout && this.wrappedStream.CanWrite)
{
try
{
Expand Down