3342 Commits

Author SHA1 Message Date
Trustin Lee
4cff4b99fd Add OpenSslEngine
Motivation:

Some users already use an SSLEngine implementation in finagle-native. It
wraps OpenSSL to get higher SSL performance.  However, to take advantage
of it, finagle-native must be compiled manually, and it means we cannot
pull it in as a dependency and thus we cannot test our SslHandler
against the OpenSSL-based SSLEngine.  For an instance, we had #2216.

Modifications:

- Pull netty-tcnative in as an optional dependency.
  http://netty.io/wiki/forked-tomcat-native.html
- Backport NativeLibraryLoader from 4.0
- Move OpenSSL-based SSLEngine implementation into our code base.
  - Copied from finagle-native; originally written by @jpinner et al.
  - Overall cleanup by @trustin.
- Run all SslHandler tests with both default SSLEngine and OpenSslEngine
2014-05-13 19:04:54 +09:00
Norman Maurer
ef9ee90b1a Minimize memory footprint of HashedWheelTimer and context-switching
Motivation:
At the moment there are two issues with HashedWheelTimer:
 * the memory footprint of it is pretty heavy (250kb fon an empty instance)
 * the way how added Timeouts are handled is inefficient in terms of how locks etc are used and so a lot of context-switching / condition can happen.

Modification:
Rewrite HashedWheelTimer to use an optimized bucket implementation to store the submitted Timeouts and a queue to handover the timeouts.  So memory foot-print of the buckets itself is reduced a lot as the bucket uses a double-linked-list. Beside this we use Atomic*FieldUpdater where-ever possible to improve the memory foot-print and performance.

Result:
Lower memory-footprint and better performance
2014-05-11 15:52:48 +02:00
Trustin Lee
b954f6e85d Upgrade netty-build to 20
- Preparation for merging openssl branch
- Also upgrade oss-parent to the latest version
2014-05-07 22:47:56 +09:00
Jeff Pinner
b58277e079 SPDY: ensure SpdyHeaderBlockRawDecoder always reads entire input 2014-05-05 09:50:04 +02:00
Norman Maurer
00bf5eb898 [maven-release-plugin] prepare for next development iteration 2014-04-30 15:46:20 +02:00
Norman Maurer
1e4fa0565a [maven-release-plugin] prepare release netty-3.9.1.Final netty-3.9.1.Final 2014-04-30 15:46:14 +02:00
Norman Maurer
48edb7802b Remove ContinuationWebSocketFrame.aggregatedText()
Motivation:
Before we aggregated the full text in the WebSocket08FrameDecoder just to fill in the ContinuationWebSocketFrame.aggregatedText(). The problem was that there was no upper-limit and so it would be possible to see an OOME if the remote peer sends a TextWebSocketFrame + a never ending stream of ContinuationWebSocketFrames. Furthermore the aggregation does not really belong in the WebSocket08FrameDecoder, as we provide an extra ChannelHandler for this anyway (WebSocketFrameAggregator).

Modification:
Remove the ContinuationWebSocketFrame.aggregatedText() method and corresponding constructor. Also refactored WebSocket08FrameDecoder a bit to me more efficient which is now possible as we not need to aggregate here.

