Skip to content

Commit 1629bfd

Browse files
committed
Fix problem which caused freeze when torrent-client wasn't working properly
1 parent b822385 commit 1629bfd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Assets/Scripts/Net/TorrentClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,22 @@ private string ReadCommandResult()
5252

5353
while (!str.ToString().EndsWith("#=end"))
5454
{
55+
ThrowIfProcessExited();
56+
5557
str.Append((char)_stdOutput.Read());
5658
}
5759

5860
return str.ToString().Substring(0, str.Length - 5);
5961
}
6062

63+
private void ThrowIfProcessExited()
64+
{
65+
if (_process.HasExited)
66+
{
67+
throw new Exception("torrent-client process has exited");
68+
}
69+
}
70+
6171
private StreamReader CreateStdOutputStream()
6272
{
6373
return new StreamReader(_process.StandardOutput.BaseStream, CreateStdEncoding());

0 commit comments

Comments
 (0)