Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Oct 16, 2024
1 parent 6055811 commit d6edb9d
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,25 @@ public void operationComplete(ChannelFuture channelFuture) throws Exception {
private void markSessionConnected(Channel activeChannel) {
VolatileFields newCache = new VolatileFields(ConnState.CONNECTED, activeChannel);

//
// Note that actions in interceptor such as Negotiation might send request by
// ReplicaSession#asyncSend(), inside which ReplicaSession#tryConnect() would
// also be called since current state of this session is still CONNECTING.
// However, it would never create another connection, thus it is safe to do
// `fields = newCache` at the end.
interceptorManager.onConnected(this);

synchronized (pendingSend) {
if (fields.state != ConnState.CONNECTING) {
// this session may have been closed or connected already
// This session may have been closed or connected already.
logger.info("{}: session is {}, skip to mark it connected", name(), fields.state);
return;
}

// Once the authentication is enabled, any request except Negotiation such as
// query_cfg_operator for meta would be cached in authPendingSend and sent after
// Negotiation is successful. Negotiation would be performed first before any other
// request for the reason that AuthProtocol#isAuthRequest() would return true for
// negotiation_operator.
sendPendingRequests(pendingSend, newCache);
fields = newCache;
}
Expand Down Expand Up @@ -284,9 +293,11 @@ void markSessionDisconnect() {
}
}

// Reset the authentication once the connection is closed.
resetAuth();
}

// After the authentication is reset, a new Negotiation would be launched.
private void resetAuth() {
synchronized (authPendingSend) {
authSucceed = false;
Expand Down Expand Up @@ -340,6 +351,7 @@ void tryNotifyFailureWithSeqID(int seqID, error_code.error_types errno, boolean
}

private void write(final RequestEntry entry, VolatileFields cache) {
// Under some circumstances requests are not allowed to be sent or delayed.
if (!interceptorManager.onSendMessage(this, entry)) {
return;
}
Expand Down

0 comments on commit d6edb9d

Please sign in to comment.