kezhuw commented on code in PR #2058:
URL: https://github.com/apache/zookeeper/pull/2058#discussion_r1769461999


##########
zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java:
##########
@@ -1184,13 +1192,21 @@ public void run() {
                         to = connectTimeout - clientCnxnSocket.getIdleRecv();
                     }
 
-                    if (to <= 0) {
+                    int expiration = expirationTimeout - 
clientCnxnSocket.getIdleRecv();
+                    if (expiration <= 0) {
                         String warnInfo = String.format(
                             "Client session timed out, have not heard from 
server in %dms for session id 0x%s",
                             clientCnxnSocket.getIdleRecv(),
                             Long.toHexString(sessionId));
                         LOG.warn(warnInfo);
+                        changeZkState(States.CLOSED);

Review Comment:
   `States.CLOSED` is the terminal state for `KeeperState.Expired`. We do this 
for server side `KeeperState.Expired`, so does client side 
`KeeperState.Expired`. This way we won't get extra `KeeperState.Disconnected` 
event, which fired already in `cleanAndNotifyState`, before 
`KeeperState.Expired`.
   
   
https://github.com/apache/zookeeper/blob/bc9afbf8ef1bc6156643d3d05c87fcf8411e9d8f/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java#L1359-L1370



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to