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

Method reserveWindowSize

java/org/apache/coyote/http2/Stream.java:253–291  ·  view source on GitHub ↗
(int reservation, boolean block)

Source from the content-addressed store, hash-verified

251
252
253 final int reserveWindowSize(int reservation, boolean block) throws IOException {
254 windowAllocationLock.lock();
255 try {
256 long windowSize = getWindowSize();
257 while (windowSize < 1) {
258 if (!canWrite()) {
259 throw new CloseNowException(sm.getString("stream.notWritable", getConnectionId(), getIdAsString()));
260 }
261 if (block) {
262 try {
263 long writeTimeout = handler.getProtocol().getStreamWriteTimeout();
264 allocationManager.waitForStream(writeTimeout);
265 windowSize = getWindowSize();
266 if (windowSize == 0) {
267 doStreamCancel(sm.getString("stream.writeTimeout"), Http2Error.ENHANCE_YOUR_CALM);
268 }
269 } catch (InterruptedException e) {
270 // Possible shutdown / rst or similar. Use an IOException to
271 // signal to the client that further I/O isn't possible for this
272 // Stream.
273 throw new IOException(e);
274 }
275 } else {
276 allocationManager.waitForStreamNonBlocking();
277 return 0;
278 }
279 }
280 int allocation;
281 if (windowSize < reservation) {
282 allocation = (int) windowSize;
283 } else {
284 allocation = reservation;
285 }
286 decrementWindowSize(allocation);
287 return allocation;
288 } finally {
289 windowAllocationLock.unlock();
290 }
291 }
292
293
294 void doStreamCancel(String msg, Http2Error error) throws CloseNowException {

Callers 3

flushMethod · 0.45
processSendfileMethod · 0.45
completedMethod · 0.45

Calls 13

canWriteMethod · 0.95
getConnectionIdMethod · 0.95
doStreamCancelMethod · 0.95
getWindowSizeMethod · 0.80
getIdAsStringMethod · 0.80
getStreamWriteTimeoutMethod · 0.80
waitForStreamMethod · 0.80
decrementWindowSizeMethod · 0.80
lockMethod · 0.65
getStringMethod · 0.65
getProtocolMethod · 0.65

Tested by

no test coverage detected