Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dotnet/diagnostics into dev…
Browse files Browse the repository at this point in the history
…/jander/ipc-async
  • Loading branch information
jander-msft committed Jun 25, 2021
2 parents 06f6967 + 9ddcba5 commit 027080a
Show file tree
Hide file tree
Showing 12 changed files with 851 additions and 100 deletions.
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@
<Sha>7f13798e5f567b72ffe63205bf49839245f0f8c1</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.0-preview.7.21319.2">
<Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.0-preview.7.21323.6">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>a9a6831a1a0aa2fc21c276e1f28b86a2b1cdbb28</Sha>
<Sha>7b28c2b572cf32cf3c874d637ca8337a3b459830</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="6.0.0-preview.7.21319.2">
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="6.0.0-preview.7.21323.6">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>a9a6831a1a0aa2fc21c276e1f28b86a2b1cdbb28</Sha>
<Sha>7b28c2b572cf32cf3c874d637ca8337a3b459830</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-preview.7.21321.2">
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.0-preview.7.21324.1">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f891033db5b8ebf651176a3dcc3bec74a217f85e</Sha>
<Sha>7833828914a42f8c99dfa6f18ccd47f99dc2b56e</Sha>
</Dependency>
<Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.6.0" Version="6.0.0-preview.7.21321.2">
<Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.6.0" Version="6.0.0-preview.7.21324.1">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f891033db5b8ebf651176a3dcc3bec74a217f85e</Sha>
<Sha>7833828914a42f8c99dfa6f18ccd47f99dc2b56e</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<MicrosoftNETCoreApp50Version>5.0.6</MicrosoftNETCoreApp50Version>
<MicrosoftAspNetCoreApp50Version>$(MicrosoftNETCoreApp50Version)</MicrosoftAspNetCoreApp50Version>
<!-- Latest shared runtime version updated by darc -->
<VSRedistCommonNetCoreSharedFrameworkx6460Version>6.0.0-preview.7.21321.2</VSRedistCommonNetCoreSharedFrameworkx6460Version>
<MicrosoftNETCoreAppRuntimewinx64Version>6.0.0-preview.7.21321.2</MicrosoftNETCoreAppRuntimewinx64Version>
<VSRedistCommonNetCoreSharedFrameworkx6460Version>6.0.0-preview.7.21324.1</VSRedistCommonNetCoreSharedFrameworkx6460Version>
<MicrosoftNETCoreAppRuntimewinx64Version>6.0.0-preview.7.21324.1</MicrosoftNETCoreAppRuntimewinx64Version>
<!-- Latest shared aspnetcore version updated by darc -->
<MicrosoftAspNetCoreAppRefInternalVersion>6.0.0-preview.7.21319.2</MicrosoftAspNetCoreAppRefInternalVersion>
<MicrosoftAspNetCoreAppRefVersion>6.0.0-preview.7.21319.2</MicrosoftAspNetCoreAppRefVersion>
<MicrosoftAspNetCoreAppRefInternalVersion>6.0.0-preview.7.21323.6</MicrosoftAspNetCoreAppRefInternalVersion>
<MicrosoftAspNetCoreAppRefVersion>6.0.0-preview.7.21323.6</MicrosoftAspNetCoreAppRefVersion>
<!-- dotnet/installer: Testing version of the SDK. Needed for the signed & entitled host. -->
<MicrosoftDotnetSdkInternalVersion>6.0.100-preview.1.21103.13</MicrosoftDotnetSdkInternalVersion>
</PropertyGroup>
Expand Down
13 changes: 2 additions & 11 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ case $CPUName in
__HostArch=x86
;;

