The Free Software Media System - Server Backend & API
Fixed yet another case of hanging on a bad stream
Vasily3401d55f41ca
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.csindex f13b65722c..e41ced28b5 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs@@ -2,6 +2,7 @@using System;using System.Collections.Generic;+using System.Globalization;using System.IO;using System.Net.Http;using System.Threading;@@ -123,6 +124,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts// Error happened during opening the stream, re-raise the exception to inform the callerthrow taskCompletionSource.Task.Exception;}+ if (!taskCompletionSource.Task.Result)+ {+ Logger.LogWarning("Zero bytes copied from stream {0} to {1} but no exception raised", GetType().Name, TempFilePath);+ throw new EndOfStreamException(String.Format(CultureInfo.InvariantCulture,+ "Zero bytes copied from stream {0}",+ GetType().Name));+ }}private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)@@ -146,7 +154,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts}catch (OperationCanceledException ex){- Logger.LogWarning(ex, "Copying of {0} to {1} was canceled", GetType().Name, TempFilePath);+ Logger.LogInformation("Copying of {0} to {1} was canceled", GetType().Name, TempFilePath);openTaskCompletionSource.TrySetException(ex);}catch (Exception ex)@@ -154,6 +162,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHostsLogger.LogError(ex, "Error copying live stream {0} to {1}.", GetType().Name, TempFilePath);openTaskCompletionSource.TrySetException(ex);}+ openTaskCompletionSource.TrySetResult(false);EnableStreamSharing = false;await DeleteTempFiles(new List<string> { TempFilePath }).ConfigureAwait(false);