Skip to content

Commit

Permalink
Make AbstractChannel.outboundBuffer volatile.
Browse files Browse the repository at this point in the history
Motivation:

The field can be read from arbitrary threads via Channel.(isWritable()|bytesBeforeWritable()|bytesBeforeUnwritable()), WriteAndFlushTask.newInstance(), PendingWriteQueue, etc.

Modifications:

Make AbstractChannel.outboundBuffer volatile.

Result:

More correct in a concurrent use case.
  • Loading branch information
buchgr authored and normanmaurer committed Jul 6, 2016
1 parent df033e1 commit 0fbb791
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public final ChannelPromise voidPromise() {
*/
protected abstract class AbstractUnsafe implements Unsafe {

private ChannelOutboundBuffer outboundBuffer = new ChannelOutboundBuffer(AbstractChannel.this);
private volatile ChannelOutboundBuffer outboundBuffer = new ChannelOutboundBuffer(AbstractChannel.this);
private RecvByteBufAllocator.Handle recvHandle;
private boolean inFlush0;
/** true if the channel has never been registered, false otherwise */
Expand Down

0 comments on commit 0fbb791

Please sign in to comment.