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

Sync feature/parameter-capturing/startup-hook #6780

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0bd813b
Update dependencies from https://github.com/dotnet/diagnostics build …
dotnet-maestro[bot] May 22, 2024
b22fa02
Validate IPC message commandset before acknowledging (#6699)
schmittjoseph May 22, 2024
cd0d6ad
Update dependencies from https://github.com/dotnet/arcade build 20240…
dotnet-maestro[bot] May 23, 2024
60ef6b8
[main] Update dependencies from dotnet/diagnostics (#6709)
dotnet-maestro[bot] May 25, 2024
ca21a9a
Update dependencies from https://github.com/dotnet/diagnostics build …
dotnet-maestro[bot] May 27, 2024
eadf419
Update dependencies from https://github.com/dotnet/diagnostics build …
dotnet-maestro[bot] May 28, 2024
37959c3
Exclude 7.3 from CG (#6716)
jander-msft May 28, 2024
12cc023
Configure request limits via DI (#6730)
schmittjoseph May 28, 2024
9fbb244
Add retries (#6747)
schmittjoseph May 30, 2024
47c7ad9
ParameterCapturingTests: Increase capture duration and set limit to 1…
clguiman May 30, 2024
0f27174
[main] Bump Microsoft.NETCore.DotNetHost in /eng/dependabot/net6.0 (#…
dependabot[bot] May 31, 2024
703a84a
[main] Bump Microsoft.NETCore.DotNetHost in /eng/dependabot/net7.0 (#…
dependabot[bot] May 31, 2024
3c31273
[main] Bump Microsoft.Identity.Web (#6738)
dependabot[bot] May 31, 2024
e5430b5
[main] Update dependencies from dotnet/diagnostics (#6759)
dotnet-maestro[bot] Jun 2, 2024
6a13c8f
[main] Bump Microsoft.NETCore.DotNetHost in /eng/dependabot/net8.0 (#…
dependabot[bot] Jun 3, 2024
4fb831d
Add documentation note about in-process features are only supported i…
AntonPalyok Jun 3, 2024
70f3537
Update dependencies from https://github.com/dotnet/diagnostics build …
dotnet-maestro[bot] Jun 4, 2024
3bcbcaf
Bump dawidd6/action-download-artifact from 3.1.4 to 5 (#6767)
dependabot[bot] Jun 4, 2024
f653b64
Update dependencies from https://github.com/dotnet/diagnostics build …
dotnet-maestro[bot] Jun 5, 2024
a17f33a
Merge branch 'main' into dev/clguiman/sync-startup-hook-feature-branch
clguiman Jun 5, 2024
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
3 changes: 3 additions & 0 deletions .github/linters/check-markdown-links-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
{
"pattern": "^https://www\\.dotnetfoundation.org/.*"
},
{
"pattern": "^https://hub\\.docker\\.com/.*"
}
],
"aliveStatusCodes": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-markdown-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
persist-credentials: false

- name: Check markdown links
uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368
uses: gaurav-nelson/github-action-markdown-link-check@7d83e59a57f3c201c76eed3d33dff64ec4452d27
with:
config-file: .github/linters/check-markdown-links-config.json
use-quiet-mode: 'yes'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/submit-linter-suggestions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# The default artifact download action doesn't support cross-workflow
# artifacts, so use a 3rd party one.
- name: 'Download linting results'
uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe
uses: dawidd6/action-download-artifact@deb3bb83256a78589fef6a7b942e5f2573ad7c13
with:
workflow: ${{env.workflow_name}}
run_id: ${{github.event.workflow_run.id }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/submit-to-do-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# The default artifact download action doesn't support cross-workflow
# artifacts, so use a 3rd party one.
- name: 'Download linting results'
uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe
uses: dawidd6/action-download-artifact@deb3bb83256a78589fef6a7b942e5f2573ad7c13
with:
workflow: ${{env.workflow_name}}
run_id: ${{github.event.workflow_run.id }}
Expand Down
4 changes: 2 additions & 2 deletions documentation/api/definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Object describing the basic state of a collection rule for the executing instanc

| Name | Type | Description |
|---|---|---|
| State | [CollectionRuleState](#collectionrulestate-63) | Indicates what state the collection rule is in for the current process. |
| State | [CollectionRuleState](#collectionrulestate) | Indicates what state the collection rule is in for the current process. |
| StateReason | string | Human-readable explanation for the current state of the collection rule. |

## CollectionRuleDetailedDescription
Expand All @@ -65,7 +65,7 @@ Object describing the detailed state of a collection rule for the executing inst

| Name | Type | Description |
|---|---|---|
| State | [CollectionRuleState](#collectionrulestate-63) | Indicates what state the collection rule is in for the current process. |
| State | [CollectionRuleState](#collectionrulestate) | Indicates what state the collection rule is in for the current process. |
| StateReason | string | Human-readable explanation for the current state of the collection rule. |
| LifetimeOccurrences | int | The number of times the trigger has executed for a process in its lifetime. |
| SlidingWindowOccurrences | int | The number of times the trigger has executed within the current sliding window. |
Expand Down
4 changes: 2 additions & 2 deletions documentation/api/stacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Allowed schemes:
### Sample Request

```http
GET /stack?pid=21632 HTTP/1.1
GET /stacks?pid=21632 HTTP/1.1
Host: localhost:52323
Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff=
Accept: application/json
Expand Down Expand Up @@ -100,7 +100,7 @@ Location: localhost:52323/operations/67f07e40-5cca-4709-9062-26302c484f18
### Sample Request

```http
GET /stack?pid=21632 HTTP/1.1
GET /stacks?pid=21632 HTTP/1.1
Host: localhost:52323
Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff=
Accept: text/plain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

First Available: 8.0 Preview 7

> [!NOTE]
> In-process features are only supported when running dotnet-monitor in `Listen` mode.
> See [Diagnostic Port](./diagnostic-port-configuration.md) configuration for details.

Some features of `dotnet monitor` require loading libraries into target applications. These libraries ship with `dotnet monitor` and are provisioned to be available to target applications using the `DefaultSharedPath` option in the [storage configuration](./storage-configuration.md) section. The following features require these in-process libraries to be used:

- [Call Stacks](#call-stacks)
Expand Down
32 changes: 16 additions & 16 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-aspnetcore</Uri>
<Sha>8e941eb42f819adb116b881195158b3887a70a1c</Sha>
</Dependency>
<Dependency Name="Microsoft.Diagnostics.Monitoring" Version="8.0.0-preview.24270.1">
<Dependency Name="Microsoft.Diagnostics.Monitoring" Version="8.0.0-preview.24304.1">
<Uri>https://github.com/dotnet/diagnostics</Uri>
<Sha>35998bc24f3ce093f3cef0cc50e224f9b07847ca</Sha>
<Sha>1c854868f031c1fb9cb2e175baaab120a42b42fd</Sha>
</Dependency>
<Dependency Name="Microsoft.Diagnostics.Monitoring.EventPipe" Version="8.0.0-preview.24270.1">
<Dependency Name="Microsoft.Diagnostics.Monitoring.EventPipe" Version="8.0.0-preview.24304.1">
<Uri>https://github.com/dotnet/diagnostics</Uri>
<Sha>35998bc24f3ce093f3cef0cc50e224f9b07847ca</Sha>
<Sha>1c854868f031c1fb9cb2e175baaab120a42b42fd</Sha>
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.24209.3">
<Uri>https://github.com/dotnet/command-line-api</Uri>
Expand All @@ -22,33 +22,33 @@
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>b4d9a1334d5189172977ba8fddd00bda70161e4a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24266.3">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.24270.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<Sha>f2b2071632d5d4c46d0f904f2b0d917b1752551b</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Archives" Version="8.0.0-beta.24266.3">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Archives" Version="8.0.0-beta.24270.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<Sha>f2b2071632d5d4c46d0f904f2b0d917b1752551b</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="8.0.0-beta.24266.3">
<Dependency Name="Microsoft.DotNet.CodeAnalysis" Version="8.0.0-beta.24270.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<Sha>f2b2071632d5d4c46d0f904f2b0d917b1752551b</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24266.3">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.24270.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<Sha>f2b2071632d5d4c46d0f904f2b0d917b1752551b</Sha>
</Dependency>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.103-servicing.24114.15">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>68e8abb1d3e1a240a6e4c29dcd220aae91681676</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.24266.3">
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.24270.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>e6f70c7dd528f05cd28cec2a179d58c22e91d9ac</Sha>
<Sha>f2b2071632d5d4c46d0f904f2b0d917b1752551b</Sha>
</Dependency>
<Dependency Name="Microsoft.FileFormats" Version="1.0.527001">
<Dependency Name="Microsoft.FileFormats" Version="1.0.530401">
<Uri>https://github.com/dotnet/diagnostics</Uri>
<Sha>35998bc24f3ce093f3cef0cc50e224f9b07847ca</Sha>
<Sha>1c854868f031c1fb9cb2e175baaab120a42b42fd</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
Expand Down
12 changes: 6 additions & 6 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
-->
<PropertyGroup Label="Automated">
<!-- dotnet/arcade references -->
<MicrosoftDotNetBuildTasksArchivesVersion>8.0.0-beta.24266.3</MicrosoftDotNetBuildTasksArchivesVersion>
<MicrosoftDotNetCodeAnalysisVersion>8.0.0-beta.24266.3</MicrosoftDotNetCodeAnalysisVersion>
<MicrosoftDotNetXUnitExtensionsVersion>8.0.0-beta.24266.3</MicrosoftDotNetXUnitExtensionsVersion>
<MicrosoftDotNetBuildTasksArchivesVersion>8.0.0-beta.24270.4</MicrosoftDotNetBuildTasksArchivesVersion>
<MicrosoftDotNetCodeAnalysisVersion>8.0.0-beta.24270.4</MicrosoftDotNetCodeAnalysisVersion>
<MicrosoftDotNetXUnitExtensionsVersion>8.0.0-beta.24270.4</MicrosoftDotNetXUnitExtensionsVersion>
<!-- dotnet/aspnetcore references -->
<MicrosoftAspNetCoreAppRuntimewinx64Version>8.0.1</MicrosoftAspNetCoreAppRuntimewinx64Version>
<VSRedistCommonAspNetCoreSharedFrameworkx6480Version>8.0.1-servicing.23580.8</VSRedistCommonAspNetCoreSharedFrameworkx6480Version>
<!-- dotnet/command-line-api references -->
<SystemCommandLineVersion>2.0.0-beta4.24209.3</SystemCommandLineVersion>
<!-- dotnet/diagnostics references -->
<MicrosoftDiagnosticsMonitoringVersion>8.0.0-preview.24270.1</MicrosoftDiagnosticsMonitoringVersion>
<MicrosoftDiagnosticsMonitoringEventPipeVersion>8.0.0-preview.24270.1</MicrosoftDiagnosticsMonitoringEventPipeVersion>
<MicrosoftDiagnosticsMonitoringVersion>8.0.0-preview.24304.1</MicrosoftDiagnosticsMonitoringVersion>
<MicrosoftDiagnosticsMonitoringEventPipeVersion>8.0.0-preview.24304.1</MicrosoftDiagnosticsMonitoringEventPipeVersion>
<!-- dotnet/installer references -->
<MicrosoftDotnetSdkInternalVersion>8.0.103-servicing.24114.15</MicrosoftDotnetSdkInternalVersion>
<!-- dotnet/roslyn-analyzers -->
Expand All @@ -67,7 +67,7 @@
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.1</MicrosoftNETCoreAppRuntimewinx64Version>
<VSRedistCommonNetCoreSharedFrameworkx6480Version>8.0.1-servicing.23580.1</VSRedistCommonNetCoreSharedFrameworkx6480Version>
<!-- dotnet/symstore references -->
<MicrosoftFileFormatsVersion>1.0.527001</MicrosoftFileFormatsVersion>
<MicrosoftFileFormatsVersion>1.0.530401</MicrosoftFileFormatsVersion>
</PropertyGroup>
<PropertyGroup Label="Runtime Versions">
<MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version>
Expand Down
2 changes: 1 addition & 1 deletion eng/dependabot/independent/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AzureIdentityVersion>1.11.3</AzureIdentityVersion>
<AzureStorageBlobsVersion>12.20.0</AzureStorageBlobsVersion>
<AzureStorageQueuesVersion>12.18.0</AzureStorageQueuesVersion>
<MicrosoftIdentityWebVersion>2.18.2</MicrosoftIdentityWebVersion>
<MicrosoftIdentityWebVersion>2.19.0</MicrosoftIdentityWebVersion>
<MicrosoftOpenApiReadersVersion>1.6.14</MicrosoftOpenApiReadersVersion>
<SystemPrivateUriVersion>4.3.2</SystemPrivateUriVersion>
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
Expand Down
2 changes: 1 addition & 1 deletion eng/dependabot/net6.0/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<!-- Microsoft.Extensions.Logging.Console -->
<MicrosoftExtensionsLoggingConsole60Version>6.0.0</MicrosoftExtensionsLoggingConsole60Version>
<!-- Microsoft.NETCore.App -->
<MicrosoftNETCoreApp60Version>6.0.30</MicrosoftNETCoreApp60Version>
<MicrosoftNETCoreApp60Version>6.0.31</MicrosoftNETCoreApp60Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion eng/dependabot/net7.0/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<!-- Microsoft.Extensions.Logging.Console -->
<MicrosoftExtensionsLoggingConsole70Version>7.0.0</MicrosoftExtensionsLoggingConsole70Version>
<!-- Microsoft.NETCore.App -->
<MicrosoftNETCoreApp70Version>7.0.19</MicrosoftNETCoreApp70Version>
<MicrosoftNETCoreApp70Version>7.0.20</MicrosoftNETCoreApp70Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion eng/dependabot/net8.0/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<!-- Microsoft.Extensions.Logging.Console -->
<MicrosoftExtensionsLoggingConsole80Version>8.0.0</MicrosoftExtensionsLoggingConsole80Version>
<!-- Microsoft.NETCore.App -->
<MicrosoftNETCoreApp80Version>8.0.5</MicrosoftNETCoreApp80Version>
<MicrosoftNETCoreApp80Version>8.0.6</MicrosoftNETCoreApp80Version>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions eng/pipelines/dotnet-monitor-cg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ schedules:
include:
- shipped/*
exclude:
- shipped/7.3
- shipped/7.2
- shipped/7.1
always: true
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.0",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24266.3",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24266.3"
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24270.4",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.24270.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Diagnostics.Monitoring.WebApi
{
public sealed record RequestLimit(string Key, int Limit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ private sealed class RequestCount : IDisposable
private readonly ConcurrentDictionary<string, RequestCount> _requestCounts = new();
private readonly ILogger<RequestLimitTracker> _logger;

public RequestLimitTracker(ILogger<RequestLimitTracker> logger)
public RequestLimitTracker(ILogger<RequestLimitTracker> logger, IEnumerable<RequestLimit> limits)
{
//CONSIDER Should we have configuration for these?
foreach (RequestLimit requestLimit in limits)
{
_requestLimitTable.Add(requestLimit.Key, requestLimit.Limit);
}

_requestLimitTable.Add(Utilities.ArtifactType_Dump, 1);
_requestLimitTable.Add(Utilities.ArtifactType_GCDump, 1);
_requestLimitTable.Add(Utilities.ArtifactType_Logs, 3);
_requestLimitTable.Add(Utilities.ArtifactType_Trace, 3);
_requestLimitTable.Add(Utilities.ArtifactType_Metrics, 3);
_requestLimitTable.Add(Utilities.ArtifactType_Stacks, 1);
_requestLimitTable.Add(Utilities.ArtifactType_Exceptions, 1);
_requestLimitTable.Add(Utilities.ArtifactType_Parameters, 1);
_requestLimitTable.Add(Unlimited, int.MaxValue);

_logger = logger;
}
Expand Down
24 changes: 21 additions & 3 deletions src/Profilers/MonitorProfiler/Communication/CommandServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ CommandServer::CommandServer(const std::shared_ptr<ILogger>& logger, ICorProfile
{
}

HRESULT CommandServer::Start(const std::string& path, std::function<HRESULT(const IpcMessage& message)> callback)
HRESULT CommandServer::Start(
const std::string& path,
std::function<HRESULT(const IpcMessage& message)> callback,
std::function<HRESULT(const IpcMessage& message)> validateMessageCallback)
{
if (_shutdown.load())
{
Expand All @@ -31,6 +34,7 @@ HRESULT CommandServer::Start(const std::string& path, std::function<HRESULT(cons
#endif

_callback = callback;
_validateMessageCallback = validateMessageCallback;

IfFailLogRet_(_logger, _server.Bind(path));
_listeningThread = std::thread(&CommandServer::ListeningThread, this);
Expand Down Expand Up @@ -75,25 +79,39 @@ void CommandServer::ListeningThread()
if (FAILED(hr))
{
_logger->Log(LogLevel::Error, _LS("Unexpected error when receiving data: 0x%08x"), hr);
// Best-effort shutdown, ignore the result.
client->Shutdown();
continue;
}

bool doEnqueueMessage = true;
hr = _validateMessageCallback(message);
if (FAILED(hr))
{
_logger->Log(LogLevel::Error, _LS("Failed to validate message: 0x%08x"), hr);
doEnqueueMessage = false;
}

*reinterpret_cast<HRESULT*>(response.Payload.data()) = hr;

hr = client->Send(response);
if (FAILED(hr))
{
_logger->Log(LogLevel::Error, _LS("Unexpected error when sending data: 0x%08x"), hr);
continue;
doEnqueueMessage = false;
}

hr = client->Shutdown();
if (FAILED(hr))
{
_logger->Log(LogLevel::Warning, _LS("Unexpected error during shutdown: 0x%08x"), hr);
// Not fatal, keep processing the message
}

_clientQueue.Enqueue(message);
if (doEnqueueMessage)
{
_clientQueue.Enqueue(message);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/Profilers/MonitorProfiler/Communication/CommandServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class CommandServer final
{
public:
CommandServer(const std::shared_ptr<ILogger>& logger, ICorProfilerInfo12* profilerInfo);
HRESULT Start(const std::string& path, std::function<HRESULT (const IpcMessage& message)> callback);
HRESULT Start(
const std::string& path,
std::function<HRESULT (const IpcMessage& message)> callback,
std::function<HRESULT (const IpcMessage& message)> validateMessageCallback);
void Shutdown();

private:
Expand All @@ -29,6 +32,8 @@ class CommandServer final
std::atomic_bool _shutdown;

std::function<HRESULT(const IpcMessage& message)> _callback;
std::function<HRESULT(const IpcMessage& message)> _validateMessageCallback;

IpcCommServer _server;

BlockingQueue<IpcMessage> _clientQueue;
Expand All @@ -38,4 +43,4 @@ class CommandServer final
std::thread _clientThread;

ComPtr<ICorProfilerInfo12> _profilerInfo;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#include "MessageCallbackManager.h"

bool MessageCallbackManager::IsRegistered(unsigned short commandSet)
{
std::lock_guard<std::mutex> lookupLock(m_lookupMutex);

std::function<HRESULT (const IpcMessage& message)> existingCallback;
return TryGetCallback(commandSet, existingCallback);
}

bool MessageCallbackManager::TryRegister(unsigned short commandSet, ManagedMessageCallback pCallback)
{
return TryRegister(commandSet, [pCallback](const IpcMessage& message)-> HRESULT
Expand All @@ -13,7 +21,8 @@ bool MessageCallbackManager::TryRegister(unsigned short commandSet, ManagedMessa

bool MessageCallbackManager::TryRegister(unsigned short commandSet, std::function<HRESULT (const IpcMessage& message)> callback)
{
std::lock_guard<std::mutex> lock(m_mutex);
std::lock_guard<std::mutex> dispatchLock(m_dispatchMutex);
std::lock_guard<std::mutex> lookupLock(m_lookupMutex);

std::function<HRESULT (const IpcMessage& message)> existingCallback;
if (TryGetCallback(commandSet, existingCallback))
Expand All @@ -27,7 +36,7 @@ bool MessageCallbackManager::TryRegister(unsigned short commandSet, std::functio

HRESULT MessageCallbackManager::DispatchMessage(const IpcMessage& message)
{
std::lock_guard<std::mutex> lock(m_mutex);
std::lock_guard<std::mutex> dispatchLock(m_dispatchMutex);

std::function<HRESULT (const IpcMessage& message)> callback;
if (!TryGetCallback(message.CommandSet, callback))
Expand All @@ -40,7 +49,8 @@ HRESULT MessageCallbackManager::DispatchMessage(const IpcMessage& message)

void MessageCallbackManager::Unregister(unsigned short commandSet)
{
std::lock_guard<std::mutex> lock(m_mutex);
std::lock_guard<std::mutex> dispatchLock(m_dispatchMutex);
std::lock_guard<std::mutex> lookupLock(m_lookupMutex);

m_callbacks.erase(commandSet);
}
Expand Down
Loading