HBASE-9411 Increment / decrement of rpcCount in RpcServer#Connection is not protected by synchronization

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1520438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-09-05 22:03:37 +00:00
parent 787a6f8053
commit 3f9e1e6c8f

View File

@ -1093,7 +1093,7 @@ public class RpcServer implements RpcServerInterface {
private ByteBuffer data; private ByteBuffer data;
private ByteBuffer dataLengthBuffer; private ByteBuffer dataLengthBuffer;
protected final LinkedList<Call> responseQueue; protected final LinkedList<Call> responseQueue;
private volatile int rpcCount = 0; // number of outstanding rpcs private Counter rpcCount = new Counter(); // number of outstanding rpcs
private long lastContact; private long lastContact;
private InetAddress addr; private InetAddress addr;
protected Socket socket; protected Socket socket;
@ -1186,17 +1186,17 @@ public class RpcServer implements RpcServerInterface {
/* Return true if the connection has no outstanding rpc */ /* Return true if the connection has no outstanding rpc */
private boolean isIdle() { private boolean isIdle() {
return rpcCount == 0; return rpcCount.get() == 0;
} }
/* Decrement the outstanding RPC count */ /* Decrement the outstanding RPC count */
protected void decRpcCount() { protected void decRpcCount() {
rpcCount--; rpcCount.decrement();
} }
/* Increment the outstanding RPC count */ /* Increment the outstanding RPC count */
protected void incRpcCount() { protected void incRpcCount() {
rpcCount++; rpcCount.increment();
} }
protected boolean timedOut(long currentTime) { protected boolean timedOut(long currentTime) {