Skip to content

Commit 9c4eb93

Browse files
yyjdeleteSeabiscuit
authored and
Seabiscuit
committed
Pickup some commits not related to Mono from Azure#374 (Azure#410)
* 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
1 parent 50ae0dc commit 9c4eb93

File tree

16 files changed

+1138
-1054
lines changed

16 files changed

+1138
-1054
lines changed

Directory.Build.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
<PropertyGroup>
99
<InformationalVersion>$(Version). Commit Hash: $(GitHeadSha)</InformationalVersion>
1010
</PropertyGroup>
11+
12+
<Target Name="VSTestIfTestProject">
13+
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
14+
</Target>
1115
</Project>

after.DotNetty.sln.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<Target Name="VSTest">
3+
<MSBuild Projects="@(ProjectReference)" Targets="VSTestIfTestProject" />
4+
</Target>
5+
</Project>

src/DotNetty.Codecs/ByteToMessageDecoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected void DiscardSomeReadBytes()
249249
// See:
250250
// - https://github.com/netty/netty/issues/2327
251251
// - https://github.com/netty/netty/issues/1764
252-
this.cumulation.DiscardReadBytes(); // todo: use discardSomeReadBytes
252+
this.cumulation.DiscardSomeReadBytes();
253253
}
254254
}
255255

src/DotNetty.Handlers/Logging/LoggingHandler.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,48 @@ public override void ChannelRead(IChannelHandlerContext ctx, object message)
209209
ctx.FireChannelRead(message);
210210
}
211211

212+
public override void ChannelReadComplete(IChannelHandlerContext ctx)
213+
{
214+
if (this.Logger.IsEnabled(this.InternalLevel))
215+
{
216+
this.Logger.Log(this.InternalLevel, this.Format(ctx, "RECEIVED_COMPLETE"));
217+
}
218+
ctx.FireChannelReadComplete();
219+
}
220+
221+
public override void ChannelWritabilityChanged(IChannelHandlerContext ctx)
222+
{
223+
if (this.Logger.IsEnabled(this.InternalLevel))
224+
{
225+
this.Logger.Log(this.InternalLevel, this.Format(ctx, "WRITABILITY", ctx.Channel.IsWritable));
226+
}
227+
ctx.FireChannelWritabilityChanged();
228+
}
229+
230+
public override void HandlerAdded(IChannelHandlerContext ctx)
231+
{
232+
if (this.Logger.IsEnabled(this.InternalLevel))
233+
{
234+
this.Logger.Log(this.InternalLevel, this.Format(ctx, "HANDLER_ADDED"));
235+
}
236+
}
237+
public override void HandlerRemoved(IChannelHandlerContext ctx)
238+
{
239+
if (this.Logger.IsEnabled(this.InternalLevel))
240+
{
241+
this.Logger.Log(this.InternalLevel, this.Format(ctx, "HANDLER_REMOVED"));
242+
}
243+
}
244+
245+
public override void Read(IChannelHandlerContext ctx)
246+
{
247+
if (this.Logger.IsEnabled(this.InternalLevel))
248+
{
249+
this.Logger.Log(this.InternalLevel, this.Format(ctx, "READ"));
250+
}
251+
ctx.Read();
252+
}
253+
212254
public override Task WriteAsync(IChannelHandlerContext ctx, object msg)
213255
{
214256
if (this.Logger.IsEnabled(this.InternalLevel))

src/DotNetty.Handlers/Tls/SniHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class SniHandler : ByteToMessageDecoder
2828
bool readPending;
2929

3030
public SniHandler(ServerTlsSniSettings settings)
31-
: this(stream => new SslStream(stream, false), settings)
31+
: this(stream => new SslStream(stream, true), settings)
3232
{
3333
}
3434

src/DotNetty.Handlers/Tls/TlsHandler.Extensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ private static SslStream CreateSslStream(TlsSettings settings, Stream stream)
4040
// Enable client certificate function only if ClientCertificateRequired is true in the configuration
4141
if (serverSettings.ClientCertificateMode == ClientCertificateMode.NoCertificate)
4242
{
43-
return new SslStream(stream, false);
43+
return new SslStream(stream, true);
4444
}
4545
#if DESKTOPCLR
4646
// SSL 版本 2 协议不支持客户端证书
4747
if (serverSettings.EnabledProtocols == SslProtocols.Ssl2)
4848
{
49-
return new SslStream(stream, false);
49+
return new SslStream(stream, true);
5050
}
5151
#endif
5252

5353
return new SslStream(stream,
54-
leaveInnerStreamOpen: false,
54+
leaveInnerStreamOpen: true,
5555
userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) =>
5656
{
5757
if (certificate == null)
@@ -84,7 +84,7 @@ private static SslStream CreateSslStream(TlsSettings settings, Stream stream)
8484
{
8585
var clientSettings = (ClientTlsSettings)settings;
8686
return new SslStream(stream,
87-
leaveInnerStreamOpen: false,
87+
leaveInnerStreamOpen: true,
8888
userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) =>
8989
{
9090
if (clientSettings.ServerCertificateValidation != null)

0 commit comments

Comments
 (0)