netty/netty — pull request #637 by losipiuk (2012-10-02 13:32:47+00:00)
Title: Call ChunkedWriteHandler.flush() once again if tried when locked.

Force recursive call of ChunkedWriteHandler.flush() if another thread
tried to call it when lock was held.

Solves problem of lost resumeTransfer() call.

Problem arises if one thread is calling flush() and gets null from ChunkedInput in line 222 (in original file)
while endOfInput is false.

ChunkedWriteHandler gets into suspend mode in such case but it is possible that resumeTransfer() call
arrives before thread releases lock. In such case transfer never resumes, unless application logic calls resumeTransfer() again, which may never happen.

I added volatile flushRequired field to handle this case. The issue with the fix is that this variable does not take into account the value of fireNow parameter of flush method. Therefore recursive call to flush(), resulting from set flushRequired field may be done with different value of fireNow parameter than originally intended.

I leave it this way, as I am not sure what is the semantics of this parameter, and more complicated solution would probably be broken anyway. Let me know what you think :)