Skip to content

Commit

Permalink
Pickup some commits not related to Mono from Azure#374 (Azure#410)
Browse files Browse the repository at this point in the history
* Add some missing method to LoggingHandler

* Avoid to alloc an huge error message when the test not failed.

* Update the unittest

* Update Microsoft.NET.Test.Sdk from 15.0.0 to 15.7.2, fix that unable to debug an unittest for the second time.
* Disable parallelization for InternalLoggerFactoryTest.TestMockReturned to avoid an rare test failure.
* Remove `dotnet-xunit` since it's never used and will be discontinued, see https://xunit.github.io/releases/2.4-beta2

* Remove space from filename

* Switch back to `DiscardSomeReadBytes` since it's avaliable

* Rework some logic in TlsHandler

* Make sure TlsHandler.MediationStream works well with different style of aync calls(Still not work for Mono, see Azure#374)
* Rework some logic in Azure#366, now always close TlsHandler.MediationStream in TlsHandler.HandleFailure since it's never exported.

* Workaround to fix issue 'microsoft/vstest#1129'.

* Change the default of TcpServerSocketChannel.Metadata.defaultMaxMessagesPerRead to 1
  • Loading branch information
yyjdelete authored and Seabiscuit committed Aug 14, 2018
1 parent 50ae0dc commit 9c4eb93
Show file tree
Hide file tree
Showing 16 changed files with 1,138 additions and 1,054 deletions.
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<PropertyGroup>
<InformationalVersion>$(Version). Commit Hash: $(GitHeadSha)</InformationalVersion>
</PropertyGroup>

<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
</Project>
5 changes: 5 additions & 0 deletions after.DotNetty.sln.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<Target Name="VSTest">
<MSBuild Projects="@(ProjectReference)" Targets="VSTestIfTestProject" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/DotNetty.Codecs/ByteToMessageDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected void DiscardSomeReadBytes()
// See:
// - https://github.com/netty/netty/issues/2327
// - https://github.com/netty/netty/issues/1764
this.cumulation.DiscardReadBytes(); // todo: use discardSomeReadBytes
this.cumulation.DiscardSomeReadBytes();
}
}

Expand Down
42 changes: 42 additions & 0 deletions src/DotNetty.Handlers/Logging/LoggingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,48 @@ public override void ChannelRead(IChannelHandlerContext ctx, object message)
ctx.FireChannelRead(message);
}

public override void ChannelReadComplete(IChannelHandlerContext ctx)
{
if (this.Logger.IsEnabled(this.InternalLevel))
{
this.Logger.Log(this.InternalLevel, this.Format(ctx, "RECEIVED_COMPLETE"));
}
ctx.FireChannelReadComplete();
}

public override void ChannelWritabilityChanged(IChannelHandlerContext ctx)
{
if (this.Logger.IsEnabled(this.InternalLevel))
{
this.Logger.Log(this.InternalLevel, this.Format(ctx, "WRITABILITY", ctx.Channel.IsWritable));
}
ctx.FireChannelWritabilityChanged();
}

public override void HandlerAdded(IChannelHandlerContext ctx)
{
if (this.Logger.IsEnabled(this.InternalLevel))
{
this.Logger.Log(this.InternalLevel, this.Format(ctx, "HANDLER_ADDED"));
}
}
public override void HandlerRemoved(IChannelHandlerContext ctx)
{
if (this.Logger.IsEnabled(this.InternalLevel))
{
this.Logger.Log(this.InternalLevel, this.Format(ctx, "HANDLER_REMOVED"));
}
}

public override void Read(IChannelHandlerContext ctx)
{
if (this.Logger.IsEnabled(this.InternalLevel))
{
this.Logger.Log(this.InternalLevel, this.Format(ctx, "READ"));
}
ctx.Read();
}

public override Task WriteAsync(IChannelHandlerContext ctx, object msg)
{
if (this.Logger.IsEnabled(this.InternalLevel))
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetty.Handlers/Tls/SniHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class SniHandler : ByteToMessageDecoder
bool readPending;

public SniHandler(ServerTlsSniSettings settings)
: this(stream => new SslStream(stream, false), settings)
: this(stream => new SslStream(stream, true), settings)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/DotNetty.Handlers/Tls/TlsHandler.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ private static SslStream CreateSslStream(TlsSettings settings, Stream stream)
// Enable client certificate function only if ClientCertificateRequired is true in the configuration
if (serverSettings.ClientCertificateMode == ClientCertificateMode.NoCertificate)
{
return new SslStream(stream, false);
return new SslStream(stream, true);
}
#if DESKTOPCLR
// SSL 版本 2 协议不支持客户端证书
if (serverSettings.EnabledProtocols == SslProtocols.Ssl2)
{
return new SslStream(stream, false);
return new SslStream(stream, true);
}
#endif

return new SslStream(stream,
leaveInnerStreamOpen: false,
leaveInnerStreamOpen: true,
userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) =>
{
if (certificate == null)
Expand Down Expand Up @@ -84,7 +84,7 @@ private static SslStream CreateSslStream(TlsSettings settings, Stream stream)
{
var clientSettings = (ClientTlsSettings)settings;
return new SslStream(stream,
leaveInnerStreamOpen: false,
leaveInnerStreamOpen: true,
userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) =>
{
if (clientSettings.ServerCertificateValidation != null)
Expand Down
Loading

0 comments on commit 9c4eb93

Please sign in to comment.