Fixed two reliability issues highlighted by SonarCloud (#44)
This commit is contained in:
parent
a2e8ecc23d
commit
967d7a4cc8
3 changed files with 10 additions and 4 deletions
|
|
@ -169,9 +169,12 @@ public sealed class StdioServerTransport : TransportBase, IServerTransport
|
||||||
{
|
{
|
||||||
_logger.TransportCleaningUp(EndpointName);
|
_logger.TransportCleaningUp(EndpointName);
|
||||||
|
|
||||||
_shutdownCts?.Cancel();
|
if (_shutdownCts != null)
|
||||||
_shutdownCts?.Dispose();
|
{
|
||||||
_shutdownCts = null;
|
await _shutdownCts.CancelAsync().ConfigureAwait(false);
|
||||||
|
_shutdownCts.Dispose();
|
||||||
|
_shutdownCts = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (_readTask != null)
|
if (_readTask != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ using McpDotNet.Server;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
|
namespace McpDotNet.TestServer;
|
||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ILoggerFactory CreateLoggerFactory()
|
private static ILoggerFactory CreateLoggerFactory()
|
||||||
|
|
@ -336,7 +338,7 @@ internal static class Program
|
||||||
Log.Logger.Information("Server started.");
|
Log.Logger.Information("Server started.");
|
||||||
|
|
||||||
// Run until process is stopped by the client (parent process)
|
// Run until process is stopped by the client (parent process)
|
||||||
while (true)
|
while (true) // NOSONAR
|
||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AssemblyName>TestServer</AssemblyName>
|
<AssemblyName>TestServer</AssemblyName>
|
||||||
|
<RootNamespace>McpDotNet.TestServer</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue