From 0d19f645e8055b6d1fda2e58430b4844e930ce50 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 17 Jan 2016 19:22:43 +0100 Subject: [PATCH] Fixed: Don't apply indexer backoff on DNS and connection issues. Fixes #751 --- src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 11 ++++++++++- .../Indexers/IndexerStatusService.cs | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index f7713faa8..ad89cf3c7 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -202,7 +202,16 @@ namespace NzbDrone.Core.Indexers } catch (WebException webException) { - _indexerStatusService.RecordFailure(Definition.Id); + if (webException.Status == WebExceptionStatus.NameResolutionFailure || + webException.Status == WebExceptionStatus.ConnectFailure) + { + _indexerStatusService.RecordConnectionFailure(Definition.Id); + } + else + { + _indexerStatusService.RecordFailure(Definition.Id); + } + if (webException.Message.Contains("502") || webException.Message.Contains("503") || webException.Message.Contains("timed out")) { diff --git a/src/NzbDrone.Core/Indexers/IndexerStatusService.cs b/src/NzbDrone.Core/Indexers/IndexerStatusService.cs index 5a43638ee..ed977cb2f 100644 --- a/src/NzbDrone.Core/Indexers/IndexerStatusService.cs +++ b/src/NzbDrone.Core/Indexers/IndexerStatusService.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Core.Indexers ReleaseInfo GetLastRssSyncReleaseInfo(int indexerId); void RecordSuccess(int indexerId); void RecordFailure(int indexerId, TimeSpan minimumBackOff = default(TimeSpan)); + void RecordConnectionFailure(int indexerId); void UpdateRssSyncStatus(int indexerId, ReleaseInfo releaseInfo); } @@ -85,7 +86,7 @@ namespace NzbDrone.Core.Indexers } } - public void RecordFailure(int indexerId, TimeSpan minimumBackOff = default(TimeSpan)) + protected void RecordFailure(int indexerId, TimeSpan minimumBackOff, bool escalate) { lock (_syncRoot) { @@ -99,7 +100,10 @@ namespace NzbDrone.Core.Indexers } status.MostRecentFailure = now; - status.EscalationLevel = Math.Min(MaximumEscalationLevel, status.EscalationLevel + 1); + if (escalate) + { + status.EscalationLevel = Math.Min(MaximumEscalationLevel, status.EscalationLevel + 1); + } if (minimumBackOff != TimeSpan.Zero) { @@ -115,6 +119,17 @@ namespace NzbDrone.Core.Indexers } } + public void RecordFailure(int indexerId, TimeSpan minimumBackOff = default(TimeSpan)) + { + RecordFailure(indexerId, minimumBackOff, true); + } + + public void RecordConnectionFailure(int indexerId) + { + RecordFailure(indexerId, default(TimeSpan), false); + } + + public void UpdateRssSyncStatus(int indexerId, ReleaseInfo releaseInfo) { lock (_syncRoot)