boolean handleInboundChannelOpen() { int oldState, newState; do { oldState = channelState; int oldCount = oldState & INBOUND_CHANNELS_MASK; if (oldCount == maxInboundChannels) { log.tracef("Refused inbound channel request on %s because too many inbound channels are open", this); return false; } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused inbound channel request on %s because close request was sent", this); return false; } newState = oldState + ONE_INBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened inbound channel on %s", this); return true; }
void sendCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & SENT_CLOSE_REQ) != 0) { // idempotent close return; } newState = oldState | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); log.tracef("Sending close request on %s", this); sendCloseRequestBody(); closeAllChannels(); if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
void handleOutboundChannelOpen() throws IOException { int oldState, newState; do { oldState = channelState; int oldCount = oldState & OUTBOUND_CHANNELS_MASK; if (oldCount == maxOutboundChannels) { log.tracef("Refused outbound channel open on %s because too many outbound channels are open", this); throw new ProtocolException("Too many channels open"); } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused outbound channel open on %s because close request was sent", this); throw new NotOpenException("Cannot open new channel because close was initiated"); } newState = oldState + ONE_OUTBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened outbound channel on %s", this); }
/** * The remote side requests a close of the whole channel. */ void receiveCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & RECEIVED_CLOSE_REQ) != 0) { // ignore duplicate, weird though it may be return; } newState = oldState | RECEIVED_CLOSE_REQ | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); closePendingChannels(); log.tracef("Received remote close request on %s", this); if ((oldState & SENT_CLOSE_REQ) == 0) { sendCloseRequestBody(); closeAllChannels(); } if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
boolean handleInboundChannelOpen() { int oldState, newState; do { oldState = channelState; int oldCount = oldState & INBOUND_CHANNELS_MASK; if (oldCount == maxInboundChannels) { log.tracef("Refused inbound channel request on %s because too many inbound channels are open", this); return false; } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused inbound channel request on %s because close request was sent", this); return false; } newState = oldState + ONE_INBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened inbound channel on %s", this); return true; }
boolean handleInboundChannelOpen() { int oldState, newState; do { oldState = channelState; int oldCount = oldState & INBOUND_CHANNELS_MASK; if (oldCount == maxInboundChannels) { log.tracef("Refused inbound channel request on %s because too many inbound channels are open", this); return false; } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused inbound channel request on %s because close request was sent", this); return false; } newState = oldState + ONE_INBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened inbound channel on %s", this); return true; }
void sendCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & SENT_CLOSE_REQ) != 0) { // idempotent close return; } newState = oldState | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); log.tracef("Sending close request on %s", this); sendCloseRequestBody(); closeAllChannels(); if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
void sendCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & SENT_CLOSE_REQ) != 0) { // idempotent close return; } newState = oldState | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); log.tracef("Sending close request on %s", this); sendCloseRequestBody(); closeAllChannels(); if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
void handleOutboundChannelOpen() throws IOException { int oldState, newState; do { oldState = channelState; int oldCount = oldState & OUTBOUND_CHANNELS_MASK; if (oldCount == maxOutboundChannels) { log.tracef("Refused outbound channel open on %s because too many outbound channels are open", this); throw new ProtocolException("Too many channels open"); } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused outbound channel open on %s because close request was sent", this); throw new NotOpenException("Cannot open new channel because close was initiated"); } newState = oldState + ONE_OUTBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened outbound channel on %s", this); }
void handleOutboundChannelOpen() throws IOException { int oldState, newState; do { oldState = channelState; int oldCount = oldState & OUTBOUND_CHANNELS_MASK; if (oldCount == maxOutboundChannels) { log.tracef("Refused outbound channel open on %s because too many outbound channels are open", this); throw new ProtocolException("Too many channels open"); } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused outbound channel open on %s because close request was sent", this); throw new NotOpenException("Cannot open new channel because close was initiated"); } newState = oldState + ONE_OUTBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened outbound channel on %s", this); }
/** * The remote side requests a close of the whole channel. */ void receiveCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & RECEIVED_CLOSE_REQ) != 0) { // ignore duplicate, weird though it may be return; } newState = oldState | RECEIVED_CLOSE_REQ | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); closePendingChannels(); log.tracef("Received remote close request on %s", this); if ((oldState & SENT_CLOSE_REQ) == 0) { sendCloseRequestBody(); closeAllChannels(); } if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
/** * The remote side requests a close of the whole channel. */ void receiveCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & RECEIVED_CLOSE_REQ) != 0) { // ignore duplicate, weird though it may be return; } newState = oldState | RECEIVED_CLOSE_REQ | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); closePendingChannels(); log.tracef("Received remote close request on %s", this); if ((oldState & SENT_CLOSE_REQ) == 0) { sendCloseRequestBody(); closeAllChannels(); } if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }