Files
Max Gortman b2f10c28cb Fixes excessive exceptions from being thrown in case of graceful channel closure. (#152)
Motivation:
SocketException and ODE are being thrown when disconnecting gracefully.

Modifications:
- dismiss async read completion if it is done on inactive channel
- do not attempt sync-reading from a socket that is not Connected
- extra: fixing echo sample with better practices
- extra: ReadListener for more natural test scenarios
- extra: tweaked nbench spec to work in-loop

Result:
No excessive errors happen during graceful shutdown
2016-08-08 15:34:08 -07:00

24 lines
759 B
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.Collections.Generic;
using System.Threading.Tasks;
using DotNetty.Transport.Channels;
public static class ChannelExtensions
{
public static Task WriteAndFlushManyAsync(this IChannel channel, params object[] messages)
{
var list = new List<Task>();
foreach (object m in messages)
{
list.Add(channel.WriteAsync(m));
}
IEnumerable<Task> tasks = list.ToArray();
channel.Flush();
return Task.WhenAll(tasks);
}
}
}