private void doAcknowledge(final Pooled<ByteBuffer> acked) { assert holdsLock(inputStream); if (eofReceived) { // no ack needed; also a best-effort to work around broken peers return; } final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); int consumed = acked.getResource().position(); if (! badMsgSize) consumed -= 8; // position minus header length (not including framing size) inboundWindow += consumed; Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_WINDOW_OPEN); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.putInt(consumed); // Open window by buffer size buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; } finally { if (! ok) pooled.free(); } }
private void doSendCloseMessage() { assert holdsLock(inputStream); if (closeSent || ! channel.getConnectionHandler().isMessageClose()) { // we don't send a MESSAGE_CLOSE because broken versions will simply stop sending packets, and we won't know when the message is really gone. // the risk is that the remote side could have started a new message in the meantime, and our MESSAGE_CLOSE would kill the wrong message. // so this behavior is better than the alternative. return; } Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_CLOSE); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; closeSent = true; } finally { if (! ok) pooled.free(); } }
final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; boolean sendCancel = cancelled && ! cancelSent; buffer.put(7, (byte) (buffer.get(7) | Protocol.MSG_FLAG_EOF)); log.tracef("Sending message (with EOF) (%s) to %s", buffer, connection); if (! channel.getConnectionHandler().isMessageClose()) {
pooled.free(); if (! eofSent && channel.getConnectionHandler().isMessageClose()) { eofSent = true; pooled = allocate(Protocol.MESSAGE_DATA);
private void doAcknowledge(final Pooled<ByteBuffer> acked) { assert holdsLock(inputStream); if (eofReceived) { // no ack needed; also a best-effort to work around broken peers return; } final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); int consumed = acked.getResource().position(); if (! badMsgSize) consumed -= 8; // position minus header length (not including framing size) inboundWindow += consumed; Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_WINDOW_OPEN); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.putInt(consumed); // Open window by buffer size buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; } finally { if (! ok) pooled.free(); } }
private void doAcknowledge(final Pooled<ByteBuffer> acked) { assert holdsLock(inputStream); if (eofReceived) { // no ack needed; also a best-effort to work around broken peers return; } final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); int consumed = acked.getResource().position(); if (! badMsgSize) consumed -= 8; // position minus header length (not including framing size) inboundWindow += consumed; Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_WINDOW_OPEN); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.putInt(consumed); // Open window by buffer size buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; } finally { if (! ok) pooled.free(); } }
private void doSendCloseMessage() { assert holdsLock(inputStream); if (closeSent || ! channel.getConnectionHandler().isMessageClose()) { // we don't send a MESSAGE_CLOSE because broken versions will simply stop sending packets, and we won't know when the message is really gone. // the risk is that the remote side could have started a new message in the meantime, and our MESSAGE_CLOSE would kill the wrong message. // so this behavior is better than the alternative. return; } Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_CLOSE); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; closeSent = true; } finally { if (! ok) pooled.free(); } }
private void doSendCloseMessage() { assert holdsLock(inputStream); if (closeSent || ! channel.getConnectionHandler().isMessageClose()) { // we don't send a MESSAGE_CLOSE because broken versions will simply stop sending packets, and we won't know when the message is really gone. // the risk is that the remote side could have started a new message in the meantime, and our MESSAGE_CLOSE would kill the wrong message. // so this behavior is better than the alternative. return; } Pooled<ByteBuffer> pooled = allocate(Protocol.MESSAGE_CLOSE); boolean ok = false; try { ByteBuffer buffer = pooled.getResource(); buffer.flip(); channel.getRemoteConnection().send(pooled); ok = true; closeSent = true; } finally { if (! ok) pooled.free(); } }
final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; boolean sendCancel = cancelled && ! cancelSent; buffer.put(7, (byte) (buffer.get(7) | Protocol.MSG_FLAG_EOF)); log.tracef("Sending message (with EOF) (%s) to %s", buffer, connection); if (! channel.getConnectionHandler().isMessageClose()) {
final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; boolean sendCancel = cancelled && ! cancelSent; buffer.put(7, (byte) (buffer.get(7) | Protocol.MSG_FLAG_EOF)); log.tracef("Sending message (with EOF) (%s) to %s", buffer, messageChannel); if (! channel.getConnectionHandler().isMessageClose()) {
pooled.free(); if (! eofSent && channel.getConnectionHandler().isMessageClose()) { eofSent = true; pooled = allocate(Protocol.MESSAGE_DATA);
pooled.free(); if (! eofSent && channel.getConnectionHandler().isMessageClose()) { eofSent = true; pooled = allocate(Protocol.MESSAGE_DATA);