Put MapMcp in Microsoft.AspNetCore.Builder namespace (#171)
* Still dispose McpSession when MessageProcessingTask throws non-OCE exceptions * Put MapMcp in icrosoft.AspNetCore.Builder namespace
This commit is contained in:
parent
065e3c6dbb
commit
57a526ec30
1 changed files with 21 additions and 21 deletions
|
|
@ -94,25 +94,30 @@ internal abstract class McpJsonRpcEndpoint : IAsyncDisposable
|
|||
{
|
||||
_logger.CleaningUpEndpoint(EndpointName);
|
||||
|
||||
if (_sessionCts is not null)
|
||||
try
|
||||
{
|
||||
await _sessionCts.CancelAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (MessageProcessingTask is not null)
|
||||
{
|
||||
try
|
||||
if (_sessionCts is not null)
|
||||
{
|
||||
await MessageProcessingTask.ConfigureAwait(false);
|
||||
await _sessionCts.CancelAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
||||
if (MessageProcessingTask is not null)
|
||||
{
|
||||
// Ignore cancellation
|
||||
try
|
||||
{
|
||||
await MessageProcessingTask.ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Ignore cancellation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_session?.Dispose();
|
||||
_sessionCts?.Dispose();
|
||||
finally
|
||||
{
|
||||
_session?.Dispose();
|
||||
_sessionCts?.Dispose();
|
||||
}
|
||||
|
||||
_logger.EndpointCleanedUp(EndpointName);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue