GeezerVison is showing github.com — Merge pull request #637 from losipiuk/3 · netty/netty@4bca917
File tree
Expand file treeCollapse file tree
Open diff view settings
src/main/java/org/jboss/netty/handler/stream
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -84,6 +84,7 @@ public class ChunkedWriteHandler |
84 | 84 | private volatile ChannelHandlerContext ctx; |
85 | 85 | private final AtomicBoolean flush = new AtomicBoolean(false); |
86 | 86 | private MessageEvent currentEvent; |
| 87 | + private volatile boolean flushNeeded; |
87 | 88 |
|
88 | 89 | /** |
89 | 90 | * Continues to fetch the chunks from the input. |
@@ -187,9 +188,10 @@ private void flush(ChannelHandlerContext ctx, boolean fireNow) throws Exception |
187 | 188 | boolean acquired = false; |
188 | 189 | final Channel channel = ctx.getChannel(); |
189 | 190 | boolean suspend = false; |
190 | | - |
| 191 | + flushNeeded = true; |
191 | 192 | // use CAS to see if the have flush already running, if so we don't need to take futher actions |
192 | 193 | if (acquired = flush.compareAndSet(false, true)) { |
| 194 | + flushNeeded = false; |
193 | 195 | try { |
194 | 196 |
|
195 | 197 | if (!channel.isConnected()) { |
@@ -297,7 +299,7 @@ public void operationComplete(ChannelFuture future) throws Exception { |
297 | 299 |
|
298 | 300 | } |
299 | 301 |
|
300 | | - if (acquired && (!channel.isConnected() || channel.isWritable() && !queue.isEmpty() && !suspend)) { |
| 302 | + if (acquired && ((!channel.isConnected() || channel.isWritable() && !queue.isEmpty() && !suspend) || flushNeeded)) { |
301 | 303 | flush(ctx, fireNow); |
302 | 304 | } |
303 | 305 | } |
|