-
-
Save lorban/602b980cbb9d190cdfb9d11331422680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean flush(ByteBuffer... buffers) throws IOException | |
{ | |
int length = buffers.length; | |
boolean last = buffers[length - 1] == LAST_FLAG; | |
if (last) | |
--length; | |
int bufSize = 0; | |
for (int i = 0; i < length; i++) | |
{ | |
ByteBuffer buffer = buffers[i]; | |
int remaining = buffer.remaining(); | |
bufSize += remaining; | |
} | |
ByteBuffer byteBuffer = ByteBuffer.allocate(bufSize); | |
for (int i = 0; i < length; i++) | |
{ | |
ByteBuffer buffer = buffers[i]; | |
byteBuffer.put(buffer); | |
} | |
byteBuffer.flip(); | |
return flush(byteBuffer, last); | |
} | |
public boolean flush(ByteBuffer buffer, boolean last) throws IOException | |
{ | |
// TODO: session.flush(streamId, buffer) feeds Quiche and then calls flush(). | |
// Can we call flush() only after the for loop below? | |
if (LOG.isDebugEnabled()) | |
LOG.debug("flushing 1 buffer(s) to {}", this); | |
{ | |
int flushed = session.flush(streamId, buffer, last); | |
if (LOG.isDebugEnabled()) | |
LOG.debug("stream #{} (last? {}) flushed {} bytes window={}/{} to {}", streamId, last, flushed, session.getWindowCapacity(streamId), session.getWindowCapacity(), this); | |
if (buffer.hasRemaining()) | |
{ | |
if (LOG.isDebugEnabled()) | |
LOG.debug("incomplete flushing of {}", this); | |
return false; | |
} | |
} | |
if (LOG.isDebugEnabled()) | |
LOG.debug("flushed {}", this); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment