Commit Graph

226 Commits

Author SHA1 Message Date
Trustin Lee
1a9c0fd569 Make use of the existance of bridge references to find a buffer 2012-06-04 11:18:48 -07:00
Trustin Lee
c8c577efc5 Remove an unused field 2012-06-04 09:25:39 -07:00
Trustin Lee
0aa99606d9 Fix a race where 2 handlers in different threads access the same buffer
- DefaultChannelPipeline detects such cases and creates an object called
  'bridge' that works as a man-in-the-middle to deal with a race
  condition
- Slight performance drop is observed but still faster than v3. 
  Couldn't find much from a profiler yet.
2012-06-04 00:24:34 -07:00
Trustin Lee
f3734e1eb9 Simplified DefaultChannelPipeline by making its list head final
- Previously, head was a volatile field which is null at the beginning.
  While iterating over the pipeline, if the loop hits null, it called
  Channel.Unsafe explicitly.
- Instead, I created an outbound handler that redirects all requests
  to the unsafe and made it a final field of the pipeline.
- As a result, DefaultChannelPipeline code became much simpler.
2012-06-03 18:51:42 -07:00
Trustin Lee
4d8e2198fa Fix a bug where LocalServerChannel's localAddress is unregistered 2012-06-03 13:20:56 -07:00
Trustin Lee
234c4c70db Ensure LocalChannel fire channelActive after peers's channelRegistered
- Also:
  - Made the test case more robust
  - Added a simple concurrent buffer modification test (needs more work)
2012-06-03 12:54:26 -07:00
Trustin Lee
d48973b0ff Add ChannelHandlerContext.hasNext(In|Out)bound(Byte|Message)Buffer 2012-06-03 04:35:38 -07:00
Trustin Lee
bbed0602c1 Use NoSuchBufferException instead of IllegalArgumentException 2012-06-03 04:26:11 -07:00
Trustin Lee
13d7ee1b2f Optimized DefaultChannelPipeline.write(...)
- Also replaced unnecessary function calls with field accesses
2012-06-03 04:25:03 -07:00
Trustin Lee
f991a8c7d4 Fix a bug where DefaultChannelPipeline.write() doesn't find the buffer
- Also fixed failures in SpdySessionHandlerTest
2012-06-03 04:10:32 -07:00
Trustin Lee
ada61d4985 Ported multicast test / Fixed bugs in NioDatagramChannelConfig 2012-06-03 02:57:52 -07:00
Trustin Lee
e6ceb91a85 Add AbstractDatagramTest / Port unicast test / Ignore 'Socket closed' 2012-06-03 02:40:58 -07:00
Trustin Lee
01a5bd41f0 Add Channel.type() which tells if stream-oriented or message-oriented
- DefaultChannelPipeline uses this information to reject invalid buffer
  access in inbound(Message|Byte)Buffer.  Otherwise, a user can access
  a message buffer when the channel is stream-oriented.
