mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Ensure IPv6 property is threadsafe.
This commit is contained in:
parent
c9a387943f
commit
6c479dfb36
@ -35,6 +35,11 @@ namespace Jellyfin.Networking.HappyEyeballs
|
|||||||
{
|
{
|
||||||
private const int ConnectionEstablishTimeout = 2000;
|
private const int ConnectionEstablishTimeout = 2000;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interlocked doesn't support bool types.
|
||||||
|
/// </summary>
|
||||||
|
private static int _useIPv6 = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the initial IPv6 check has been performed (to determine whether v6 is available or not).
|
/// Gets a value indicating whether the initial IPv6 check has been performed (to determine whether v6 is available or not).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -43,7 +48,21 @@ namespace Jellyfin.Networking.HappyEyeballs
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether IPv6 should be preferred. Value may change based on runtime failures.
|
/// Gets or sets a value indicating whether IPv6 should be preferred. Value may change based on runtime failures.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool? UseIPv6 { get; set; } = null;
|
public static bool UseIPv6
|
||||||
|
{
|
||||||
|
get => Interlocked.CompareExchange(ref _useIPv6, 1, 1) == 1;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
Interlocked.CompareExchange(ref _useIPv6, 1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Interlocked.CompareExchange(ref _useIPv6, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements the httpclient callback method.
|
/// Implements the httpclient callback method.
|
||||||
@ -56,7 +75,7 @@ namespace Jellyfin.Networking.HappyEyeballs
|
|||||||
// Until .NET supports an implementation of Happy Eyeballs (https://tools.ietf.org/html/rfc8305#section-2),
|
// Until .NET supports an implementation of Happy Eyeballs (https://tools.ietf.org/html/rfc8305#section-2),
|
||||||
// let's make IPv4 fallback work in a simple way. This issue is being tracked at https://github.com/dotnet/runtime/issues/26177
|
// let's make IPv4 fallback work in a simple way. This issue is being tracked at https://github.com/dotnet/runtime/issues/26177
|
||||||
// and expected to be fixed in .NET 6.
|
// and expected to be fixed in .NET 6.
|
||||||
if (UseIPv6 == true)
|
if (UseIPv6)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user