Date: Monday, December 18, 2006 @ 17:14:04
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/ControllerInfo.hpp (1.3 -> 1.4) src/ControllerInfo.cpp
          (1.7 -> 1.8)

Renamed hostname to host_address, as it actually _is_ a host address (as a 
string)


----------------------------+
 include/ControllerInfo.hpp |   10 +++++-----
 src/ControllerInfo.cpp     |   26 +++++++++++++-------------
 2 files changed, 18 insertions(+), 18 deletions(-)


Index: carob/include/ControllerInfo.hpp
diff -u carob/include/ControllerInfo.hpp:1.3 
carob/include/ControllerInfo.hpp:1.4
--- carob/include/ControllerInfo.hpp:1.3        Mon Dec 18 15:14:29 2006
+++ carob/include/ControllerInfo.hpp    Mon Dec 18 17:14:04 2006
@@ -41,7 +41,7 @@
 class AbstractControllerPool;
 /**
  * Identifies a controller.
- * For now a controller is identified by an hostname and a port.
+ * For now a controller is identified by an host address and a port.
  * TODO: In the future, only its sockaddr should be kept (see CAROB-61)
  */
 class ControllerInfo
@@ -130,16 +130,16 @@
   struct addrinfo*        getAddrs(const std::wstring& name, in_port_t port, 
int socktype,  int family)
                               throw (ConnectionException, UnexpectedException);
   /**
-   * Call getnameinfo() on this UDP_addr to determine unique hostname
+   * Call getnameinfo() on this UDP_addr to determine host address
    */
-  void                    getHostnameFromUDPAddr() throw (ConnectionException, 
UnexpectedException);
+  void                    getHostAddressFromUDPAddr() throw 
(ConnectionException, UnexpectedException);
 
   /** Host port */
   in_port_t               host_port;
   /** Host name as given by the user */
   std::wstring            original_hostname;
-  /** Unique numerical host name guessed from UDP socket address */
-  char                    hostname[NI_MAXHOST+1];
+  /** Host address as string, retrieved from UDP socket address */
+  char                    host_address[NI_MAXHOST+1];
   /** UDP socket address */
   struct sockaddr         UDP_addr;
   /** UDP socket address length */
Index: carob/src/ControllerInfo.cpp
diff -u carob/src/ControllerInfo.cpp:1.7 carob/src/ControllerInfo.cpp:1.8
--- carob/src/ControllerInfo.cpp:1.7    Mon Dec 18 17:02:51 2006
+++ carob/src/ControllerInfo.cpp        Mon Dec 18 17:14:04 2006
@@ -37,7 +37,7 @@
     original_hostname(L""), UDP_addr_len(0), has_been_connected(false),
     TCP_sock_addr_len(0)
 {
-  hostname[0] = '\0';
+  host_address[0] = '\0';
 }
 
 ControllerInfo::ControllerInfo(const std::wstring &name, in_port_t port)
@@ -59,7 +59,7 @@
   freeaddrinfo(addrs);
 
   // get the unique numeric host name from this UDP address
-  getHostnameFromUDPAddr();
+  getHostAddressFromUDPAddr();
 }
 
 ControllerInfo::ControllerInfo(const ControllerInfo& ci)
@@ -93,7 +93,7 @@
     host_port = ntohs(inAddr6.sin6_port);
   }
   // Get a unique numeric string rep of the given address.
-  getHostnameFromUDPAddr();
+  getHostAddressFromUDPAddr();
 
   // Try to get a pretty name for host
   char hostname_str[NI_MAXHOST+1];
@@ -106,7 +106,7 @@
   else
   {
     // failure, just use the numeric address
-    original_hostname = fromString(hostname);
+    original_hostname = fromString(host_address);
   }
 }
 
@@ -115,7 +115,7 @@
 {
   host_port = ci.host_port;
   original_hostname = ci.original_hostname;
-  strncpy(hostname, ci.hostname, NI_MAXHOST);
+  strncpy(host_address, ci.host_address, NI_MAXHOST);
   // copy the udp address
   UDP_addr_len = ci.UDP_addr_len;
   memcpy(&UDP_addr, &(ci.UDP_addr), UDP_addr_len);
@@ -175,10 +175,10 @@
   return UDP_addr.sa_family;
 }
 
-void ControllerInfo::getHostnameFromUDPAddr() throw (ConnectionException, 
UnexpectedException)
+void ControllerInfo::getHostAddressFromUDPAddr() throw (ConnectionException, 
UnexpectedException)
 {
-  wstring fctName(L"ControllerInfo::getHostnameFromUDPAddr");
-  int error = getnameinfo(&UDP_addr, UDP_addr_len, hostname, sizeof(hostname), 
NULL, 0, NI_NUMERICHOST);
+  wstring fctName(L"ControllerInfo::gethost_addressFromUDPAddr");
+  int error = getnameinfo(&UDP_addr, UDP_addr_len, host_address, 
sizeof(host_address), NULL, 0, NI_NUMERICHOST);
   if (error != 0)
   {
     wstring wMsg(L"Error while executing getnameinfo()");
@@ -196,7 +196,7 @@
     throw (ConnectionException, UnexpectedException)
 {
   wstring fctName(L"ControllerInfo::connect()");
-  struct addrinfo* addr = getAddrs(fromString(hostname), host_port, 
SOCK_STREAM, getFamily());
+  struct addrinfo* addr = getAddrs(fromString(host_address), host_port, 
SOCK_STREAM, getFamily());
 
   // to iterate on the returned list
   struct addrinfo* addrIter = addr;
@@ -263,7 +263,7 @@
 
 bool ControllerInfo::operator ==(const ControllerInfo& ci) const
 {
-  int cmp = strncmp(hostname, ci.hostname, NI_MAXHOST);
+  int cmp = strncmp(host_address, ci.host_address, NI_MAXHOST);
   if (cmp == 0) // same name, compare ports
   {
     return host_port == ci.host_port;
@@ -274,7 +274,7 @@
 
 bool ControllerInfo::operator <(const ControllerInfo& ci) const
 {
-  int cmp = strncmp(hostname, ci.hostname, NI_MAXHOST);
+  int cmp = strncmp(host_address, ci.host_address, NI_MAXHOST);
   if (cmp == 0) // same name, compare ports
   {
     return host_port < ci.host_port;
@@ -285,7 +285,7 @@
 
 bool ControllerInfo::operator >(const ControllerInfo& ci) const
 {
-  int cmp = strncmp(hostname, ci.hostname, NI_MAXHOST);
+  int cmp = strncmp(host_address, ci.host_address, NI_MAXHOST);
   if (cmp == 0) // same name, compare ports
   {
     return host_port > ci.host_port;
@@ -296,5 +296,5 @@
 
 ControllerInfo::operator std::wstring() const
 {
-  return original_hostname + L"(" + fromString(hostname) + L"):" + 
toWString(host_port);
+  return original_hostname + L"/" + fromString(host_address) + L":" + 
toWString(host_port);
 }

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to