version 1.77, 2009/12/15 11:39:34
|
version 1.78, 2010/04/09 08:23:14
|
|
|
| |
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); |
|
|
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()) |
{ | { |
|
|
_hostname.assign(hostname); | _hostname.assign(hostname); |
} | } |
| |
mutex_unlock(&_mutex); |
mutex_unlock(&_mutexForGetHostName); |
} | } |
| |
return _hostname; | return _hostname; |
|
|
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()) |
{ | { |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
mutex_unlock(&_mutex); |
mutex_unlock(&_mutexForGetFQHN); |
throw; | throw; |
} | } |
} | } |
| |
mutex_unlock(&_mutex); |
mutex_unlock(&_mutexForGetFQHN); |
} | } |
| |
return _hostname; | return _hostname; |