Skip to content

Commit

Permalink
Merge pull request #821 from fl4via/UNDERTOW-1602
Browse files Browse the repository at this point in the history
[UNDERTOW-1602] Don't immediatly attempt to resume if parsing was uns…
  • Loading branch information
fl4via authored Oct 16, 2019
2 parents d2db4e1 + 8c61372 commit 5b2c0cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ protected AbstractHttp2StreamSourceChannel createChannelImpl(FrameHeaderData fra
boolean ack = Bits.anyAreSet(frameParser.flags, PING_FLAG_ACK);
channel = new Http2PingStreamSourceChannel(this, pingParser.getData(), ack);
if(!ack) { //not an ack from one of our pings, so send it back
sendPing(pingParser.getData(), null, true);
sendPing(pingParser.getData(), new Http2ControlMessageExceptionHandler(), true);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public abstract class AbstractFramedChannel<C extends AbstractFramedChannel<C, R
private final List<ChannelListener<C>> closeTasks = new CopyOnWriteArrayList<>();
private volatile boolean flushingSenders = false;

private boolean partialRead = false;

@SuppressWarnings("unused")
private volatile int outstandingBuffers;
private static final AtomicIntegerFieldUpdater<AbstractFramedChannel> outstandingBuffersUpdater = AtomicIntegerFieldUpdater.newUpdater(AbstractFramedChannel.class, "outstandingBuffers");
Expand Down Expand Up @@ -352,6 +354,7 @@ public synchronized R receive() throws IOException {
channel.getSourceChannel().shutdownReads();
return null;
}
partialRead = false;
boolean requiresReinvoke = false;
int reinvokeDataRemaining = 0;
ReferenceCountedPooled pooled = this.readData;
Expand Down Expand Up @@ -470,6 +473,9 @@ public synchronized R receive() throws IOException {
}
return newChannel;
}
} else {
//we set partial read to true so the read listener knows not to immediately call receive again
partialRead = true;
}
return null;
} catch (IOException|RuntimeException|Error e) {
Expand Down Expand Up @@ -943,7 +949,11 @@ public void handleEvent(final StreamSourceChannel channel) {
UndertowLogger.REQUEST_IO_LOGGER.tracef("Invoking receive listener", receiver);
ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener);
}
if (readData != null && !readData.isFreed() && channel.isOpen()) {
final boolean partialRead;
synchronized (AbstractFramedChannel.this) {
partialRead = AbstractFramedChannel.this.partialRead;
}
if (readData != null && !readData.isFreed() && channel.isOpen() && !partialRead) {
try {
runInIoThread(new Runnable() {
@Override
Expand All @@ -955,6 +965,9 @@ public void run() {
IoUtils.safeClose(AbstractFramedChannel.this);
}
}
synchronized (AbstractFramedChannel.this) {
AbstractFramedChannel.this.partialRead = false;
}
}
}

Expand Down

0 comments on commit 5b2c0cd

Please sign in to comment.