76 Commits

Author SHA1 Message Date
Max Gortman 6515aa0853 set version to 0.6.0 (#435) 2018-10-10 09:16:51 -07:00
SilverFox 797629ac1b Pickup some commits not related to Mono from #374 (#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 #374)
* Rework some logic in #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
2018-08-13 11:38:06 -07:00
Johnny Z 2c0c10939e WebSocket support. (#400) 2018-08-13 10:58:52 -07:00
Johnny Z b8370d7b34 Realign with Netty Redis codec. (#391) 2018-04-13 10:05:26 -07:00
Johnny Z f227f95966 HTTP 1.1 codec #52 (#256) 2018-04-11 09:31:39 -07:00
Johnny Z 2cd04cd8a7 InliningDiagnoser/Unsafe unaligned. (#384) 2018-03-26 09:47:51 -07:00
Johnny Z 42f210a258 Made Libuv write promise complete on write callback #376. (#378) 2018-03-15 15:00:59 -07:00
Johnny Z 33b95cfe61 Buffer read/write/get/set strings. (#369)
Motivation:
Implement commonly used string-based operations (originally Netty CharSequence) for byte buffers.

Modifications:
Added read/write/get/set strings methods to byte buffers.
Also reduced unsafe pin/unpins for byte operations.

Result:
String-based operations are supported in DotNetty
2018-03-15 14:58:49 -07:00
SilverFox b2e8b4ba15 Improve unittest and fix some leak (#366)
- Fix #353, SniHandlerTest timeout in net452 and netcoreapp2.1(preview).
- Fix that test for TlsHandlerTest.NoAutoReadHandshakeProgresses never finish in netcoreapp2.0 and 2.1(preview)
- Fix some leak on TlsHandler and EmbeddedChannel.
- Update xunit from 2.2.0 to 2.3.1. That greatly improve the test speed of DotNetty.Buffers.Tests in net452.
2018-03-07 07:28:40 -08:00
Johnny Z d31f62a435 Motivation: (#364)
Pending write buffers released before Libuv write callbacks.

Modifications:
According to Libuv documentation, write requests sent with uv_write will be queued. It is safe to reuse the uv_write_t object only after the callback passed to uv_write is fired.
Made Libuv tcp writes release buffers only after the write callback is called. Aslo avoid write buffer pin/unpin operations if the byte buffers to write already pinned.

Result:
Fix #348 and potentially reduced write pin/unpin operations.
2018-02-26 10:51:10 -08:00
maksimkim 75652fbdd9 Channel pool (#313)
Motivation:

Provide a generic API and implementation for channel/connection pooling

Modifications:

Add IChannelPool / IChannelPoolMap API and implementations.

Result:

Reusable / Generic pool implementation that users can use.
2018-02-15 09:55:06 -08:00
Johnny Z 4ddb22088a Libuv tests. (#332) 2018-01-19 11:11:02 -08:00
Johnny Z d77bc29389 Unsafe direct buffers. (#316) 2017-12-20 10:41:36 -08:00
mkim a05ec8c563 +FlowControlHandler 2017-11-26 01:37:16 -08:00
Johnny Z 68d2675008 ResourceLeakDetector 2017-11-17 11:58:59 -08:00
alextolp 65b47356dd Make ReadListeningHandler thread-safe 2017-10-26 18:25:46 -07:00
Johnny Z 131db28613 Libuv based tcp transport. (#270) 2017-10-02 16:10:14 -07:00
SilverFox 37c756a64d Realigning API of IdleStateHandler, and some bugfix (#285)
* Align API and Test of IdleStateHandler with netty 4.1.15(f9003293...7460d90a)
* Fix EmbeddedChannel.ReleaseAll crashes when queue is null
* Fix ReadTimeoutHandler don't close channel when timeout
* Change IdleStateHandler.ChannelIdle and WriteTimeoutHandler.WriteTimedOut to virtual
2017-09-15 11:54:13 -07:00
Johnny Z 6b86b1b883 Re align with Netty buffers. (#287) 2017-09-15 11:32:11 -07:00
Max Gortman 05d127f935 TlsHandler drives handshake to completion with AutoRead=false (#263) 2017-07-13 16:44:12 -07:00
ScarletKuro e31fced6c0 Expanded Unpooled functionality. Ported UnpooledTest(#36) (#251)
Motivation:
Make code to be as close to the original to benefit from co-development
UnpooledTests is needed

Modifications:
- added Copy* and CopiedBuffer functions with params support to Unpooled
- added new constuctors with params support to Unpooled
- added CombineBytes to ByteBufferUtil
- constants in AbstractByteBufferAllocator are now public

Result:
- can now verify that the current Unpooled class works as intended
2017-05-16 14:07:07 -07:00
Max Gortman 5865d225df Fixes #225
extra: flaky test fixes
2017-05-15 11:22:41 -07:00
SilverFox 5e42bcf81f Add Float and Zero api for IByteBuffer (#209) 2017-05-12 19:09:50 -07:00
ScarletKuro ee07830122 Implemented Medium, UnsignedMedium (#241) (#244)
Motivation:
In network programming the int24/uint24 is required in some cases

Modifications:
- added MediumUtil class to DotNetty.Common that provides ToMediumInt and ToUnsignedMediumInt
- added GetMedium, GetUnsignedMedium, SetMedium, ReadMedium, ReadUnsignedMedium, WriteUnsignedMedium, WriteMedium to IByteBuffer and their implementation in various buffers
- added SwapMedium to ByteBufferUtil

Result:
- int24/uint24 support
2017-05-12 11:47:14 -07:00
Max Gortman 95f79e1cd2 Porting HashedWheelTimer (#242)
Motivation:
It is a common task to manage various timeouts in networking code. Normal high precision timers usually trade performance for precision which is a flexible requirement with timeouts.

Modifications:
- added HashedWheelTimer
- moved RejectedExecutionException to Common.Concurrency

Result:
- users may choose to use HWT in their code to avoid contentions due to frequent timer management.
2017-05-12 02:35:28 -07:00
Damon Barry 5249d8de2a Make ReadOnlyByteBufferStream seekable (#247) 2017-05-08 17:24:23 -07:00
Johnny Z c79a974400 Changed unit test projects to NET452 required by xunit 2.2.0 (#229) 2017-04-05 10:16:33 -07:00
Krishnendu Ghosh 1d3eda9a74 SNI Support (ported netty SniHandler) (#219)
* First cut commit *unfinished

* Replace SNI handler with TlsHandler with certificate selected based on host name found in clientHello

* first cut tests for SniHandler

* test update

* Test update

* Supress further read when handler is replaced

* made the snitest more effective and IDN in hostname lower case as per netty impl

* More asserts to check whether snihandler gets replaces with tlshaldler in the pipeline

* assert server name is always found in clienthello as per the test setup

* Provided option to select default host name in case of error or client hello does not contail SNI extension, otherwise handshake fails in those cases

* More elaborate tests

* verbosity in test

* Fixed Read continues to get called after handler removed and removed the workaround in SniHandler

* relaced goto statement with flag for breaking outer for loop from within switch

* Update SniHandler.cs

* trigger CI build

* addressed review comments

* Fixed task continuation option

* addresses further review comments

* triggere build again with some more assert in test #221

* suppress read logic is still needed due to async "void"

*  changing the map to (string -> Task<ServerTlsSettings)

* one more constructor overload

* extensive tls read/write test is not needed since that's already done in tlshandler test

* more readable target host validation in test to force retrigger confusing CI build

* retrigger

* addressed review comment "this generates 30 random data frames. pls replace with new [] { 1 }"
2017-03-29 02:27:53 -07:00
Johnny Z 107a1c87b1 Follow up .NET tooling to upgraded packages to latest stable version
1. Microsoft.Extensions.Configuration from 1.1.0 to 1.1.1
2. Microsoft.Extensions.Logging from 1.1.0 to 1.1.1
3. Google.Protobuf from 3.1.0 to 3.2.0
4. Microsoft.NET.Test.Sdk from 15.0.0 preview to 15.0.0
5. XUnit to 2.2.0 release
6. Moq from alpha to 4.7.1
7. NBench from 0.3.4 to 1.0.0
2017-03-21 15:03:36 -07:00
Max Gortman 5ac2fce46d Add ability to limit buffer pool memory capacity (#206)
Motivation:
If pool grows too fast OOM exception may happen.

Modifications:
- add limit on max memory capacity allocated per heap arena, after which allocations are unpooled.
- extra: log exceptions terminating executor loop

Result:
Users have option to limit size of buffer pool.
2017-03-09 19:00:56 -08:00
Alex Valuyskiy 00d656c533 Downgraded to net45 (#197) 2017-02-22 12:23:29 -08:00
Max Gortman 52d1bf34d1 Migrating to new .Net Core RC tooling (#192) 2017-02-09 02:30:48 -08:00
Max Gortman 17a69a0864 FIX: DefaultMachineId doesn't throw; MQTT: buffer release, better string decoding (#175)
Modifications
- algorithm of determining best machine's MAC modified to not throw
- added convenient IReferenceCounted.SafeRelease extension method
- added release for buffers in MQTT codec in case processing fails to ensure release (or proper data flow) of the buffer in all cases
- fixed the way string is decoded in MQTT codec
2016-11-25 01:42:31 -08:00
Johnny Z 44885964bd Socket-based UDP channel transport (#79). (#171)
Motivation:
Ported/Re-implemented DatagramChannel/UDP into DotNetty

Modifications:
- Added DatagramChannel/Config into transport project.
- Added DatagramPacket/DefaultAddressedEnvelop/IAddressedEnvelop into transport project.
- Added DatagramPacketEncoder/DatagramPacketDecoder into Codec project.
- Extra: Ported QuoteOfTheMoment UDP example project.

Result:
DatagramChannel/UDP transport is supported by DotNetty.
2016-11-23 15:45:02 -08:00
Johnny Z 6d1a58df8e Initial Protobuf 2/3 Codec Implementation ( #118) (#163)
Motivation:
Ported/Re-implemented Protobuf codec support into DotNetty

Modifications:
- Added Protobuf 2/3 Codec project
- Added Protobuf 2/3 Codec unit test project.
- Extra: Ported MessageToByteEncoder to DotNetty.Codec.

Result:
Protobuf 2/3 codec supported by DotNetty.
2016-11-16 14:00:06 -08:00
Max Gortman 4f28a55b48 Move to .NET Core tooling (#170)
Motivation
.NET Core tooling allows building for both .NET Framework and .NET Standard while easing pains of running tests and packaging.

Modifications
- csproj -> xproj + project.json
- support for .NET Standard 1.3
- build script is now based on CAKE
- using dotnet CLI for building, testing, packing
- strong name by default (snk included)

Result
DotNetty works on .NET Core and any other platform supporting .NET Standard 1.3+.
2016-11-07 17:50:24 -08:00
Johnny Z 6fc89419c8 Initial Redis Codec Implementation (#161)
Motivation:
Added/Ported Redis codec support into DotNetty

Modifications:
- Added Redis Codec project
- Added Redis Codec unit test project.
- Extra: Added DefaultByteBufferHolder to DotNetty.Buffers.
- Extra: Added UnrealeasableByteBuffer to DotNetty.Buffers.

Result:
Redis codec supported by DotNetty.
2016-10-10 09:57:57 -07:00
Max Gortman 7aef9c7500 Switch to ConcurrentQueue in STEE by default (#160)
Motivation:
as netty moved on to use JCTools directly, it is worth revisiting standard .NET concurrent collection and open queue type election in executor.

Modifications:
- Removed MpscLinkedQueue as redundant (perf is no better than with ConcurrentQueue)
- Introduced CompatibleConcurrentQueue to bridge ConcurrentQueue and IQueue<T> interface, made it the default.
- Updated STEE execution benchmark

Result:
Cleaner solution, less GC pressure from executor actions, ability to specify specialized task queue type (e.g. MpscArrayQueue on server for efficiency (at a cost of extra-mem consumption).
2016-09-07 16:39:03 -07:00
Max Gortman fe25038624 Base64 Encoder/Decoder (+2 squashed commit) (#150)
Squashed commit:

[bb7fb5b] test Decode randomly

[86c9d76] test Decode randomly
2016-08-31 01:27:20 -07:00
egmkang wang 735435be22 Base64 Encoder/Decoder (+2 squashed commit)
Squashed commit:

[bb7fb5b] test Decode randomly

[86c9d76] test Decode randomly
2016-08-27 12:31:24 +08:00
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
Mikhail Tuhckov fb18eaffd7 Exposes SSL Stream and adds more TLS settings (#132)
Motivation:

Some important SSL Stream settings are hidden in the TlsHandler class

Modifications:
SSLStream is provided by user now via factory method;
TLS settings extended

Results:
More advanced scenarios, like X509 client authentication, are possible to do now
2016-06-16 12:07:04 -07:00
Max Gortman 8ab8c8bf0c porting removal of invoker, better decoupling (#125)
Motivation:
Catching up on recent netty changes, simplifying data flow through channel pipeline

Modifications:
- Replaced IChannelHandlerInvoker with direct methods on IChannelHandlerContext implementation.
- Ported changes in AbstractChannel, DefaultChannelPipeline, etc. to reduce coupling through casting.

Result:
IChannelHandlerInvoker is removed, perf improved, it is easier to implement IChannel or IChannelPipeline from scratch.
2016-06-13 12:32:06 -07:00
Max Gortman ff93b80592 Check MQTT packet identifier > 0. Fixes #76 2016-06-01 15:03:19 -07:00
Max Gortman f31c02e346 Fixes TlsHandler from operation, perf and compat POVs.
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.
2016-06-01 14:09:14 -07:00
Max Gortman 0131fa9fe2 Porting adaptive read buffer prediction
Motivation:
Provides good flexible default while lowering memory consumption on average.

Modifications:
- Synced IRecvByteBufAllocator and relevant parts up to date
- Ported AdaptiveRecvByteBufAllocator
- Extra: properly porting ChannelMetadata

Result:
Process of receiving bytes from network is more configurable and allows for both more conservative and more agressive ingestion.
2016-05-31 17:55:07 -07:00
Max Gortman 6cf5cf5499 Adds attribute support in Channel, Bootstrap [#78]
Motivation:
Increasing feature parity and dev convenience through addition of arbitrary data assignment on Channel and related API on Bootstrap classes.

Modifications
- Introduced IAttributeMap, IAttribute<T>, IConstant and related impl artifacts.
- Moved ChannelOption to common constant codebase
- AbstractChannel now inherits from DefaultChannelMap
- Reflection-less child optoins config in ServerBootstrap
- Extra: minor closure allocation fixes, internal API fixes.

Result:
Attributes can be set on Channels, better code portability in Bootstrap.
2016-05-17 17:44:00 -07:00
Max Gortman ebc82c4e2d Moving towards .NET Platform compatibility
Motivation:
Support new versions of .NET, have a core framework that is portable across all .NET platforms.

Modifications:
addressing part of issues reported by portability analyzer

Result:
Easier to introduce .NET Platform compatibility in the future.
2016-05-13 14:16:26 -07:00
Max Gortman 8114b7fb21 Fixing minor issues and code style throughout
Motivation:
Modern language features provide for easier to read, more compact code.

Modifications:
- expression body for single line methods
- Extra: fixes in xml docs
- Extra: code style deviations in recent commits

Result:
Cleaner, more consistent code.
2016-05-13 12:18:04 -07:00
Aaron Stannard e2dad0e71a added inbound only TcpSocketChannel benchmark 2016-05-13 08:59:25 -07:00