Commit Graph

5861 Commits

Author SHA1 Message Date
Norman Maurer
535b024913 [#2323] Make it clear a Channel must be closed to release all resources
Motivation:
Ensure the user know the Channel must be closed to release resources like filehandles.

Modifications:
Add some extra javadoc.

Result:
More clear documentation
2014-03-16 06:56:49 -07:00
Norman Maurer
b22d92057b [#2262] Fix NPE triggered by unresolveable InetSocketAddress in epoll transport
Motivation:
At the moment when an unresolvable InetSocketAddress is passed into the epoll transport a NPE is thrown

Modifications:
Add check in place which will throw an UnknownHostException if an InetSocketAddress could not been resolved.

Result:
Proper handling of unresolvable InetSocketAddresses
2014-03-16 06:25:52 -07:00
Frederic Bregier
55bafbd9c2 [#2305] Fix issue related to decoding post request raized an exception due to a split of information by chunk not correctly taken into account by the decoder
Motivation:

If the last item analyzed in a previous received HttpChunk/HttpContent was a part of an attribute's name, the read index was not set to the new right place and therefore raizing an exception in some case (since the "new" name analyzed is empty, which is not allowed so the exception).

What appears there is that the read index should be reset to the last valid position encountered whatever the case. Currently it was set when only when there is an attribute not already finished (name is ok, but content is possibly not).

Therefore the issue is that elements could be rescanned multiple times (including completed elements) and moreover some bad decoding can occur such as when in a middle of an attribute's name.

Modifications:

To fix this issue, since "firstpos" contains the last "valid" read index of the decoding (when finding a '&', '=', 'CR/LF'), we should add the setting of the read index for the following cases:

'lastchunk' encountered, therefore finishing the current buffer
any other cases than current attribute is not finished (name not found yet in particular)
So adding for this 2 cases:

undecodedChunk.readerIndex(firstpos);

Result:

Now the decoding is done once, content is added from chunk/content to chunk/content, name is decoded correctly even if in the middle of 2 chunks/contents.
A Junit test code was added: testChunkCorrect that should not raized any exception.
2014-03-14 09:36:50 +01:00
Bourne, Geoff
1c074eabe5 Fix limit computation of NIO ByteBuffers obtained via ReadOnlyByteBufferBuf.nioBuffer
Motivation:

When starting with a read-only NIO buffer, wrapping it in a ByteBuf,
and then later retrieving a re-wrapped NIO buffer the limit was getting
too short.

Modifications:

Changed ReadOnlyByteBufferBuf.nioBuffer(int,int) to compute the
limit in the same manner as the internalNioBuffer method.

Result:

Round-trip conversion from NIO to ByteBuf to NIO will work reliably.
2014-03-14 08:07:19 +01:00
Norman Maurer
92037e8bea [#2307] Remove synchronized bottleneck in SingleThreadEventExecutor.execute(...)
Motivation:
Remove the synchronization bottleneck in startThread() which is called by each execute(..) call from outside the EventLoop.

Modifications:
Replace the synchronized block with the use of AtomicInteger and compareAndSet loops.

Result:
Less conditions during SingleThreadEventExecutor.execute(...)
2014-03-13 09:45:05 +01:00
Norman Maurer
d4d2085377 Remove sniffer whitelist entries for NIO.2
Motivation:
Cleanup pom.xml file.

Modifications:
Remove sniffer whitelist entries for NIO.2 as we not include a NIO.2 bases transport anymore.

Result:
Less entries in pom.xml
2014-03-13 06:58:36 +01:00
Norman Maurer
e0b2f34a37 [#2308] Use SelectorProvider.open*() to open NIO channels and so remove condition when create new NIO channels.
Motivation:
At the moment we use SocketChannel.open(), ServerSocketChannel.open() and DatagramSocketChannel.open(...) within the constructor of our
NIO channels. This introduces a bottleneck if you create a lot of connections as these calls delegate to SelectorProvider.provider() which
uses synchronized internal. This change removed the bottleneck.

Modifications:
Obtain a static instance of the SelectorProvider and use SelectorProvider.openSocketChannel(), SelectorProvider.openServerSocketChannel() and
SelectorProvider.openDatagramChannel(). This eliminates the bottleneck as SelectorProvider.provider() is not called on every channel creation.

Result:
Less conditions when create new channels.
2014-03-13 06:46:05 +01:00
Norman Maurer
f396f40db9 Fix checkstyle errors introduced by f0d1bbd63e 2014-03-12 13:57:01 +01:00
Norman Maurer
ef76907422 Remove condition in ChannelHandlerAdapter.isSharable() by caching the result of the annotation lookup.
Motivation:
Remove the synchronization bottleneck and so speed up things

Modifications:
Introduce a ThreadLocal cache that holds mappings between classes of ChannelHandlerAdapater implementations and the result of checking if the @Sharable annotation is present.
This way we only will need to do the real check one time and server the other calls via the cache. A ThreadLocal and WeakHashMap combo is used to implement the cache
as this way we can minimize the conditions while still be sure we not leak class instances in containers.

Result:
Less conditions during adding ChannelHandlerAdapter to the ChannelPipeline
2014-03-12 12:31:22 +01:00
Trustin Lee
8d2ddae4a7 Add capacity limit to Recycler / Optimize when assertion is off
Motivation:

- As reported recently [1], Recycler's thread-local object pool has unbounded capacity which is a potential problem.
- It accesses a hash table on each push and pop for debugging purposes.  We don't really need it besides debugging Netty itself.

Modifications:

- Introduced the maxCapacity constructor parameter to Recycler.  The default default maxCapacity is retrieved from the system property whose default is 256K, which should be plenty for most cases.
- Recycler.Stack.map is now created and accessed only when assertion is enabled for Recycler.

Result:

- Recycler does not grow infinitely anymore.
- If assertion is disabled, Recycler should be much faster.

[1] https://github.com/netty/netty/issues/1841
2014-03-12 18:17:24 +09:00
Norman Maurer
ef69c4592b Revert "ipfilter implementation for netty 4/5 [#2129]"
Motivation:
ipfilter implementation may need a bit more time to stabilize.

Modifications:
Revert the commit that added it to 4.0 branch (it is still included in 4.1 and master)

Result:
ipfilter will not be included in the next 4.0.x release (just as before9
2014-03-12 06:26:50 +01:00
Trustin Lee
8e2de4fcb2 Move the pull request guide to the developer guide
Motivation:

CONTRIBUTING.md is useful only because it lets Github show a user the
link to it so the user can check what information we need before
submitting a bug report.  However, Github does not do the same for a
pull request submission form, and thus there's no reason to keep the
information about how to submit a good pull request in CONTRIBUTING.md.

Modification:

Replace the section about issuing a pull request with the link to the
official developer guide.

Result:

CONTRIBUTING.md is easier to maintain.
2014-03-12 13:18:14 +09:00
Norman Maurer
072c5e3cc6 Use bitwise operations to choose next EventExecutor if number of EventExecutors is power of two 2014-03-10 20:46:59 +01:00
Jakob Buchgraber
ae20f278ff ipfilter implementation for netty 4/5 [#2129] 2014-03-10 20:46:05 +01:00
Norman Maurer
fc5d20ff2d [#2297] Correctly close all registered Channels on EpollEventLoop.closeAll() 2014-03-10 20:27:44 +01:00
David Dossot
3c7ef6ffce added support for empty query parameters 2014-03-10 06:49:00 +01:00
Norman Maurer
ae818b3be6 Fix buffer leak in test which was introduced while implement ZLIB_OR_NONE support. Related to [#2269] 2014-03-10 06:24:53 +01:00
Aaron Riekenberg
223deb255e [#2280] Correct logic in Native.finishConnect. Fix use of optval parameter in c getOption function. In epoll event loop, check that channel is open before processing event. 2014-03-09 19:37:32 +01:00
Chris Mowforth
3c1bcb7279 Add content length and date headers to CORS response 2014-03-06 21:00:10 +01:00
Norman Maurer
835c446f5f Fix buffer leak in test which was introduced while implement ZLIB_OR_NONE support. Related to [#2269] 2014-03-06 20:03:40 +01:00
Trustin Lee
2b47058644 Update CONTRIBUTING.md 2014-03-07 01:54:32 +09:00
Trustin Lee
5ef79e942e Add CONTRIBUTING.md
Motivation:
We often receive a bug report or a pull request which do not give us
enough information.  If CONTRIBUTING.md exists in the repository, Github
will display some notice in the beginning of the issue submission form,
which might increase the overall quality of the bug reports and pull
requests.

Modification:
Write CONTRIBUTING.md

Result:
Potentially higher-quality bug reports and pull requests
2014-03-07 01:54:32 +09:00
Norman Maurer
641b6e5bbe Ensure the HttpResponseEncoder is always placed before the HttpObjectAggregator. Part of [#2219] 2014-03-05 06:56:21 +01:00
Norman Maurer
c838790400 Corrected inconsistencies in the Javadoc.
Port of 80030493b9f7824c02dc88260c2579afc0aed8bc
2014-03-04 06:34:14 +01:00
Jatinder
6e1cee654f [#2252] Fix bug where AppendableCharSequence private constructor does not set correct position 2014-03-03 19:58:22 +01:00
Norman Maurer
6513859a79 [#2261] Correct javadoc of ChunkedInput 2014-03-03 07:03:58 +01:00
Jakob Buchgraber
216fce193b Added a secure WebSocket client example
Merged WebSocketClient and WebSocketSslClient

Add private constructors to fix checkstyle errors.

More checkstyle madness.

made WebSocketClientRunner final
2014-03-03 06:49:30 +01:00
Andrew Gaul
6454cc003a Correct ConcurrentHashMapV8 bitwise arithmetic
Previously ConcurrentHashMapV8 evaulated ((x | 1) == 0), an expression
that always returned false.  This commit brings Netty closer to the
Java 8 implementation.
2014-03-03 06:44:56 +01:00
Jakob Buchgraber
15d28f0c59 Added asserts to make sure ChannelHandlers are removed from the pipeline 2014-03-03 06:43:32 +01:00
Jakob Buchgraber
2062e774eb Add ZLIB_OR_NONE support to JdkZlibDecoder [#2016] 2014-03-03 06:31:06 +01:00
Dao Ngoc
98d81b285c Fix #2275 %s WebSocket version %s server handshake 2014-02-28 17:19:30 -08:00
Norman Maurer
bdedde1294 [#1259] Add optimized queue for SCMP pattern and use it in NIO and native transport
This queue also produces less GC then CLQ when make use of OneTimeTask
2014-02-27 11:44:06 +01:00
Trustin Lee
927e330cfe Fix a compilation error 2014-02-26 16:44:17 -08:00
Trustin Lee
8ffa168ab8 Fix checkstyle 2014-02-26 16:18:32 -08:00
Trustin Lee
0d210f45f2 Fix a bug where HttpObjectDecoder generates two LastHttpContent consecutively
Motivation:
When an HttpResponseDecoder decodes an invalid chunk, a LastHttpContent instance is produced and the decoder enters the 'BAD_MESSAGE' state, which is not supposed to produce a message any further.  However, because HttpObjectDecoder.invalidChunk() did not clear this.message out to null, decodeLast() will produce another LastHttpContent message on a certain situation.

Modification:
Do not forget to null out HttpObjectDecoder.message in invalidChunk(), and add a test case for it.

Result:
No more consecutive LastHttpContent messages produced by HttpObjectDecoder.
2014-02-26 15:54:33 -08:00
Norman Maurer
ccd135df01 [maven-release-plugin] prepare for next development iteration 2014-02-24 15:39:26 +01:00
Norman Maurer
33587eb183 [maven-release-plugin] prepare release netty-4.0.17.Final 2014-02-24 15:37:31 +01:00
Michael Nitschinger
b3b73be61c Upgrade JMH to 0.4.1 and make use of @Params. 2014-02-23 16:40:04 +01:00
cmcmaugh
d21197e0fc Apply receive timeout to commPort when using RxtxChannel. Part of [#1390] 2014-02-23 16:34:17 +01:00
Norman Maurer
c538fd5098 Fix check to clear READ_OP and EPOLLIN. Part of [#2254] 2014-02-22 20:06:35 +01:00
Norman Maurer
b00e2a19d3 [#2254] Correctly handle Channel.read() and ChannelHandlerContext.read()
This includes also when it is called from channelRead(...) and channelReadComplete(...) methods.
2014-02-22 18:45:36 +01:00
Trustin Lee
0fc66a411f The default buffer must be unpooled for backward compatibility
Mistakenly set to pooled while merging the changes from 4.1 and master.
2014-02-21 14:43:07 -08:00
Norman Maurer
7fe10fe635 [#2254] Fix regression in handling autoRead and Channel.read()
This regression was introduced by e0b39159657c9eb711047bc32367537c4870d467
2014-02-21 08:39:41 +01:00
Trustin Lee
5c27273885 Avoid unnecessary IllegalStateException in ChunkedWriteHandler
Motivation:
ChunkedWriteHandler can sometimes fail to write the last chunk of a ChunkedInput due to an I/O error.  Subsequently, the ChunkedInput's associated promise is marked as failure and the connection is closed.  When the connection is closed, ChunkedWriteHandler attempts to clean up its message queue and to mark their promises as success or failure.  However, because the promise of the ChunkedInput, which was consumed completely yet failed to be written, is already marked as failure, the attempt to mark it as success fails, leading a WARN level log.

Modification:
Use trySuccess() instead of setSuccess() so that the attempt to mark a ChunkedInput as success does not raise an exception even if the promise is already done.

Result:
Fixes #2249
2014-02-20 17:14:53 -08:00
Jeff Pinner
d838a07c14 SPDY: remove SPDY/3 support 2014-02-20 15:00:04 -08:00
Norman Maurer
66e2bb1e75 [maven-release-plugin] prepare for next development iteration 2014-02-19 03:41:24 +01:00
Norman Maurer
c466bb803d [maven-release-plugin] prepare release netty-4.0.16.Final 2014-02-19 03:36:54 +01:00
Norman Maurer
e74b5fc2fa Fix a regression which could lead to GenericFutureListeners never been notifed. Part of [#2186].
This regression was introduced by commit c97f2d2de00ad74835067cb6f5a62cd4651d1161
2014-02-20 15:01:09 +01:00
Trustin Lee
f120b6c390 Fix a bug where HttpObjectAggregator doesn't always produce FullHttpMessage
- Fixes #2182
- Always convert an unfull invalid message to a full message
2014-02-19 15:33:42 -08:00
Trustin Lee
00d982994c Ensure that the last bad chunk is LastHttpChunk 2014-02-19 15:20:48 -08:00