(file) Return to System.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/System.cpp between version 1.74.2.1 and 1.79

version 1.74.2.1, 2009/10/20 13:21:19 version 1.79, 2010/10/13 14:24:46
Line 60 
Line 60 
  
 Boolean System::bindVerbose = false; Boolean System::bindVerbose = false;
  
   MutexType System::_mutexForGetHostName = PEGASUS_MUTEX_INITIALIZER;
   
   MutexType System::_mutexForGetFQHN = PEGASUS_MUTEX_INITIALIZER;
   
 Boolean System::copyFile(const char* fromPath, const char* toPath) Boolean System::copyFile(const char* fromPath, const char* toPath)
 { {
     ifstream is(fromPath PEGASUS_IOS_BINARY);     ifstream is(fromPath PEGASUS_IOS_BINARY);
Line 244 
Line 248 
 String System::getHostName() String System::getHostName()
 { {
     static String _hostname;     static String _hostname;
     static MutexType _mutex = PEGASUS_MUTEX_INITIALIZER;  
  
     // Use double-checked locking pattern to avoid overhead of     // Use double-checked locking pattern to avoid overhead of
     // mutex on subsequent calls.     // mutex on subsequent calls.
  
     if (0 == _hostname.size())     if (0 == _hostname.size())
     {     {
         mutex_lock(&_mutex);          mutex_lock(&_mutexForGetHostName);
  
         if (0 == _hostname.size())         if (0 == _hostname.size())
         {         {
Line 263 
Line 266 
             _hostname.assign(hostname);             _hostname.assign(hostname);
         }         }
  
         mutex_unlock(&_mutex);          mutex_unlock(&_mutexForGetHostName);
     }     }
  
     return _hostname;     return _hostname;
Line 335 
Line 338 
 String System::getFullyQualifiedHostName() String System::getFullyQualifiedHostName()
 { {
     static String _hostname;     static String _hostname;
     static MutexType _mutex = PEGASUS_MUTEX_INITIALIZER;  
   
     // Use double-checked locking pattern to avoid overhead of     // Use double-checked locking pattern to avoid overhead of
     // mutex on subsequent calls.     // mutex on subsequent calls.
  
     if (0 == _hostname.size())     if (0 == _hostname.size())
     {     {
         mutex_lock(&_mutex);          mutex_lock(&_mutexForGetFQHN);
  
         if (0 == _hostname.size())         if (0 == _hostname.size())
         {         {
Line 352 
Line 353 
             }             }
             catch (...)             catch (...)
             {             {
                 mutex_unlock(&_mutex);                  mutex_unlock(&_mutexForGetFQHN);
                 throw;                 throw;
             }             }
         }         }
  
         mutex_unlock(&_mutex);          mutex_unlock(&_mutexForGetFQHN);
     }     }
  
     return _hostname;     return _hostname;
Line 646 
Line 647 
 #ifdef PEGASUS_ENABLE_IPV6 #ifdef PEGASUS_ENABLE_IPV6
     struct in6_addr ip6 = PEGASUS_IPV6_LOOPBACK_INIT;     struct in6_addr ip6 = PEGASUS_IPV6_LOOPBACK_INIT;
 #endif #endif
     Uint32 ip4 = PEGASUS_IPV4_LOOPBACK_INIT;  
     switch (af)     switch (af)
     {     {
 #ifdef PEGASUS_ENABLE_IPV6 #ifdef PEGASUS_ENABLE_IPV6
Line 658 
Line 658 
             Uint32 tmp;             Uint32 tmp;
             memcpy(&tmp, binIPAddress, sizeof(Uint32));             memcpy(&tmp, binIPAddress, sizeof(Uint32));
             Uint32 n = ntohl(tmp);             Uint32 n = ntohl(tmp);
             return !memcmp(&ip4, &n, sizeof (ip4));              return n >= PEGASUS_IPV4_LOOPBACK_RANGE_START &&
                   n <= PEGASUS_IPV4_LOOPBACK_RANGE_END;
         }         }
     }     }
  
Line 667 
Line 668 
  
 Boolean System::isLocalHost(const String &hostName) Boolean System::isLocalHost(const String &hostName)
 { {
       // shortcut if hostname == localhost
       if (String::equalNoCase(hostName,String("localhost"))) return true;
 // Get all ip addresses on the node and compare them with the given hostname. // Get all ip addresses on the node and compare them with the given hostname.
 #ifdef PEGASUS_ENABLE_IPV6 #ifdef PEGASUS_ENABLE_IPV6
     CString csName = hostName.getCString();     CString csName = hostName.getCString();
Line 807 
Line 810 
  
     if (!hostNameIsIPNotation)  // if hostname is not an IP address     if (!hostNameIsIPNotation)  // if hostname is not an IP address
     {     {
         // localhost ?  
         if (String::equalNoCase(hostName,String("localhost"))) return true;  
         char localHostName[PEGASUS_MAXHOSTNAMELEN];         char localHostName[PEGASUS_MAXHOSTNAMELEN];
         CString cstringLocalHostName = System::getHostName().getCString();         CString cstringLocalHostName = System::getHostName().getCString();
         strcpy(localHostName, (const char*) cstringLocalHostName);         strcpy(localHostName, (const char*) cstringLocalHostName);
Line 1005 
Line 1006 
 #endif #endif
  
 // System ID constants for Logger::put and Logger::trace // System ID constants for Logger::put and Logger::trace
   #ifdef PEGASUS_FLAVOR
   const String System::CIMLISTENER = "cimlistener" PEGASUS_FLAVOR;
   #else
 const String System::CIMLISTENER = "cimlistener"; // Listener systme ID const String System::CIMLISTENER = "cimlistener"; // Listener systme ID
   #endif
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.74.2.1  
changed lines
  Added in v.1.79

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2