netty/netty — pull request #2981 by lw346 (2014-10-09 08:11:51+00:00)
Title: Make autoRead an AtomicBoolean instead of a volatile field.

This solves the problem I mention in #2958 and https://gist.github.com/lw346/a93359b938344e205f5f whereby if multiple threads are mutating the state of the autoRead property, we can end up in a live-lock situation whereby autoRead is set to true, but the channel is not being read from.

By converting the volatile field into an AtomicBoolean, I introduce locking around the field using a CAS operation - is that a problem?

Note that it is the only field in DefaultChannelConfig that needs this modification, as we take immediate action on the before and after value of the field in the setAutoRead(boolean) method.