TS-1797 improve ClusterMachine::pop_ClusterHandler() when ts starting
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/25adb5cf Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/25adb5cf Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/25adb5cf Branch: refs/heads/3.3.x Commit: 25adb5cf4833a08de59f773095f4321920ecbaee Parents: 86b17cc Author: Chen Bin <kuo...@taobao.com> Authored: Wed Apr 3 11:17:22 2013 +0800 Committer: Chen Bin <kuo...@taobao.com> Committed: Wed Apr 3 11:17:22 2013 +0800 ---------------------------------------------------------------------- iocore/cluster/ClusterMachine.cc | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/25adb5cf/iocore/cluster/ClusterMachine.cc ---------------------------------------------------------------------- diff --git a/iocore/cluster/ClusterMachine.cc b/iocore/cluster/ClusterMachine.cc index e4ac7df..a60839f 100644 --- a/iocore/cluster/ClusterMachine.cc +++ b/iocore/cluster/ClusterMachine.cc @@ -152,10 +152,17 @@ clusterHandlers(0) ClusterHandler *ClusterMachine::pop_ClusterHandler(int no_rr) { + int find = 0; int64_t now = rr_count; if (no_rr == 0) { ink_atomic_increment(&rr_count, 1); } + + /* will happen when ts start (cluster connection is not established) */ + while (!clusterHandlers[now % this->num_connections] && (find < this->num_connections)) { + now++; + find++; + } return this->clusterHandlers[now % this->num_connections]; }