Skip to content

Commit

Permalink
Merge pull request #19 from otakulan/feature/tgh/fix-hosted-service-c…
Browse files Browse the repository at this point in the history
…rash

Fix named pipe server hosted service crash
  • Loading branch information
starcraft66 authored Jun 18, 2024
2 parents 9a3c6c2 + 5496577 commit 84fffb6
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

while (!stoppingToken.IsCancellationRequested)
{
InitializePipeServer();

_logger.LogInformation("Waiting for client connection...");

try
{
InitializePipeServer();
_logger.LogInformation("Waiting for client connection...");

var waitTask = _server.WaitForConnectionAsync(stoppingToken);

Check warning on line 76 in Lanpartyseating.Desktop/Business/NamedPipeServerHostedService.cs

View workflow job for this annotation

GitHub Actions / build (x64)

Dereference of a possibly null reference.

Check warning on line 76 in Lanpartyseating.Desktop/Business/NamedPipeServerHostedService.cs

View workflow job for this annotation

GitHub Actions / build (x64)

Dereference of a possibly null reference.

Check warning on line 76 in Lanpartyseating.Desktop/Business/NamedPipeServerHostedService.cs

View workflow job for this annotation

GitHub Actions / build (arm64)

Dereference of a possibly null reference.

Check warning on line 76 in Lanpartyseating.Desktop/Business/NamedPipeServerHostedService.cs

View workflow job for this annotation

GitHub Actions / build (arm64)

Dereference of a possibly null reference.
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10), stoppingToken); // Adjust the timeout as needed

Expand Down Expand Up @@ -139,6 +138,8 @@ private void InitializePipeServer()

if (pipeHandle.IsInvalid)
{
// Access denied errors have been observed here intermittently.
// Throwing here will cause the server to re-initialize in the run loop above.
throw new Win32Exception(Marshal.GetLastWin32Error());
}

Expand Down

0 comments on commit 84fffb6

Please sign in to comment.