poorbarcode commented on code in PR #23123:
URL: https://github.com/apache/pulsar/pull/23123#discussion_r1703477705


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -3605,19 +3605,38 @@ public String clientSourceAddressAndPort() {
 
     @Override
     public CompletableFuture<Optional<Boolean>> checkConnectionLiveness() {
+        if (!isActive()) {
+            return CompletableFuture.completedFuture(Optional.of(false));
+        }
         if (connectionLivenessCheckTimeoutMillis > 0) {
             return 
NettyFutureUtil.toCompletableFuture(ctx.executor().submit(() -> {
+                if (!isActive()) {
+                    return 
CompletableFuture.completedFuture(Optional.of(false));
+                }
                 if (connectionCheckInProgress != null) {
                     return connectionCheckInProgress;
                 } else {
                     final CompletableFuture<Optional<Boolean>> 
finalConnectionCheckInProgress =
                             new CompletableFuture<>();
                     connectionCheckInProgress = finalConnectionCheckInProgress;
                     ctx.executor().schedule(() -> {
+                        if (!isActive()) {
+                            
finalConnectionCheckInProgress.complete(Optional.of(false));
+                            return;
+                        }
                         if (finalConnectionCheckInProgress == 
connectionCheckInProgress
                                 && !finalConnectionCheckInProgress.isDone()) {
                             log.warn("[{}] Connection check timed out. Closing 
connection.", this.toString());
                             ctx.close();
+                        } else if (finalConnectionCheckInProgress != 
connectionCheckInProgress){
+                            log.info("[{}] Connection check might be success, 
because the variable"

Review Comment:
   Thanks for reminding me, I have improved the `if... else` logic. After the 
improvement, this situation is not expected, once this log is printed, it means 
something went wrong, so this log is helpful for troubleshooting. 
   
   - Send ping
   - Case 1 : Receive pong
     - Change connectionCheckInProgress to `done`
   - Case 2: Waiting for receiving pong timeout
     - Print this log 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to