MCPcopy Index your code
hub / github.com/apache/tomcat / flush

Method flush

java/org/apache/coyote/http2/Stream.java:1034–1069  ·  view source on GitHub ↗
(boolean block)

Source from the content-addressed store, hash-verified

1032 }
1033
1034 final boolean flush(boolean block) throws IOException {
1035 writeLock.lock();
1036 try {
1037 /*
1038 * Need to ensure that there is exactly one call to flush even when there is no data to write. Too few
1039 * calls (i.e. zero) and the end of stream message is not sent for a completed asynchronous write. Too
1040 * many calls and the end of stream message is sent too soon and trailer headers are not sent.
1041 */
1042 boolean dataInBuffer = buffer.position() > 0;
1043 boolean flushed = false;
1044
1045 if (dataInBuffer) {
1046 dataInBuffer = flush(false, block);
1047 flushed = true;
1048 }
1049
1050 if (dataInBuffer) {
1051 dataLeft = true;
1052 } else {
1053 if (writeBuffer.isEmpty()) {
1054 // Both buffer and writeBuffer are empty.
1055 if (flushed) {
1056 dataLeft = false;
1057 } else {
1058 dataLeft = flush(false, block);
1059 }
1060 } else {
1061 dataLeft = writeBuffer.write(this, block);
1062 }
1063 }
1064
1065 return dataLeft;
1066 } finally {
1067 writeLock.unlock();
1068 }
1069 }
1070
1071 private boolean flush(boolean writeInProgress, boolean block) throws IOException {
1072 writeLock.lock();

Callers 3

doWriteMethod · 0.95
endMethod · 0.95
writeFromBufferMethod · 0.95

Calls 15

positionMethod · 0.80
getIdAsStringMethod · 0.80
flipMethod · 0.80
remainingMethod · 0.80
getWriteListenerMethod · 0.80
lockMethod · 0.65
writeMethod · 0.65
unlockMethod · 0.65
isTraceEnabledMethod · 0.65
traceMethod · 0.65
getStringMethod · 0.65
getConnectionIdMethod · 0.65

Tested by

no test coverage detected