Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Foundation] Don't dispose the CancellationTokenSource in NSUrlSessionHandler's InflightData. Fixes #11799. #20328

Merged
Merged
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
19 changes: 1 addition & 18 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ void RemoveInflightData (NSUrlSessionTask task, bool cancel = true)
if (inflightRequests.TryGetValue (task, out var data)) {
if (cancel)
data.CancellationTokenSource.Cancel ();
data.Dispose ();
inflightRequests.Remove (task);
}
#if !MONOMAC && !__WATCHOS__ && !NET8_0
Expand All @@ -247,7 +246,6 @@ protected override void Dispose (bool disposing)
foreach (var pair in inflightRequests) {
pair.Key?.Cancel ();
pair.Key?.Dispose ();
pair.Value?.Dispose ();
}

inflightRequests.Clear ();
Expand Down Expand Up @@ -1130,7 +1128,7 @@ static bool TryGetAuthenticationType (NSUrlProtectionSpace protectionSpace, [Not
}
}

class InflightData : IDisposable {
class InflightData {
public readonly object Lock = new object ();
public string RequestUrl { get; set; }

Expand All @@ -1154,21 +1152,6 @@ public InflightData (string requestUrl, CancellationToken cancellationToken, Htt
CancellationToken = cancellationToken;
Request = request;
}

public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}

// The bulk of the clean-up code is implemented in Dispose(bool)
protected virtual void Dispose (bool disposing)
{
if (disposing) {
CancellationTokenSource.Dispose ();
}
}

}

class NSUrlSessionDataTaskStreamContent : MonoStreamContent {
Expand Down
Loading