cpp: TSocketPool: Optimize the case of a single server in the pool.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920676 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocketPool.cpp b/lib/cpp/src/transport/TSocketPool.cpp
index c50877d..76eba4e 100644
--- a/lib/cpp/src/transport/TSocketPool.cpp
+++ b/lib/cpp/src/transport/TSocketPool.cpp
@@ -169,17 +169,20 @@
 
 /* TODO: without apc we ignore a lot of functionality from the php version */
 void TSocketPool::open() {
-  if (randomize_) {
+
+  unsigned int numServers = servers_.size();
+  if (numServers == 1 && isOpen()) {
+    // only one server that is already connected to
+    return;
+  }
+
+  if (randomize_ && numServers > 1) {
     random_shuffle(servers_.begin(), servers_.end());
   }
 
-  unsigned int numServers = servers_.size();
   for (unsigned int i = 0; i < numServers; ++i) {
 
     shared_ptr<TSocketPoolServer> &server = servers_[i];
-    bool retryIntervalPassed = (server->lastFailTime_ == 0);
-    bool isLastServer = alwaysTryLast_ ? (i == (numServers - 1)) : false;
-
     // Impersonate the server socket
     setCurrentServer(server);
 
@@ -188,6 +191,9 @@
       return;
     }
 
+    bool retryIntervalPassed = (server->lastFailTime_ == 0);
+    bool isLastServer = alwaysTryLast_ ? (i == (numServers - 1)) : false;
+
     if (server->lastFailTime_ > 0) {
       // The server was marked as down, so check if enough time has elapsed to retry
       int elapsedTime = time(NULL) - server->lastFailTime_;