Repository: hbase
Updated Branches:
  refs/heads/branch-1 ce4af20ad -> d12ad1738


HBASE-11851 RpcClient can try to close a connection not ready to close


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d12ad173
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d12ad173
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d12ad173

Branch: refs/heads/branch-1
Commit: d12ad173817da94b2a11899686fa52d5b866e679
Parents: ce4af20
Author: Nicolas Liochon <[email protected]>
Authored: Fri Aug 29 14:35:57 2014 +0200
Committer: Nicolas Liochon <[email protected]>
Committed: Fri Aug 29 14:41:36 2014 +0200

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/ipc/RpcClient.java  | 52 +++++++++-----------
 1 file changed, 24 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d12ad173/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
----------------------------------------------------------------------
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
index 0262462..369b1f5 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
@@ -732,39 +732,35 @@ public class RpcClient {
       // beware of the concurrent access to the calls list: we can add calls, 
but as well
       //  remove them.
       long waitUntil = EnvironmentEdgeManager.currentTimeMillis() + 
minIdleTimeBeforeClose;
-      while (!shouldCloseConnection.get() && running.get() &&
-          EnvironmentEdgeManager.currentTimeMillis() < waitUntil && 
calls.isEmpty()) {
-        wait(Math.min(minIdleTimeBeforeClose, 1000));
-      }
 
-      if (shouldCloseConnection.get()) {
-        return false;
-      }
+      while (true) {
+        if (shouldCloseConnection.get()) {
+          return false;
+        }
 
-      if (!running.get()) {
-        markClosed(new IOException("stopped with " + calls.size() + " pending 
request(s)"));
-        return false;
-      }
+        if (!running.get()) {
+          markClosed(new IOException("stopped with " + calls.size() + " 
pending request(s)"));
+          return false;
+        }
 
-      if (!calls.isEmpty()) {
-        // shouldCloseConnection can be set to true by a parallel thread here. 
The caller
-        //  will need to check anyway.
-        return true;
-      }
+        if (!calls.isEmpty()) {
+          // shouldCloseConnection can be set to true by a parallel thread 
here. The caller
+          //  will need to check anyway.
+          return true;
+        }
 
-      if (EnvironmentEdgeManager.currentTimeMillis() >= waitUntil) {
-        // Connection is idle.
-        // We expect the number of calls to be zero here, but actually someone 
can
-        //  adds a call at the any moment, as there is no synchronization 
between this task
-        //  and adding new calls. It's not a big issue, but it will get an 
exception.
-        markClosed(new IOException(
-            "idle connection closed with " + calls.size() + " pending 
request(s)"));
-        return false;
-      }
+        if (EnvironmentEdgeManager.currentTimeMillis() >= waitUntil) {
+          // Connection is idle.
+          // We expect the number of calls to be zero here, but actually 
someone can
+          //  adds a call at the any moment, as there is no synchronization 
between this task
+          //  and adding new calls. It's not a big issue, but it will get an 
exception.
+          markClosed(new IOException(
+              "idle connection closed with " + calls.size() + " pending 
request(s)"));
+          return false;
+        }
 
-      // We can get here if we received a notification that there is some work 
to do but
-      //  the work was cancelled. As we're not idle we continue to wait.
-      return false;
+        wait(Math.min(minIdleTimeBeforeClose, 1000));
+      }
     }
 
     public InetSocketAddress getRemoteAddress() {

Reply via email to