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(); } }
void handleDuplicate() { // this method is called when the remote side forgot about us. Our mapping will have been already replaced. // We must not send anything to the peer from here on because things may be in a broken state. // Though this is a best-effort strategy as everything is screwed up in this case anyway. conn.duplicateMessageId(messageId, channel.getRemoteConnection().getPeerAddress()); synchronized (inputStream) { if (! streamClosed) { eofReceived = true; // it wasn't really, but we should act like it was closeSent = true; // we didn't really, but we should act like we did cancelled = true; // just not the usual way... inputStream.pushException(conn.duplicateMessageIdException()); } } }
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 int bufRemaining = buffer.remaining(); if ((inboundWindow -= bufRemaining) < 0) { channel.getRemoteConnection().handleException(new IOException("Input overrun")); return;
final Connection connection = channel.getRemoteConnection().getConnection(); final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; log.trace("Message includes cancel flag"); channel.getRemoteConnection().send(pooledBuffer); ok = true; if (intr) {
channel.getRemoteConnection().send(pooled); ok = true; } finally {
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(); } }
void handleDuplicate() { // this method is called when the remote side forgot about us. Our mapping will have been already replaced. // We must not send anything to the peer from here on because things may be in a broken state. // Though this is a best-effort strategy as everything is screwed up in this case anyway. conn.duplicateMessageId(messageId, channel.getRemoteConnection().getPeerAddress()); synchronized (inputStream) { if (! streamClosed) { eofReceived = true; // it wasn't really, but we should act like it was closeSent = true; // we didn't really, but we should act like we did cancelled = true; // just not the usual way... inputStream.pushException(conn.duplicateMessageIdException()); } } }
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 int bufRemaining = buffer.remaining(); if ((inboundWindow -= bufRemaining) < 0) { channel.getRemoteConnection().handleException(new IOException("Input overrun")); return;
void handleDuplicate() { // this method is called when the remote side forgot about us. Our mapping will have been already replaced. // We must not send anything to the peer from here on because things may be in a broken state. // Though this is a best-effort strategy as everything is screwed up in this case anyway. RemoteLogger.conn.duplicateMessageId(messageId, channel.getRemoteConnection().getChannel().getPeerAddress()); synchronized (inputStream) { if (! streamClosed) { eofReceived = true; // it wasn't really, but we should act like it was closeSent = true; // we didn't really, but we should act like we did cancelled = true; // just not the usual way... inputStream.pushException(RemoteLogger.conn.duplicateMessageIdException()); } } }
final int bufRemaining = buffer.remaining(); if ((inboundWindow -= bufRemaining) < 0) { channel.getRemoteConnection().handleException(new IOException("Input overrun")); return;
final Connection connection = channel.getRemoteConnection().getConnection(); final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; log.trace("Message includes cancel flag"); channel.getRemoteConnection().send(pooledBuffer); ok = true; if (intr) {
final ConnectedMessageChannel messageChannel = channel.getRemoteConnection().getChannel(); final boolean badMsgSize = channel.getConnectionHandler().isFaultyMessageSize(); final int msgSize = badMsgSize ? buffer.remaining() : buffer.remaining() - 8; log.trace("Message includes cancel flag"); channel.getRemoteConnection().send(pooledBuffer); ok = true; if (intr) {
channel.getRemoteConnection().send(pooled); ok = true; } finally {
channel.getRemoteConnection().send(pooled); ok = true; } finally {