Making max pipe length platform-dependant

This commit is contained in:
Tomas Urbonaitis 2019-07-10 18:00:10 +03:00
Родитель 09decc7ba5
Коммит 0ee99fa889
6 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -138,6 +138,7 @@ namespace GVFS.Common
public abstract class GVFSPlatformConstants
{
public static readonly char PathSeparator = Path.DirectorySeparatorChar;
public abstract int MaxPipePathLength { get; }
public abstract string ExecutableExtension { get; }
public abstract string InstallerExtension { get; }

Просмотреть файл

@ -22,10 +22,6 @@ namespace GVFS.Common.NamedPipes
/// </summary>
public class NamedPipeServer : IDisposable
{
// TODO(Mac) the limit is much shorter on macOS
// Tests show that 250 is the max supported pipe name length
private const int MaxPipeNameLength = 250;
private bool isStopping;
private string pipeName;
private Action<Connection> handleConnection;
@ -43,9 +39,9 @@ namespace GVFS.Common.NamedPipes
public static NamedPipeServer StartNewServer(string pipeName, ITracer tracer, Action<ITracer, string, Connection> handleRequest)
{
if (pipeName.Length > MaxPipeNameLength)
if (pipeName.Length > GVFSPlatform.Instance.Constants.MaxPipePathLength)
{
throw new PipeNameLengthException(string.Format("The pipe name ({0}) exceeds the max length allowed({1})", pipeName, MaxPipeNameLength));
throw new PipeNameLengthException(string.Format("The pipe name ({0}) exceeds the max length allowed({1})", pipeName, GVFSPlatform.Instance.Constants.MaxPipePathLength));
}
NamedPipeServer pipeServer = new NamedPipeServer(pipeName, tracer, connection => HandleConnection(tracer, connection, handleRequest));

Просмотреть файл

@ -167,6 +167,8 @@ namespace GVFS.Platform.Mac
{
get { return "vfsforgit"; }
}
public override int MaxPipePathLength => 104;
}
}
}

Просмотреть файл

@ -298,6 +298,8 @@ namespace GVFS.Platform.POSIX
}
public override bool SupportsUpgradeWhileRunning => true;
public override int MaxPipePathLength => 108;
}
}
}

Просмотреть файл

@ -490,6 +490,8 @@ namespace GVFS.Platform.Windows
{
get { return new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "GVFS", "GVFS.Mount", "git", "ssh-agent", "wish", "bash" }; }
}
public override int MaxPipePathLength => 250;
}
}
}

Просмотреть файл

@ -235,6 +235,8 @@ namespace GVFS.UnitTests.Mock.Common
}
public override bool SupportsUpgradeWhileRunning => false;
public override int MaxPipePathLength => 250;
}
}
}