Commit Graph

190 Commits

Author SHA1 Message Date
Norman Maurer
8a7bc2c606 Add a lot of javadocs to make usage more clear 2012-12-21 22:22:40 +01:00
Norman Maurer
42a77eda9b And again javadocs cleanup 2012-12-21 07:35:42 +01:00
Norman Maurer
d2060ee3f1 Add more javadocs 2012-12-20 15:45:49 +01:00
Norman Maurer
a1baeeb8c0 Mark IdleStateEvent as final and add javadocs 2012-12-20 15:45:35 +01:00
Norman Maurer
1f9d165583 [#836] Correctly reset timeout on sendFile(...) 2012-12-19 21:16:41 +01:00
Norman Maurer
695665a4cf More javadocs fixes 2012-12-19 21:08:47 +01:00
Norman Maurer
db0459ea9c Fix javadocs of IdleStateHandler 2012-12-19 16:25:31 +01:00
Norman Maurer
d9b26dab29 Remove get*() from the methods to match the rest of our method signatures 2012-12-19 15:38:17 +01:00
Norman Maurer
a1368f0fa8 Some javadocs fixed to remove dead links 2012-12-19 15:36:07 +01:00
Norman Maurer
77c01d252e Fix visibily of ImmediateExecutor and add private constructor 2012-12-19 15:31:07 +01:00
Norman Maurer
11047aaa69 [#832] Add javadocs which explains how to workaround the problem 2012-12-19 15:17:10 +01:00
Trustin Lee
def12a171c Rename ChannelBuf to Buf and ChannelBufType to BufType
- Fixes #825
2012-12-17 17:43:45 +09:00
Trustin Lee
03e68482bb Remove ChannelBuf/ByteBuf.Unsafe
- Fixes #826
Unsafe.isFreed(), free(), suspend/resumeIntermediaryAllocations() are not that dangerous. internalNioBuffer() and internalNioBuffers() are dangerous but it seems like nobody is using it even inside Netty. Removing those two methods also removes the necessity to keep Unsafe interface at all.
2012-12-17 17:41:21 +09:00
Trustin Lee
51e6519b67 Replace UnsafeByteBuf with ByteBuf.unsafe() again
* UnsafeByteBuf is gone. I added ByteBuf.unsafe() back.
* To avoid extra instantiation, all ByteBuf implementations implement the ByteBuf.Unsafe interface.
* To hide this implementation detail, all ByteBuf implementations are package-private.
* AbstractByteBuf and SwappedByteBuf are public and they do not implement ByteBuf.Unsafe because they don't need to.
* unwrap() is not an unsafe operation anymore.
* ChannelBuf also has unsafe() and Unsafe. ByteBuf.Unsafe extends ChannelBuf.unsafe(). ChannelBuf.unsafe() provides free() operation so that a user does not need to down-cast the buffer in freeInbound/OutboundBuffer().
2012-12-05 19:28:56 +09:00
Trustin Lee
33c0c89fef Remove unnecessary empty lines 2012-12-03 19:58:13 +09:00
Trustin Lee
81e2db10fa ByteBufAllocator API w/ ByteBuf perf improvements
This commit introduces a new API for ByteBuf allocation which fixes
issue #643 along with refactoring of ByteBuf for simplicity and better
performance. (see #62)

A user can configure the ByteBufAllocator of a Channel via
ChannelOption.ALLOCATOR or ChannelConfig.get/setAllocator().  The
default allocator is currently UnpooledByteBufAllocator.HEAP_BY_DEFAULT.

To allocate a buffer, do not use Unpooled anymore. do the following:

  ctx.alloc().buffer(...); // allocator chooses the buffer type.
  ctx.alloc().heapBuffer(...);
  ctx.alloc().directBuffer(...);

To deallocate a buffer, use the unsafe free() operation:

  ((UnsafeByteBuf) buf).free();

The following is the list of the relevant changes:

- Add ChannelInboundHandler.freeInboundBuffer() and
  ChannelOutboundHandler.freeOutboundBuffer() to let a user free the
  buffer he or she allocated. ChannelHandler adapter classes implement
  is already, so most users won't need to call free() by themselves.
  freeIn/OutboundBuffer() methods are invoked when a Channel is closed
  and deregistered.

- All ByteBuf by contract must implement UnsafeByteBuf. To access an
  unsafe operation: ((UnsafeByteBuf) buf).internalNioBuffer()

- Replace WrappedByteBuf and ByteBuf.Unsafe with UnsafeByteBuf to
  simplify overall class hierarchy and to avoid unnecesary instantiation
  of Unsafe instances on an unsafe operation.

- Remove buffer reference counting which is confusing

- Instantiate SwappedByteBuf lazily to avoid instantiation cost

- Rename ChannelFutureFactory to ChannelPropertyAccess and move common
  methods between Channel and ChannelHandlerContext there. Also made it
  package-private to hide it from a user.

- Remove unused unsafe operations such as newBuffer()

- Add DetectionUtil.canFreeDirectBuffer() so that an allocator decides
  which buffer type to use safely
2012-11-22 15:10:59 +09:00
Trustin Lee
ea4a0e3535 Prefer {@code ...} to <code>...</code> / Fix deprecation warnings 2012-11-12 11:51:23 +09:00
Trustin Lee
a07fb94fe7 Prefer "str".equals(var) to var.equals("str") / Add proper null checks 2012-11-12 08:59:54 +09:00
Trustin Lee
86b777a919 [#710] flush() requests made before SSL handshake completion are not executed after completion
- Ensure SslHandler flushes its outbound buffer on handshake completion
- Enable SSL in HttpSnoopClient example
2012-11-05 16:37:40 +09:00
Norman Maurer
fb6ce4989a Javadoc fixes 2012-10-26 22:38:06 +02:00
Trustin Lee
951c49f449 [#644] SslHandler should not defer channelActive event
- otherwise a user will have a misconception about the life cycle of the actual connection.
2012-10-16 15:19:34 -07:00
Norman Maurer
9e6c616c35 Introduce helper method to detect if a buffer is encrypted. See #657 2012-10-16 13:44:30 +02:00
Norman Maurer
d504d78cb1 Fix checkstyle 2012-10-13 09:21:40 +02:00
ab
ce88ae3889 Ensure that either SslHandler's handshake timeout or the handshake
itself (or its failure) take place but not both.
2012-10-10 14:16:13 +02:00
Trustin Lee
7514a82c35 Disable timeouts if they are set to 0 2012-09-28 13:52:05 +09:00
Trustin Lee
817309c7c8 Remove magic numbers from SslHandler 2012-09-27 19:28:41 +09:00
Trustin Lee
a3f25da228 Remove unused parameter 2012-08-29 12:28:01 +09:00
norman
3aaf7cf82b [#160] Make sure the exception is fired before the channel gets closed 2012-08-22 07:56:39 +02:00
Trustin Lee
00188a2923 [#160] No response to write if server is using SslHandler and client is not
- Make SslHandler close the connection on SSLException or NotSslRecordException
2012-08-22 13:38:09 +09:00
Trustin Lee
2bb114bcb7 [#504] SslHandler.flush() notifies futures prematurely.
- Make use of ChannelFlushFutureNotifier to notify flush futures
  correctly
- Improve the test case to ensure this commit fixes the bug
2012-08-19 17:36:58 +09:00
Trustin Lee
a2aadef4da Add ByteBuf.Unsafe.discardSomeReadBytes() to reduce discardReadBytes() 2012-08-08 17:34:00 +09:00
Norman Maurer
9b37de32a0 Merge pull request #465 from izstas/master
Add TRACE level to Internal Logger
2012-07-28 12:06:09 -07:00
izstas
62ed610c1d Added TRACE level for LoggingHandler 2012-07-19 16:15:36 +04:00
Trustin Lee
5a613f379e Make ByteBuf dynamic / Introduce an interface for composite buffers
- Replace ByteBufferBackedByteBuf with DirectByteBuf
- Make DirectByteBuf and HeapByteBuf dynamic
- Remove DynamicByteBuf
- Replace Unpooled.dynamicBuffer() with Unpooled.buffer() and
  directBuffer()
- Remove ByteBufFactory (will be replaced with ByteBufPool later)
- Add ByteBuf.Unsafe (might change in the future)
2012-07-19 20:25:47 +09:00
Trustin Lee
353c6607ed Add more constructors to NotSslRecordException 2012-07-10 22:26:52 +09:00
Trustin Lee
3fff8ce1d6 Fixed a bug where SslHandler does not sometimes forward a flush request 2012-07-08 15:11:46 +09:00
Trustin Lee
cef7dfc02f Made the AIO transport adhere to Netty thread model strictly
- Fixed data races
- Simplified channel creation using dummy AsyncChannelGroup
2012-07-08 00:53:56 +09:00
norman
b9781c968c Optimize SslHandler's detection of supressable exceptions, so it will not break on different OS's or jdk impls. See #79 2012-07-05 09:37:26 +02:00
norman
db09c421d9 Optimize SslHandler's detection of supressable exceptions, so it will not break on different OS's or jdk impls. See #79 2012-07-05 09:18:59 +02:00
norman
e40c430976 Throw a special SSLException if a non SSL/TLS record was detected. See #437 2012-07-05 07:53:29 +02:00
norman
d0e83520cc Add getters for the specified timeout values. See #418 2012-07-03 10:18:57 +02:00
Trustin Lee
7e75a9a1a9 Fix a bug where timeout handlers sometimes generate events too early 2012-06-18 13:38:59 +09:00
Trustin Lee
dfce95dd5a Remove unused type 2012-06-12 18:09:05 +09:00
Trustin Lee
61e357049e Remove BlockingReadHandler from master
- As mentioned in the developer group:
  - https://groups.google.com/d/topic/netty/ZT0zaZ56eoU/discussion
2012-06-12 17:42:36 +09:00
Trustin Lee
ecd0ae5406 Prefer MessageBuf over Queue where possible
- Also replaced thread safe queues with non-thread-safe ones where
  possible
- Unpooled.wrappedBuffer(Queue<T>) does not wrap MessageBuf anymore
2012-06-12 17:02:00 +09:00
Trustin Lee
6211e53e86 Code clean-up based on IntelliJ code analysis 2012-06-11 22:54:28 +09:00
Trustin Lee
876847fd20 Merge MessageBufs and ByteBufs into Unpooled
- e.g. Unpooled.messageBuffer()
- It will make much more sense once we introduce pooling:
  - i.e. Pooled.buffer()
2012-06-11 17:02:29 +09:00
norman
71ad0125d6 No need for volatile 2012-06-11 09:58:53 +02:00
Trustin Lee
89444ef4ec Fix a bug where ChunkedWriteHandler stalls
- Other encoders in the pipeline were swallowing the flush request.
- Do not allocate a new buffer unnecessarily in ChunkedNioFile
2012-06-11 11:23:09 +09:00
Trustin Lee
9dce123938 Use MessageBuf instead of Queue wherever possible in channel API 2012-06-11 10:43:47 +09:00
Norman Maurer
ed47feeed8 Fix checkstyle 2012-06-10 20:45:38 +02:00
Norman Maurer
12898a2ef4 Modify ChunkedInput to not return a chunk. It now read the chunk and directly transfer it. This helps to safe a copy on most cases 2012-06-10 20:31:14 +02:00
Trustin Lee
574d84e98e Remove ChannelBufferHolder / Add more handler interfaces for type safety
- ChannelInboundHandler and ChannelOutboundHandler does not have a type
  parameter anymore.  
- User should implement ChannelInboundMessageHandler or
  ChannelOutboundMessageHandler.
2012-06-10 12:22:32 +09:00
Trustin Lee
a849d11877 ChannelBuffers -> ByteBufs / Add MessageBuf & ChannelBuf
- Add MessageBuf which replaces java.util.Queue
- Add ChannelBuf which is common type of ByteBuf and ChannelBuf
- ChannelBuffers was renamed to ByteBufs
- Add MessageBufs
- All these changes are going to replace ChannelBufferHolder.
2012-06-10 11:31:39 +09:00
Trustin Lee
5164d91255 Rename ChannelBuffer to ByteBuf as discussed before
- ChannelBuffer gives a perception that it's a buffer of a
  channel, but channel's buffer is now a byte buffer or a message
  buffer.  Therefore letting it be as is is going to be confusing.
2012-06-10 11:08:43 +09:00
Trustin Lee
87f52aa604 Ensure that a user implements flush() or inboundBufferUpdated()
- Also prohibited a user from overriding
  ChannelInbound(Byte|Message)HandlerAdapter.  If a user wants to do
  that, he or she should extend ChannelInboundHandlerAdapter instead.
2012-06-10 10:48:11 +09:00
Trustin Lee
b6d5593e6a Do not wrap IOException with IOException 2012-06-10 04:30:56 +09:00
Trustin Lee
e376888d48 Replace 'Stream' with 'Byte'
- In computing, 'stream' means both byte stream and message stream,
  which is confusing.
- Also, we were already mixing stream and byte in some places and
  it's better use the terms consistently.
  (e.g. inboundByteBuffer & inbound stream)
2012-06-09 21:05:59 +09:00
Trustin Lee
468a3228a4 Fit every line into 120 columns 2012-06-08 19:28:12 +09:00
Trustin Lee
50fafdc3d3 Rewrite SslHandler / Reduce the chance of OIO-OIO dead lock
- SslHandler always begins handshake unless startTls is true
  - Removed issueHandshake property
  - If a user wants to start handshake later, he/she has to add 
    SslHandler later.
- Removed enableRenegotiation property
  - JDK upgrade fixes the security vulnerability - no need to complicate
    our code
- Some property name changes
  - getSSLEngineInboundCloseFuture() -> sslCloseFuture() 
- Updated securechat example
- Added timeout for handshake and close_notify for better security
  - However, it's currently hard-coded.  Will make it a property later.
2012-06-08 01:22:35 +09:00
Trustin Lee
4a23c2a6eb Fix checkstyle errors 2012-06-07 22:01:59 +09:00
Trustin Lee
8701e24b9a Add back Channel(Inbound|Outbound)(Message|Stream)HandlerAdapter
- they are useful when creating an anonymous class
- Also added back CombinedChannelHandler with extra constraints
2012-06-07 17:49:45 +09:00
Trustin Lee
aab71ccd8a Remove Channel(Inbound|Outbound)HandlerAdapter which does nothing
- Thanks to the recent refactoring, Channel(Inbound|Outbound)Handler-
  Adapter ended up having empty body.  No need to keep.
2012-06-07 17:25:15 +09:00
Trustin Lee
ea0c9cfe79 Post-overhaul fixes / Split LoggingHandler into three
- LoggingHandler now only logs state and operations
- StreamLoggingHandler and MessageLoggingHandler log the buffer content
- Added ChannelOperationHandlerAdapter
  - Used by WriteTimeoutHandler
2012-06-07 16:56:21 +09:00
Trustin Lee
5e93d206ff Overhaul - Split ChannelHandler & Merge ChannelHandlerContext
- Extracted some handler methods from ChannelInboundHandler into
  ChannelStateHandler
- Extracted some handler methods from ChannelOutboundHandler into
  ChannelOperationHandler
- Moved exceptionCaught and userEventTriggered are now in
  ChannelHandler
  
- Channel(Inbound|Outbound)HandlerContext is merged into
  ChannelHandlerContext
- ChannelHandlerContext adds direct access methods for inboud and
  outbound buffers
  - The use of ChannelBufferHolder is minimal now.
    - Before: inbound().byteBuffer()
    - After: inboundByteBuffer()
    - Simpler and better performance
    
- Bypass buffer types were removed because it just does not work at all
  with the thread model.
  - All handlers that uses a bypass buffer are broken.  Will fix soon.

- CombinedHandlerAdapter does not make sense anymore either because
  there are four handler interfaces to consider and often the two
  handlers will implement the same handler interface such as
  ChannelStateHandler.  Thinking of better ways to provide this feature
2012-06-07 14:52:33 +09:00
Trustin Lee
b1a156d3f2 Fix a build failure due to a dependency problem / Fix checkstyle errors 2012-06-07 09:15:53 +09:00
Trustin Lee
a9cc75dd3e Port SSL echo test
- Remove britspaces
2012-06-06 23:18:37 +09:00
norman
a4b2d70264 Remove some more synchronization stuff which is not needed anymore 2012-06-06 08:24:44 +02:00
norman
a56ea06e58 Only parse packet length once per packet. See #382 2012-06-06 08:20:30 +02:00
norman
f759d30538 Fix starttls support. Now SslHandler should be fully functional again 2012-06-06 08:06:12 +02:00
norman
2aea5291bd Port SslHandler to the new API. Everything except of starttls works 2012-06-06 07:52:28 +02:00
norman
35ba150db0 Fix BlockingReadHandler 2012-06-05 14:18:09 +02:00
norman
12069d3bf4 Eliminate most of the synchonization stuff in ChunkedWriteHandler as its not needed anymore with the new thread-model 2012-06-05 14:13:56 +02:00
Trustin Lee
1eced1e9e3 Update license headers 2012-06-04 13:31:44 -07:00
Trustin Lee
45f19d02ff Remove the codecs and handlers that can't make it on time for 4.0.0.A1
- Removed ones are: IP filer and HTTP multipart codec
  - Needs closer code review and polishing
  - Sorry. I'll add them back in the next alpha releases
  - SSL handler and ChunkedWriteHandler also need more work, but
    I really want to make them part of the first alpha because they
    are used pretty often by users.
2012-06-02 01:38:10 -07:00
Trustin Lee
cc4f705029 Replace ChannelBuffer.toByteBuffer() with hasNioBuffer() and nioBuffer()
... just like we do with byte arrays.  toByteBuffer() and
toByteBuffers() had an indeterministic behavior and thus it could not
tell when the returned NIO buffer is shared or not.  nioBuffer() always
returns a view buffer of the Netty buffer.  The only case where
hasNioBuffer() returns false and nioBuffer() fails is the
CompositeChannelBuffer, which is not very commonly used and *slow*.
2012-06-02 01:30:55 -07:00
Trustin Lee
14e68aca57 Fix a Javadoc error 2012-06-01 23:18:46 -07:00
Trustin Lee
141a05c831 Strict thread model / Allow assign an executor to a handler
- Add EventExecutor and make EventLoop extend it
- Add SingleThreadEventExecutor and MultithreadEventExecutor
- Add EventExecutor's default implementation
- Fixed an API design problem where there is no way to get non-bypass
  buffer of desired type
2012-06-01 17:51:19 -07:00
Trustin Lee
754cd99843 Port ChunkedWriteHandler 2012-06-01 00:36:12 -07:00
Trustin Lee
7be188f8c0 Ported BlockingReadHandler 2012-05-31 16:44:51 -07:00
Trustin Lee
9bb5b34887 Remove BufferedWriteHandler
- All writes in Netty 4 are buffered by default and a user can call
  flush() to flush it.
2012-05-31 15:55:11 -07:00
Trustin Lee
2aa466640e Ported Read/WriteTimeoutHandler with simplification
- The default behavior is now to close the channel on timeout.  A user
  can override this behavior, but I would just use IdleStateHandler or
  use eventLoop's timer facility directly for finer control.
2012-05-31 15:53:38 -07:00
Trustin Lee
5f24f176bb Port ReadTimeoutHandler 2012-05-31 15:04:25 -07:00
Trustin Lee
7ddc93bed8 Ported IdleStateHandler / Forward-ported the UptimeClient example
- Add ChannelHandlerContext.eventLoop() for convenience
- Bootstrap and ServerBootstrap handles channel initialization failure
  better
- More strict checks for missing @Sharable annotation
  - A handler without @Sharable annotation cannot be added more than
    once now.
2012-05-31 14:54:48 -07:00
Norman Maurer
5852d82ad6 Only send event upstream once the Ssl handshake was completed successfull. See #358
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:25:29 -07:00
Norman Maurer
e2bdc2234d Cleanup 2012-05-30 19:21:21 -07:00
Norman Maurer
e2a7462d70 Fix syntax. See #342 2012-05-30 19:14:10 -07:00
Jeff Pinner
2f71c001b4 Make SslBufferPool an interface 2012-05-30 19:13:52 -07:00
norman
7007e2fbaf Make all methods of SslBufferPool public so a subclass can be placed in another package. See #336 2012-05-30 19:12:26 -07:00
norman
1226cdacfb Use the correct ChannelBufferFactory when creating new ChannelBuffers. See #335
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:12:11 -07:00
norman
ed357181c0 Make sure SslHandler also works if SslBufferPool use non heap ByteBuffers. See #329
Conflicts:

	handler/src/main/java/io/netty/handler/ssl/SslHandler.java
2012-05-30 19:11:23 -07:00
Trustin Lee
57d3d0cbb5 Update ChunkedWriteHandler to the latest revision at branch 3 2012-05-30 18:47:55 -07:00
norman
7b434e225f Make sure we fire the event from the io-thread. See #306 2012-05-30 18:45:57 -07:00
norman
31e643b32d Refactor ChunkedWriteHandler to remove synchronization which can have bad side effects like deadlocks. See #297 and #301
Conflicts:

	handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java
2012-05-30 18:45:28 -07:00
norman
280c65a28e Refactor ChunkedWriteHandler to remove synchronization which can have bad side effects like deadlocks. See #297 and #301
Conflicts:

	handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java
2012-05-30 18:43:52 -07:00
norman
f8f703e679 Add @Override annotations 2012-05-30 18:41:43 -07:00
norman
c705379adb Notify ChannelFuture's of queued writes if the SslHandler gets remove d from the ChannelPipeline. See #306 2012-05-30 18:41:32 -07:00
norman
c0bb070876 Fail all queued writes if the ChunkedWriteHandler is removed from the ChannelPipeline. See #304 2012-05-30 18:41:13 -07:00
norman
d308fa8fe1 Fail all pending writes on channelClosed(..). See #305 2012-05-30 18:40:59 -07:00
Norman Maurer
d1e6328102 Allow to register ChannelFutureListener's that get notified once the inbound of the SSLEngine is closed. See #137 2012-05-30 18:40:43 -07:00