Review watchers
This commit is contained in:
parent
9684f15925
commit
99202af871
3 changed files with 42 additions and 40 deletions
|
|
@ -144,21 +144,21 @@ public sealed class KeaDhcpLeaseWatcher : IHostedService
|
|||
_eventChannel.Writer.TryComplete();
|
||||
if (reader is { IsCompleted: false })
|
||||
{
|
||||
try
|
||||
{
|
||||
await reader.ConfigureAwait(continueOnCapturedContext: false);
|
||||
}
|
||||
catch { }
|
||||
await reader.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
|
||||
}
|
||||
|
||||
_pipe.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task FileReader(AutoResetEvent waitHandle, CancellationToken stoppingToken)
|
||||
{
|
||||
PipeWriter writer = _pipe.Writer;
|
||||
SepReader? reader = null;
|
||||
try
|
||||
{
|
||||
PipeWriter writer = _pipe.Writer;
|
||||
using (stoppingToken.Register(s => ((PipeWriter)s!).Complete(null), writer))
|
||||
{
|
||||
using var file = new FileStream(Options.Leases, LeaseFileStreamOptions);
|
||||
|
||||
|
|
@ -170,7 +170,11 @@ public sealed class KeaDhcpLeaseWatcher : IHostedService
|
|||
{
|
||||
if (reader is null)
|
||||
{
|
||||
reader = MemfileReader.From(_pipe.Reader.AsStream());
|
||||
reader = await Task.Factory.StartNew(
|
||||
s => MemfileReader.From((Stream)s!),
|
||||
_pipe.Reader.AsStream(),
|
||||
stoppingToken,
|
||||
TaskCreationOptions.AttachedToParent, TaskScheduler.Default);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -202,11 +206,10 @@ public sealed class KeaDhcpLeaseWatcher : IHostedService
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader?.Dispose();
|
||||
writer.Complete();
|
||||
_pipe.Reset();
|
||||
}
|
||||
|
||||
static void CountNewLines(Decoder decoder, in Memory<byte> memory, ref int newLinesEncountered, ref bool awaitLineFeed)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ builder.WebHost.ConfigureKestrel((context, options) =>
|
|||
var path = PathEx.ExpandPath(pdnsOptions.Socket);
|
||||
FileInfo file = new(path);
|
||||
file.Directory!.Create();
|
||||
file.Delete();
|
||||
options.ListenUnixSocket(path, options =>
|
||||
{
|
||||
options.UseConnectionHandler<PowerDnsHandler>();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
|
||||
<PackageReference Include="Sep" Version="0.3.0" />
|
||||
<PackageReference Include="Sep" Version="0.4.0" />
|
||||
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue