From 6150509451ba8d03ae677c6073fb5d3a08b5702d Mon Sep 17 00:00:00 2001 From: haolin Date: Sat, 15 Oct 2016 16:00:05 +0800 Subject: [PATCH] avoid the extreme case that notify missing --- diablo-client-spring/pom.xml | 4 ++-- diablo-client/pom.xml | 4 ++-- diablo-common/pom.xml | 2 +- diablo-server/pom.xml | 4 ++-- .../diablo/server/support/PullingSupport.java | 20 +++++++++++-------- pom.xml | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/diablo-client-spring/pom.xml b/diablo-client-spring/pom.xml index 5a764c2..9d3c1db 100644 --- a/diablo-client-spring/pom.xml +++ b/diablo-client-spring/pom.xml @@ -3,7 +3,7 @@ diablo me.hao0 - 1.1.0 + 1.1.1 4.0.0 @@ -22,7 +22,7 @@ me.hao0 diablo-client - 1.1.0 + 1.1.1 diff --git a/diablo-client/pom.xml b/diablo-client/pom.xml index 97ac9a0..3dd5915 100644 --- a/diablo-client/pom.xml +++ b/diablo-client/pom.xml @@ -3,7 +3,7 @@ diablo me.hao0 - 1.1.0 + 1.1.1 4.0.0 @@ -22,7 +22,7 @@ me.hao0 diablo-common - 1.1.0 + 1.1.1 diff --git a/diablo-common/pom.xml b/diablo-common/pom.xml index 1adaf1f..16206dd 100644 --- a/diablo-common/pom.xml +++ b/diablo-common/pom.xml @@ -3,7 +3,7 @@ diablo me.hao0 - 1.1.0 + 1.1.1 4.0.0 diff --git a/diablo-server/pom.xml b/diablo-server/pom.xml index 4b5d467..798263b 100644 --- a/diablo-server/pom.xml +++ b/diablo-server/pom.xml @@ -3,7 +3,7 @@ diablo me.hao0 - 1.1.0 + 1.1.1 4.0.0 @@ -22,7 +22,7 @@ me.hao0 diablo-common - 1.1.0 + 1.1.1 diff --git a/diablo-server/src/main/java/me/hao0/diablo/server/support/PullingSupport.java b/diablo-server/src/main/java/me/hao0/diablo/server/support/PullingSupport.java index f0f9c0d..ac3b4e7 100644 --- a/diablo-server/src/main/java/me/hao0/diablo/server/support/PullingSupport.java +++ b/diablo-server/src/main/java/me/hao0/diablo/server/support/PullingSupport.java @@ -149,13 +149,8 @@ public void run() { if (sendUpdatedConfigsIfPossible(client.getAppId(), pullingConfigs, response)){ // updated config sent - // complete async context to tell the container sends response - asyncContext.complete(); - - // cancel data changed listening - if (pullingTimeoutFuture != null){ - pullingTimeoutFuture.cancel(false); - } + // stop pulling + stopPulling(); } else { // no updated config sent @@ -164,13 +159,17 @@ public void run() { int serverKeepPullingTimeout = getPullingTimeout((HttpServletRequest) asyncContext.getRequest()); pullingTimeoutFuture = longPullingScheduler.schedule(new Runnable() { public void run() { - Logs.info("client pulling is timeout."); stopPulling(); } }, serverKeepPullingTimeout, TimeUnit.SECONDS); // start to listen config updated eventDispatcher.register(this); + + // NOTE: avoid the extreme case that config updated notify before registering self + if (sendUpdatedConfigsIfPossible(client.getAppId(), pullingConfigs, response)){ + stopPulling(); + } } } @@ -203,6 +202,11 @@ private void stopPulling() { // tell the container to send response asyncContext.complete(); + + // cancel data changed listening + if (pullingTimeoutFuture != null){ + pullingTimeoutFuture.cancel(false); + } } /** diff --git a/pom.xml b/pom.xml index 963538a..71e039a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ me.hao0 diablo - 1.1.0 + 1.1.1 diablo-common diablo-server