diff options
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/diagnosticserver.cpp | 38 | ||||
-rw-r--r-- | src/vm/diagnosticserver.h | 8 | ||||
-rw-r--r-- | src/vm/fastserializer.cpp | 1 | ||||
-rw-r--r-- | src/vm/fastserializer.h | 3 |
4 files changed, 33 insertions, 17 deletions
diff --git a/src/vm/diagnosticserver.cpp b/src/vm/diagnosticserver.cpp index c0e11d100f..3a700383ac 100644 --- a/src/vm/diagnosticserver.cpp +++ b/src/vm/diagnosticserver.cpp @@ -4,7 +4,6 @@ #include "common.h" #include "diagnosticserver.h" -#include "diagnosticsipc.h" #include "eventpipeprotocolhelper.h" #ifdef FEATURE_PAL @@ -13,6 +12,8 @@ #ifdef FEATURE_PERFTRACING +IpcStream::DiagnosticsIpc *DiagnosticServer::s_pIpc = nullptr; + static DWORD WINAPI DiagnosticsServerThread(LPVOID lpThreadParameter) { CONTRACTL @@ -28,17 +29,13 @@ static DWORD WINAPI DiagnosticsServerThread(LPVOID lpThreadParameter) auto pIpc = reinterpret_cast<IpcStream::DiagnosticsIpc *>(lpThreadParameter); if (pIpc == nullptr) { - STRESS_LOG0(LF_STARTUP, LL_ERROR,"Diagnostics IPC listener was undefined\n"); + STRESS_LOG0(LF_DIAGNOSTICS_PORT, LL_ERROR, "Diagnostics IPC listener was undefined\n"); return 1; } -#ifdef _DEBUG ErrorCallback LoggingCallback = [](const char *szMessage, uint32_t code) { - LOG((LF_REMOTING, LL_WARNING, "warning (%d): %s.\n", code, szMessage)); + STRESS_LOG2(LF_DIAGNOSTICS_PORT, LL_WARNING, "warning (%d): %s.\n", code, szMessage); }; -#else - ErrorCallback LoggingCallback = nullptr; -#endif while (true) { @@ -69,7 +66,7 @@ static DWORD WINAPI DiagnosticsServerThread(LPVOID lpThreadParameter) break; default: - LOG((LF_REMOTING, LL_WARNING, "Received unknow request type (%d)\n", header.RequestType)); + LOG((LF_DIAGNOSTICS_PORT, LL_WARNING, "Received unknow request type (%d)\n", header.RequestType)); break; } } @@ -93,23 +90,25 @@ bool DiagnosticServer::Initialize() { auto ErrorCallback = [](const char *szMessage, uint32_t code) { STRESS_LOG2( - LF_STARTUP, // facility + LF_DIAGNOSTICS_PORT, // facility LL_ERROR, // level "Failed to create diagnostic IPC: error (%d): %s.\n", // msg code, // data1 szMessage); // data2 }; - IpcStream::DiagnosticsIpc *pIpc = IpcStream::DiagnosticsIpc::Create( + + // TODO: Should we handle/assert that (s_pIpc == nullptr)? + s_pIpc = IpcStream::DiagnosticsIpc::Create( "dotnetcore-diagnostic", ErrorCallback); - if (pIpc != nullptr) + if (s_pIpc != nullptr) { DWORD dwThreadId = 0; HANDLE hThread = ::CreateThread( // TODO: Is it correct to have this "lower" level call here? nullptr, // no security attribute 0, // default stack size DiagnosticsServerThread, // thread proc - (LPVOID)pIpc, // thread parameter + (LPVOID)s_pIpc, // thread parameter 0, // not suspended &dwThreadId); // returns thread ID @@ -117,7 +116,7 @@ bool DiagnosticServer::Initialize() { // Failed to create IPC thread. STRESS_LOG1( - LF_STARTUP, // facility + LF_DIAGNOSTICS_PORT, // facility LL_ERROR, // level "Failed to create diagnostic server thread (%d).\n", // msg ::GetLastError()); // data1 @@ -155,7 +154,18 @@ bool DiagnosticServer::Shutdown() EX_TRY { - // FIXME: Stop IPC server thread? + if (s_pIpc != nullptr) + { + auto ErrorCallback = [](const char *szMessage, uint32_t code) { + STRESS_LOG2( + LF_DIAGNOSTICS_PORT, // facility + LL_ERROR, // level + "Failed to unlink diagnostic IPC: error (%d): %s.\n", // msg + code, // data1 + szMessage); // data2 + }; + s_pIpc->Unlink(ErrorCallback); + } fSuccess = true; } EX_CATCH diff --git a/src/vm/diagnosticserver.h b/src/vm/diagnosticserver.h index 95399a2ef8..51f32ae09f 100644 --- a/src/vm/diagnosticserver.h +++ b/src/vm/diagnosticserver.h @@ -5,10 +5,11 @@ #ifndef __DIAGNOSTIC_SERVER_H__ #define __DIAGNOSTIC_SERVER_H__ -#include <stdint.h> - #ifdef FEATURE_PERFTRACING // This macro should change to something more generic than performance. +#include <stdint.h> +#include "diagnosticsipc.h" + //! TODO: Temp class. enum class DiagnosticMessageType : uint32_t { @@ -51,6 +52,9 @@ public: //! Shutdown the event pipe. static bool Shutdown(); + +private: + static IpcStream::DiagnosticsIpc *s_pIpc; }; #endif // FEATURE_PERFTRACING diff --git a/src/vm/fastserializer.cpp b/src/vm/fastserializer.cpp index 89dbe50728..e02ec93010 100644 --- a/src/vm/fastserializer.cpp +++ b/src/vm/fastserializer.cpp @@ -4,6 +4,7 @@ #include "common.h" #include "fastserializer.h" +#include "diagnosticsipc.h" #ifdef FEATURE_PERFTRACING diff --git a/src/vm/fastserializer.h b/src/vm/fastserializer.h index 3b4de65bf5..98208c0eb1 100644 --- a/src/vm/fastserializer.h +++ b/src/vm/fastserializer.h @@ -11,7 +11,8 @@ #include "fastserializableobject.h" #include "fstream.h" -#include "diagnosticsipc.h" + +class IpcStream; // the enumeration has a specific set of values to keep it compatible with consumer library // it's sibling is defined in https://github.com/Microsoft/perfview/blob/10d1f92b242c98073b3817ac5ee6d98cd595d39b/src/FastSerialization/FastSerialization.cs#L2295 |