Result:
No more risk of OOME because of frames.
2014-04-30 14:25:54 +02:00
Norman Maurer
3a8ddc9963 Correctly write pending data after ssl handshake completes. Related to [#2437]
Motivation:
When writing data from a server before the ssl handshake completes may not be written at all to the remote peer
if nothing else is written after the handshake was done.

Modification:
Correctly try to write pending data after the handshake was complete

Result:
Correctly write out all pending data
2014-04-30 14:17:57 +02:00
Norman Maurer
4a9b7799bc [#2428] Proper fix of incorrect port range check
Motivation:

In the Internet Protocol, the valid port number range is from 1 to 65535
(inclusive on the both side.)  However, SocksCmdRequest and SocksCmdResponse
refuses to construct itself when the port number 65535 is specified. Beside
this it excepts 0 as port number which should not allowed.

Modification:

* Not raise an exception when the specified port number is 65535.
* Raise an exception when the specified port number is 0

Result:

Fixes #2428
2014-04-30 08:13:12 +02:00
Trustin Lee
6398964b89 Fix incorrect port range check
Motivation:

In the Internet Protocol, the valid port number range is from 1 to 65535
(inclusive on the both side.)  However, SocksCmdRequest refuses to
construct itself when the port number 65535 is specified.

Modification:

Do not raise an exception when the specified port number is 65535.

Result:

Fixes #2428
2014-04-29 18:00:40 +09:00
Norman Maurer
eb4090b904 [#2434] Correctly shutdown bossExecutor in OioServerSocketChannelFactory
Motivation:
At the moment the bossExecutor is not shutdown correctly. So the threads may never exit.

Modifications:
Correctly shutdown bossExecutor.

Result:
Threads are correctly stopped.
2014-04-27 20:51:50 +02:00
Trustin Lee
07266cbd0b Better names for SslHandler.unwrap*() methods
Motivation:

The names of SslHandler.unwrap*() methods are somewhat ambiguous.

Modifications:

- Rename unwrap() to unwrapMultiple() and unwrapNonApp()
- Rename unwrap0() to unwrapSingle()

Result:

Readability
2014-04-20 17:20:00 +09:00
Trustin Lee
18b0e95659 Feed only a single SSL record to SSLEngine.unwrap()
Motivation:

Some SSLEngine implementations violate the contract and raises an
exception when SslHandler feeds an input buffer that contains multiple
SSL records to SSLEngine.unwrap(), while the expected behavior is to
decode the first record and return.

Modification:

Modify SslHandler.decode() to keep the lengths of each record and feed
SSLEngine.unwrap() record by record to work around the forementioned
issue.

Result:

SslHandler now works OpenSSLEngine from finagle-native.  Performance
impact remains unnoticeable.  Fixes #2116
2014-04-20 16:17:28 +09:00
Trustin Lee
dbb9231ea8 Work around an Android SSLEngine issue
Motivation:

Some Android SSLEngine implementations skip FINISHED handshake status
and go straightly into NOT_HANDSHAKING.  This behavior blocks SslHandler
from notifying its handshakeFuture, because we do the notification when
SSLEngine enters the FINISHED state.

Modification:

When the current handshake state is NOT_HANDSHAKING and the
handshakeFuture is not fulfilled yet, treat NOT_HANDSHAKING as FINISHED.

Result:

Better Android compatibility
2014-04-18 17:52:09 +09:00
Jeff Pinner
a0f00b54b1 SPDY: refactor frame codec implementation
Motivation:

Currently, the SPDY frame encoding and decoding code is based upon
the ChannelHandler abstraction. This requires maintaining multiple
versions for 3.x and 4.x (and possibly 5.x moving forward).

Modifications:

The SPDY frame encoding and decoding code is separated from the
ChannelHandler and SpdyFrame abstractions. Also test coverage is
improved.

Result:

SpdyFrameCodec now implements the ChannelHandler abstraction and is
responsible for creating and handling SpdyFrame objects.
2014-04-16 20:35:50 +02:00
Frederic Bregier
ac19593a96 Fix Junit test for V3.9 and issue #2305
Motivation:
The Junit test for issue #2305 was incomplete for V3.9 since the request was not setup using setChunked(true) and therefore the chunks were ignored.

Modifications:
Add the chunk true property to the request and add the final LAST_CHUNK to the chunks offered to the decoder.

Result:
Now the request is correctly and fully decoded by the decoder in this Junit test case.
2014-03-16 05:49:15 -07:00
Frederic Bregier
7d5c9e715e [#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:50:53 +01:00
Trustin Lee
cb9fe47d98 Make sure GZIP header is written even if nothing was written
Motivation:

JdkZlibEncoder does not generate a GZIP header when a user does not write anything at all, ending up with a 10-byte footer only.

Modification:

Modify finishEncode() method to write the GZIP header if it was not written before.

Result:

Encoding 0-byte content result in 20-byte GZIP stream now.
2014-03-13 14:05:30 +09:00
jbertram
5604c6a6a0 Simple retry mechanism to cope with a temporarily unavailable endpoint
Motivation:
Use simple retry mechanism when try to connect to peer so a slow-startup will not produce an error

Modification:
Add new Servlet params which allow to configure retry count and wait time. Default behaviour is the same as before

Result:
It is now possible to configure retry when the peer is not up yet and the Servlet is init.
2014-03-12 07:00:19 +01:00
Trustin Lee
ca32b717e2 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:38 +09:00
Trustin Lee
d4382e8405 Update CONTRIBUTING.md 2014-03-07 01:54:59 +09:00
Trustin Lee
3cf4638255 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:59 +09:00
Jeff Pinner
a3bff7b89e SPDY: remove SPDY/3 support 2014-02-20 14:52:22 -08:00
Norman Maurer
527347094a [#2223] Need to make sure that the close() triggeres an upstream event in all cases 2014-02-11 16:45:21 +01:00
Norman Maurer
9a4f005e2a [#2221] Remove duplicated release of pools 2014-02-11 15:22:51 +01:00
Frederic Bregier
8837857fae Same fix for Netty 3.9 than from Allow an HTML5 encoder mode for HttpPostRequestEncoder #2081 2014-02-10 15:40:19 +01:00
Trustin Lee
8b40cfaa67 Prefer interface to implementation in type declaration
This fixes the build failure with JDK 8
2014-02-08 08:48:35 -08:00
Trustin Lee
0830c42420 Should log at WARN level instead when failed to close a file. 2014-01-24 16:46:36 +09:00
Trustin Lee
3c2647d094 Add debug log message on deletion failure 2014-01-24 16:42:48 +09:00
Frederic Bregier
8bb0a131a7 Fix fileChannel not closed, preventing delete to occur correctly 2014-01-24 16:40:05 +09:00
Trustin Lee
113c264d43 Somewhat more ambiguous yet not-incorrect caller thread description
- Netty 3 has inconsistent thread model that's not easy to document, so I would not spend too much effort on this.
2014-01-21 15:00:44 +09:00
Frederic Bregier
b037eda614 Fix try to delete file while it does not exist anymore (see #2102 and #1713) in reference to this issue (3.9) 2014-01-21 14:15:22 +09:00
Trustin Lee
743c035ebb Backport the HttpPostRequestEncoder fixes by @igstan / Inspector warning 2014-01-19 22:29:53 +09:00
Trustin Lee
1012160288 Fix incorrect documentation about thread model
- Fixes #2130
2014-01-19 14:00:32 +09:00
Trustin Lee
ca4eb04dc5 Add README.md 2014-01-16 14:40:07 +09:00
Trustin Lee
2c6be36647 Fix inspector warnings 2014-01-13 23:07:03 +09:00
Trustin Lee
d29e155648 Fix inspector warnings 2014-01-13 22:45:49 +09:00
Trustin Lee
cc842817a1 Fix inspector warnings 2014-01-13 18:18:43 +09:00
wgallagher
4c35b593c1 Fix a bug where SpdyHeaderBlockZlibDecoder fails to decompress
- Fixes #2077
2014-01-13 18:04:01 +09:00
Trustin Lee
2bc252f22b Deprecate specifying an alternative Executor for delegated tasks for SslHandler / Fix a problem where SslHandler consumes too much CPU until the delegated task is finished. 2014-01-09 17:58:51 +09:00
Trustin Lee
013b57f1c1 Fix Java 5 source compatibility issue / Inspector warnings 2014-01-09 15:16:30 +09:00
Trustin Lee
8198f23dbb Fix a regression in SslHandler where delegated tasks run in a different executor makes the session hang
- Fixes #2098
2014-01-09 15:13:31 +09:00
Trustin Lee
fc9a794613 [maven-release-plugin] prepare for next development iteration 2013-12-22 19:45:29 +09:00
Trustin Lee
a06d4dddd5 [maven-release-plugin] prepare release netty-3.9.0.Final netty-3.9.0.Final 2013-12-22 19:45:19 +09:00
Trustin Lee
f438eb348a Use LinkedHashSet for HttpHeaders.names() and add Javadoc about the performance of names() and entries() 2013-12-22 19:21:07 +09:00
Trustin Lee
7347bfec50 Optimize SslHandler.unwrap() so that it doesn't produce unnecessarily many buffers
- Adapted from 4c7fa950cc4f4c52eeaae5887335b1f3047592f8
- Related issue: #1905
2013-12-16 21:01:24 +09:00
Frederic Bregier
92bcbcd0e1 Add support for 'charset' property for multipart boundaries
- Fixes #2004
2013-12-16 14:32:34 +09:00
Koen Serry
07f41e8db3 [#1996] Remove bogus jboss-beans.xml 2013-12-14 14:13:15 +01:00
Norman Maurer
2e6c22d272 Merge pull request #2063 from jpinner/spdy_minor_version
SPDY: add SETTINGS_MINOR_VERSION
2013-12-14 05:11:41 -08:00
Jeff Pinner
d4bdcefe17 SPDY: add SETTINGS_MINOR_VERSION 2013-12-13 12:09:45 -08:00