x86_64)
x86_64|amd64)
__BuildArch=x64
__HostArch=x64
;;
Expand Down Expand Up @@ -259,7 +259,7 @@ while :; do
-clang*)
__Compiler=clang
# clangx.y or clang-x.y
version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
version="$(echo "$1" | tr -d '[:alpha:]-=')"
parts=(${version//./ })
__ClangMajorVersion="${parts[0]}"
__ClangMinorVersion="${parts[1]}"
Expand Down Expand Up @@ -433,15 +433,6 @@ if [ "$__HostOS" == "OSX" ]; then

export MACOSX_DEPLOYMENT_TARGET=10.12

# If Xcode 9.2 exists (like on the CI/build machines), use that. Xcode 9.3 or
# greater (swift 4.1 lldb) doesn't work that well (seg faults on exit).
if [ -f "/Applications/Xcode_9.2.app/Contents/Developer/usr/bin/lldb" ]; then
if [ -f "/Applications/Xcode_9.2.app/Contents/SharedFrameworks/LLDB.framework/LLDB" ]; then
export LLDB_PATH=/Applications/Xcode_9.2.app/Contents/Developer/usr/bin/lldb
export LLDB_LIB=/Applications/Xcode_9.2.app/Contents/SharedFrameworks/LLDB.framework/LLDB
fi
fi

if [ ! -f $LLDB_LIB ]; then
echo "Cannot find the lldb library. Try installing Xcode."
exit 1
Expand Down
6 changes: 5 additions & 1 deletion eng/common/native/find-native-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ check_version_exists() {
desired_version="$1$2"
elif command -v "$compiler-$1$2" > /dev/null; then
desired_version="-$1$2"
elif command -v "$compiler$1" > /dev/null; then
desired_version="$1"
elif command -v "$compiler-$1" > /dev/null; then
desired_version="-$1"
fi

echo "$desired_version"
Expand All @@ -55,7 +59,7 @@ if [ -z "$CLR_CC" ]; then
# Set default versions
if [ -z "$majorVersion" ]; then
# note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
if [ "$compiler" = "clang" ]; then versions=( 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
if [ "$compiler" = "clang" ]; then versions=( 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
elif [ "$compiler" = "gcc" ]; then versions=( 9 8 7 6 5 4.9 ); fi

for version in "${versions[@]}"; do
Expand Down
6 changes: 6 additions & 0 deletions eng/gen-buildsys-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ elif command -v "clang$2$3" > /dev/null
elif command -v "clang-$2$3" > /dev/null
then
desired_llvm_version="-$2$3"
elif command -v "clang-$2" > /dev/null
then
desired_llvm_version="-$2"
elif command -v "clang$2" > /dev/null
then
desired_llvm_version="$2"
elif command -v clang > /dev/null
then
desired_llvm_version=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected bool IsCompletedSuccessfully(Task t)
/// </summary>
internal class TcpServerRouterFactory : IIpcServerTransportCallbackInternal
{
readonly ILogger _logger;
protected readonly ILogger _logger;

string _tcpServerAddress;

Expand All @@ -177,6 +177,13 @@ public string TcpServerAddress
get { return _tcpServerAddress; }
}

public delegate TcpServerRouterFactory CreateInstanceDelegate(string tcpServer, int runtimeTimeoutMs, ILogger logger);

public static TcpServerRouterFactory CreateDefaultInstance(string tcpServer, int runtimeTimeoutMs, ILogger logger)
{
return new TcpServerRouterFactory(tcpServer, runtimeTimeoutMs, logger);
}

public TcpServerRouterFactory(string tcpServer, int runtimeTimeoutMs, ILogger logger)
{
_logger = logger;
Expand All @@ -192,12 +199,12 @@ public TcpServerRouterFactory(string tcpServer, int runtimeTimeoutMs, ILogger lo
_tcpServer.TransportCallback = this;
}

public void Start()
public virtual void Start()
{
_tcpServer.Start();
}

public async Task Stop()
public virtual async Task Stop()
{
await _tcpServer.DisposeAsync().ConfigureAwait(false);
}
Expand Down Expand Up @@ -281,15 +288,22 @@ public void CreatedNewServer(EndPoint localEP)
/// </summary>
internal class TcpClientRouterFactory
{
readonly ILogger _logger;
protected readonly ILogger _logger;

readonly string _tcpClientAddress;
protected readonly string _tcpClientAddress;

bool _auto_shutdown;
protected bool _auto_shutdown;

protected int TcpClientTimeoutMs { get; set; } = Timeout.Infinite;

int TcpClientTimeoutMs { get; set; } = Timeout.Infinite;
protected int TcpClientRetryTimeoutMs { get; set; } = 500;

int TcpClientRetryTimeoutMs { get; set; } = 500;
public delegate TcpClientRouterFactory CreateInstanceDelegate(string tcpClient, int runtimeTimeoutMs, ILogger logger);

public static TcpClientRouterFactory CreateDefaultInstance(string tcpClient, int runtimeTimeoutMs, ILogger logger)
{
return new TcpClientRouterFactory(tcpClient, runtimeTimeoutMs, logger);
}

public string TcpClientAddress {
get { return _tcpClientAddress; }
Expand All @@ -304,7 +318,7 @@ public TcpClientRouterFactory(string tcpClient, int runtimeTimeoutMs, ILogger lo
TcpClientTimeoutMs = runtimeTimeoutMs;
}

public async Task<Stream> ConnectTcpStreamAsync(CancellationToken token)
public virtual async Task<Stream> ConnectTcpStreamAsync(CancellationToken token)
{
Stream tcpClientStream = null;

Expand Down Expand Up @@ -368,6 +382,14 @@ public async Task<Stream> ConnectTcpStreamAsync(CancellationToken token)
return tcpClientStream;
}

public virtual void Start()
{
}

public virtual void Stop()
{
}

async Task ConnectAsyncInternal(Socket clientSocket, EndPoint remoteEP, CancellationToken token)
{
using (token.Register(() => clientSocket.Close(0)))
Expand Down Expand Up @@ -597,10 +619,10 @@ internal class IpcServerTcpServerRouterFactory : DiagnosticsServerRouterFactory
TcpServerRouterFactory _tcpServerRouterFactory;
IpcServerRouterFactory _ipcServerRouterFactory;

public IpcServerTcpServerRouterFactory(string ipcServer, string tcpServer, int runtimeTimeoutMs, ILogger logger)
public IpcServerTcpServerRouterFactory(string ipcServer, string tcpServer, int runtimeTimeoutMs, TcpServerRouterFactory.CreateInstanceDelegate factory, ILogger logger)
{
_logger = logger;
_tcpServerRouterFactory = new TcpServerRouterFactory(tcpServer, runtimeTimeoutMs, logger);
_tcpServerRouterFactory = factory(tcpServer, runtimeTimeoutMs, logger);
_ipcServerRouterFactory = new IpcServerRouterFactory(ipcServer, logger);
}

Expand Down Expand Up @@ -638,6 +660,7 @@ public override void Start()

public override Task Stop()
{
_logger?.LogInformation($"Stopping IPC server ({_ipcServerRouterFactory.IpcServerPath}) <--> TCP server ({_tcpServerRouterFactory.TcpServerAddress}) router.");
_ipcServerRouterFactory.Stop();
return _tcpServerRouterFactory.Stop();
}
Expand Down Expand Up @@ -786,11 +809,11 @@ internal class IpcServerTcpClientRouterFactory : DiagnosticsServerRouterFactory
IpcServerRouterFactory _ipcServerRouterFactory;
TcpClientRouterFactory _tcpClientRouterFactory;

public IpcServerTcpClientRouterFactory(string ipcServer, string tcpClient, int runtimeTimeoutMs, ILogger logger)
public IpcServerTcpClientRouterFactory(string ipcServer, string tcpClient, int runtimeTimeoutMs, TcpClientRouterFactory.CreateInstanceDelegate factory, ILogger logger)
{
_logger = logger;
_ipcServerRouterFactory = new IpcServerRouterFactory(ipcServer, logger);
_tcpClientRouterFactory = new TcpClientRouterFactory(tcpClient, runtimeTimeoutMs, logger);
_tcpClientRouterFactory = factory(tcpClient, runtimeTimeoutMs, logger);
}

public override string IpcAddress
Expand Down Expand Up @@ -820,11 +843,14 @@ public override ILogger Logger
public override void Start()
{
_ipcServerRouterFactory.Start();
_tcpClientRouterFactory.Start();
_logger?.LogInformation($"Starting IPC server ({_ipcServerRouterFactory.IpcServerPath}) <--> TCP client ({_tcpClientRouterFactory.TcpClientAddress}) router.");
}

public override Task Stop()
{
_logger?.LogInformation($"Stopping IPC server ({_ipcServerRouterFactory.IpcServerPath}) <--> TCP client ({_tcpClientRouterFactory.TcpClientAddress}) router.");
_tcpClientRouterFactory.Stop();
_ipcServerRouterFactory.Stop();
return Task.CompletedTask;
}
Expand Down Expand Up @@ -905,11 +931,11 @@ internal class IpcClientTcpServerRouterFactory : DiagnosticsServerRouterFactory
IpcClientRouterFactory _ipcClientRouterFactory;
TcpServerRouterFactory _tcpServerRouterFactory;

public IpcClientTcpServerRouterFactory(string ipcClient, string tcpServer, int runtimeTimeoutMs, ILogger logger)
public IpcClientTcpServerRouterFactory(string ipcClient, string tcpServer, int runtimeTimeoutMs, TcpServerRouterFactory.CreateInstanceDelegate factory, ILogger logger)
{
_logger = logger;
_ipcClientRouterFactory = new IpcClientRouterFactory(ipcClient, logger);
_tcpServerRouterFactory = new TcpServerRouterFactory(tcpServer, runtimeTimeoutMs, logger);
_tcpServerRouterFactory = factory(tcpServer, runtimeTimeoutMs, logger);
}

public override string IpcAddress
Expand Down Expand Up @@ -944,6 +970,7 @@ public override void Start()

public override Task Stop()
{
_logger?.LogInformation($"Stopping IPC client ({_ipcClientRouterFactory.IpcClientPath}) <--> TCP server ({_tcpServerRouterFactory.TcpServerAddress}) router.");
return _tcpServerRouterFactory.Stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ internal interface Callbacks
void OnRouterStopped();
}

public static async Task<int> runIpcClientTcpServerRouter(CancellationToken token, string ipcClient, string tcpServer, int runtimeTimeoutMs, ILogger logger, Callbacks callbacks)
public static async Task<int> runIpcClientTcpServerRouter(CancellationToken token, string ipcClient, string tcpServer, int runtimeTimeoutMs, TcpServerRouterFactory.CreateInstanceDelegate tcpServerRouterFactory, ILogger logger, Callbacks callbacks)
{
return await runRouter(token, new IpcClientTcpServerRouterFactory(ipcClient, tcpServer, runtimeTimeoutMs, logger), callbacks).ConfigureAwait(false);
return await runRouter(token, new IpcClientTcpServerRouterFactory(ipcClient, tcpServer, runtimeTimeoutMs, tcpServerRouterFactory, logger), callbacks).ConfigureAwait(false);
}

public static async Task<int> runIpcServerTcpServerRouter(CancellationToken token, string ipcServer, string tcpServer, int runtimeTimeoutMs, ILogger logger, Callbacks callbacks)
public static async Task<int> runIpcServerTcpServerRouter(CancellationToken token, string ipcServer, string tcpServer, int runtimeTimeoutMs, TcpServerRouterFactory.CreateInstanceDelegate tcpServerRouterFactory, ILogger logger, Callbacks callbacks)
{
return await runRouter(token, new IpcServerTcpServerRouterFactory(ipcServer, tcpServer, runtimeTimeoutMs, logger), callbacks).ConfigureAwait(false);
return await runRouter(token, new IpcServerTcpServerRouterFactory(ipcServer, tcpServer, runtimeTimeoutMs, tcpServerRouterFactory, logger), callbacks).ConfigureAwait(false);
}

public static async Task<int> runIpcServerTcpClientRouter(CancellationToken token, string ipcServer, string tcpClient, int runtimeTimeoutMs, ILogger logger, Callbacks callbacks)
public static async Task<int> runIpcServerTcpClientRouter(CancellationToken token, string ipcServer, string tcpClient, int runtimeTimeoutMs, TcpClientRouterFactory.CreateInstanceDelegate tcpClientRouterFactory, ILogger logger, Callbacks callbacks)
{
return await runRouter(token, new IpcServerTcpClientRouterFactory(ipcServer, tcpClient, runtimeTimeoutMs, logger), callbacks).ConfigureAwait(false);
return await runRouter(token, new IpcServerTcpClientRouterFactory(ipcServer, tcpClient, runtimeTimeoutMs, tcpClientRouterFactory, logger), callbacks).ConfigureAwait(false);
}

public static bool isLoopbackOnly(string address)
Expand Down
Loading

0 comments on commit 027080a

Please sign in to comment.