Skip to content

Commit 88bd6ad

Browse files
committed
Handle channel read timeouts and EOF behavior in ChannelReader
1 parent 4ba8706 commit 88bd6ad

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/NullOpsDevs.LibSsh/Core/ChannelReader.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ public static unsafe long CopyToStream(_LIBSSH2_CHANNEL* channel, int streamId,
8181
{
8282
break;
8383
}
84+
else if (bytesRead == LibSshNative.LIBSSH2_ERROR_TIMEOUT)
85+
{
86+
// Timeout in blocking mode - check if channel actually has EOF
87+
if (LibSshNative.libssh2_channel_eof(channel) == 1)
88+
break;
89+
90+
// No EOF yet - wait and retry
91+
Thread.Sleep(300);
92+
}
93+
// Other errors - stop reading
94+
else
95+
{
96+
break;
97+
}
8498
}
8599

86100
return totalBytesRead;

0 commit comments

Comments
 (0)