- Because ChannelType cannot be both STREAM and MESSAGE, catch-all
  buffer has been removed to avoid confusion and unexpected behavior
  (it's already causing headache.)
- As a result, codec embedder needs rework.
2012-06-02 01:58:15 -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
04cf1c8199 Use custom thread factory by default to better recognize the threads
... from their names
2012-06-01 22:57:54 -07:00
Trustin Lee
61e169e53a Remove EventExecutor.parent(), which is of no use 2012-06-01 22:33:53 -07:00
Trustin Lee
4440386494 Little bit of optimization 2012-06-01 18:34:19 -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
5243d3d0f0 Add @Sharable annotation to ChannelInitializer 2012-05-31 17:05:34 -07:00
Trustin Lee
f2eddda5a4 Call discardReadBytes() on outbound byte buffers when possible
- Also fixed a test failure in codec-http
2012-05-31 16:59:54 -07:00
Trustin Lee
d626561b59 Define a dedicated exception for performing blocking ops in event loop 2012-05-31 16:47:00 -07:00
Trustin Lee
468918227a Remove unnecessary parameter in AttributeKey and ChannelOption
- Removed UniqueKey which does nothing
- The valueType parameter was not needed at all because we do not need
  type information in runtime at all.
2012-05-31 16:03:57 -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
Trustin Lee
49bda34a5d Fix a bug where ChannelBufferHolder.isEmpty() returns a wrong value
.. when it has a byte buffer
2012-05-31 09:14:39 -07:00
Trustin Lee
0fd824c3bb Fix UnsupportedOperationException 2012-05-31 09:11:07 -07:00
Trustin Lee
2a63acef4d More convenient inbound stream handler / Smarter inbound buffer cleanup
- Added a new convenience method to ChannelInboundstreamHandlerAdapter 
- EchoServerHandler uses the new method
- DefaultChannelPipeline calls inboundByteBuffer.discardReadBytes()
  when it is sure there's no memory copy involved
2012-05-31 09:03:31 -07:00
Trustin Lee
665777e6f9 Add InternetProtocolFamily and use it with NioDatagramChannel 2012-05-31 02:49:39 -07:00
Trustin Lee
7ac89ace4f Finished forward-porting SPDY codec 2012-05-31 01:53:58 -07:00
Trustin Lee
32c982b478 Fix NPE in OioChildEventLoop 2012-05-31 01:19:54 -07:00
Trustin Lee
67ec4429cc Implement NIO.2 multicast options 2012-05-30 19:03:45 -07:00
Trustin Lee
42abb6df3a QueueFactory cleanup
- Really attempt to create a queue to determine LTQ can be initialized
  in runtime, and cache the result
- Remove unnecessary Class<T> parameter in createQueue()
- Remove unused createQueue(Collection)
2012-05-30 16:19:22 -07:00
Trustin Lee
e5bcc74cd5 Warn if the last inbound handler forwarded an exceptionCaught() event 2012-05-30 11:48:04 -07:00
Trustin Lee
cca35454d2 Ensure channelInboundBufferUpdated is fired after channelActive 2012-05-30 11:32:39 -07:00
Trustin Lee
47fa2ef2e8 Use LinkedHashSet instead of HashSet to preserve order of execution 2012-05-30 10:17:45 -07:00
Trustin Lee
9f9045c3b4 Add EventLoop implementation for the local transport 2012-05-30 04:33:43 -07:00
Trustin Lee
c17e5b458a Typo 2012-05-30 04:28:01 -07:00
Trustin Lee
4154f42520 Less restriction in shutdown hook modification 2012-05-30 04:27:19 -07:00
Trustin Lee
078a502c5f Add shutdown hooks to SingleThreadEventLoop
- LocalChannel and LocalServerChannel uses it to close themselves on
  shutdown
- LocalEcho example does not call close() anymore because the channels
  are closed automatically on shutdown
2012-05-30 04:23:15 -07:00
Trustin Lee
243f6581c6 Safer shutdown 2012-05-30 04:06:15 -07:00
Trustin Lee
65e224f149 Safer shutdown 2012-05-30 04:05:10 -07:00
Trustin Lee
a53ecbf5f1 Implement the local transport
- Replace the old local example with localecho example
- Channel's outbound buffer is guaranteed to be created on construction
  time.
2012-05-30 03:58:14 -07:00
Trustin Lee
392623749e Fix compilation errors 2012-05-30 02:01:48 -07:00
Trustin Lee
78974e85c5 AbstractUnsafe.out() -> directOutbound()
- to avoid confusion between Channel.outbound()
2012-05-30 00:38:23 -07:00
Trustin Lee
f4c6bcafaf Keep channel's outbound buffer in AbstractChannel
- Replace firstOut() with newOutboundBuffer()
2012-05-30 00:35:53 -07:00
Trustin Lee
a9948d681e Throw NoSuchBufferException instead of returning null
- Exception in this case makes a user less confusing
- To reduce the overhead of filling the stack trace,
  NoSuchBufferException has a public pre-constructed instance.
  - This is necessary because codec framework sometimes need to support
    both type of outbound buffers.
- Fixed a bug where SpdyFrameEncoder did not handle ping messages
- Reduced memory copy in codec embedder (EmbeddedChannel)
2012-05-29 17:25:09 -07:00
Trustin Lee
8237afff64 Ported most examples
- Renamed ChannelBootstrap to Bootstrap
- Renamed ServerChannelBootstrap to ServerBootstrap
- Moved bootstrap classes to io.netty.bootstrap as before
- Moved unfoldAndAdd() to a separate utility class
- Fixed a bug in unfoldAndAdd() where it did not handle ChannelBuffer
  correctly
2012-05-29 16:41:26 -07:00
Trustin Lee
026715e818 Refactor the pipeline API to support stacked codecs
- Previous API did not support the pipeline which contains multiple
  MessageToStreamEncoders because there was no way to find the closest
  outbound byte buffer.  Now you always get the correct buffer even if
  the handler that provides the buffer is placed distantly.
  For example:
  
    Channel -> MsgAEncoder -> MsgBEncoder -> MsgCEncoder
  
  Msg(A|B|C)Encoder will all have access to the channel's outbound
  byte buffer.  Previously, it was simply impossible.

- Improved ChannelBufferHolder.toString()
2012-05-29 12:09:29 -07:00
Trustin Lee
6d39c342b6 Add FIXME 2012-05-28 05:20:32 -07:00
Trustin Lee
e48281471b Limit future notification stack depth / Robost writeCounter management
- Also ported the discard example while testing this commit
2012-05-28 05:05:49 -07:00
Trustin Lee
a2698e65fb Added more convenience methods to bootstraps 2012-05-28 01:23:58 -07:00