@@ -129,6 +129,8 @@ public abstract class AbstractFramedChannel<C extends AbstractFramedChannel<C, R
129
129
private final List <ChannelListener <C >> closeTasks = new CopyOnWriteArrayList <>();
130
130
private volatile boolean flushingSenders = false ;
131
131
132
+ private boolean partialRead = false ;
133
+
132
134
@ SuppressWarnings ("unused" )
133
135
private volatile int outstandingBuffers ;
134
136
private static final AtomicIntegerFieldUpdater <AbstractFramedChannel > outstandingBuffersUpdater = AtomicIntegerFieldUpdater .newUpdater (AbstractFramedChannel .class , "outstandingBuffers" );
@@ -352,6 +354,7 @@ public synchronized R receive() throws IOException {
352
354
channel .getSourceChannel ().shutdownReads ();
353
355
return null ;
354
356
}
357
+ partialRead = false ;
355
358
boolean requiresReinvoke = false ;
356
359
int reinvokeDataRemaining = 0 ;
357
360
ReferenceCountedPooled pooled = this .readData ;
@@ -470,6 +473,9 @@ public synchronized R receive() throws IOException {
470
473
}
471
474
return newChannel ;
472
475
}
476
+ } else {
477
+ //we set partial read to true so the read listener knows not to immediately call receive again
478
+ partialRead = true ;
473
479
}
474
480
return null ;
475
481
} catch (IOException |RuntimeException |Error e ) {
@@ -943,7 +949,11 @@ public void handleEvent(final StreamSourceChannel channel) {
943
949
UndertowLogger .REQUEST_IO_LOGGER .tracef ("Invoking receive listener" , receiver );
944
950
ChannelListeners .invokeChannelListener (AbstractFramedChannel .this , listener );
945
951
}
946
- if (readData != null && !readData .isFreed () && channel .isOpen ()) {
952
+ final boolean partialRead ;
953
+ synchronized (AbstractFramedChannel .this ) {
954
+ partialRead = AbstractFramedChannel .this .partialRead ;
955
+ }
956
+ if (readData != null && !readData .isFreed () && channel .isOpen () && !partialRead ) {
947
957
try {
948
958
runInIoThread (new Runnable () {
949
959
@ Override
@@ -955,6 +965,9 @@ public void run() {
955
965
IoUtils .safeClose (AbstractFramedChannel .this );
956
966
}
957
967
}
968
+ synchronized (AbstractFramedChannel .this ) {
969
+ AbstractFramedChannel .this .partialRead = false ;
970
+ }
958
971
}
959
972
}
960
973
0 commit comments