mirror of
https://github.com/Azure/DotNetty.git
synced 2026-10-18 22:30:36 +08:00
f31c02e346
Motivation: TlsHandler Fix TlsHandler, optimize encryption / decryption wrt Write vs Flush semantics, optimize memory retention for sparse communication, adopt IByteBuffer.GetIoBuffers() in TlsHandler. Modifications: - TlsHandler is rewritten to use batch->copy->write approach instead of writing directly to SslStream in order to reduce overhead of framing / writing out everything separately. - TlsHandler uses IByteBuffer.GetIoBuffers intead of direct array access increasing compatibility for non-array-backed buffers. - TlsHandler and TlsHandler.MediationStream use Task semantics now when reading through SslStream. - Extra: upgraded to NBench 2.2, xUnit 2.1.0. - Extra: better portability for .NET Core support. Result: TlsHandler provides better framing and much better (x2+) performance (depends on application control of flushing). TlsHandler operates properly in edge cases when more than one frame is accepted at once and if decrypted frame size is more than 4 KB. TlsHandler holds only 256 byte buffer while waiting for more data to arrive off the wire. Extra: DotNetty is almost .NET Core compatible.
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
namespace DotNetty.Tests.Common
|
|
{
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using DotNetty.Common;
|
|
using Xunit;
|
|
|
|
public static class AssertEx
|
|
{
|
|
public static Task EventuallyAsync(Func<bool> testFunc, TimeSpan interval, TimeSpan timeout) => EventuallyAsync(() => Task.FromResult(testFunc()), interval, timeout);
|
|
|
|
public static async Task EventuallyAsync(Func<Task<bool>> testFunc, TimeSpan interval, TimeSpan timeout)
|
|
{
|
|
PreciseTimeSpan deadline = PreciseTimeSpan.Deadline(timeout);
|
|
while (true)
|
|
{
|
|
if (await testFunc())
|
|
{
|
|
return;
|
|
}
|
|
if (PreciseTimeSpan.FromStart - deadline > PreciseTimeSpan.Zero)
|
|
{
|
|
Assert.True(false, "Did not reach expected state in time.");
|
|
}
|
|
await Task.Delay(interval);
|
|
}
|
|
}
|
|
}
|
|
} |