Skip to content

Commit

Permalink
[netty#2215] DefaultChannelHandlerContext tasks needs to be volatile …
Browse files Browse the repository at this point in the history
…to ensure every thread only see full initialized instances
  • Loading branch information
Norman Maurer committed Feb 8, 2014
1 parent d8c1409 commit bd20f80
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,12 @@ private static int skipFlags0(Class<? extends ChannelHandler> handlerType) {
private ChannelFuture succeededFuture;

// Lazily instantiated tasks used to trigger events to a handler with different executor.
Runnable invokeChannelReadCompleteTask;
Runnable invokeReadTask;
Runnable invokeFlushTask;
Runnable invokeChannelWritableStateChangedTask;
// These needs to be volatile as otherwise an other Thread may see an half initialized instance.
// See the JMM for more details
volatile Runnable invokeChannelReadCompleteTask;
volatile Runnable invokeReadTask;
volatile Runnable invokeFlushTask;
volatile Runnable invokeChannelWritableStateChangedTask;

DefaultChannelHandlerContext(
DefaultChannelPipeline pipeline, ChannelHandlerInvoker invoker, String name, ChannelHandler handler) {
Expand Down

0 comments on commit bd20f80

Please sign in to comment.