]> sourceware.org Git - systemtap.git/commitdiff
PR 12917 - Implement Compile-Server/Client Versioning - Rework
authorDave Brolley <brolley@redhat.com>
Fri, 8 Jul 2011 14:54:38 +0000 (10:54 -0400)
committerDave Brolley <brolley@redhat.com>
Fri, 8 Jul 2011 15:00:19 +0000 (11:00 -0400)
- Prefer newer servers when selecting servers from a list.

csclient.cxx

index 8aae702af6b9236e88f48ea23d94dd3ea8a588e7..d7b38f88dcd80e5fbbd9e9edb3b09815cf708639 100644 (file)
@@ -120,6 +120,16 @@ struct compile_server_info
       return false;
     return true;
   }
+
+  // Used to sort servers by preference for order of contact. The preferred server is
+  // "less" than the other one.
+  bool operator< (const compile_server_info &that) const
+  {
+    // Prefer servers with a later (higher) version number.
+    cs_protocol_version this_version (this->version.c_str ());
+    cs_protocol_version that_version (that.version.c_str ());
+    return that_version < this_version;
+  }
 };
 
 ostream &operator<< (ostream &s, const compile_server_info &i);
@@ -1071,6 +1081,18 @@ compile_server_client::package_request ()
   return rc;
 }
 
+static void
+preferred_order (vector<compile_server_info> &servers)
+{
+  // Sort the given list of servers into the preferred order for contacting.
+  // Don't bother if there are less than 2 servers in the list.
+  if (servers.size () < 2)
+    return;
+
+  // Sort the list using compile_server_info::operator<
+  sort (servers.begin (), servers.end ());
+}
+
 int
 compile_server_client::find_and_connect_to_server ()
 {
@@ -1123,6 +1145,9 @@ compile_server_client::find_and_connect_to_server ()
       return 1;
     }
 
+  // Sort the list of servers into a preferred order.
+  preferred_order (server_list);
+
   // Now try each of the identified servers in turn.
   int rc = compile_using_server (server_list);
   if (rc == SUCCESS)
@@ -1751,6 +1776,9 @@ query_server_status (systemtap_session &s, const string &status_string)
   get_all_server_info (s, servers);
   keep_common_server_info (raw_servers, servers);
 
+  // Sort the list of servers into a preferred order.
+  preferred_order (servers);
+
   // Print the server information. Skip the empty entry at the head of the list.
   clog << _F("Systemtap Compile Server Status for '%s'", working_string.c_str()) << endl;
   bool found = false;
This page took 0.083981 seconds and 5 git commands to generate.