diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-09-27 14:49:06 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-09-27 14:49:06 +0000 |
commit | 0b955b7dfeb77b6660f6a70977c36fcec68cc4d3 (patch) | |
tree | 0f363367deeb2f095d0718d04729a1625f8321e5 /cpp/src | |
parent | Win32 fixes (diff) | |
download | ice-0b955b7dfeb77b6660f6a70977c36fcec68cc4d3.tar.bz2 ice-0b955b7dfeb77b6660f6a70977c36fcec68cc4d3.tar.xz ice-0b955b7dfeb77b6660f6a70977c36fcec68cc4d3.zip |
Win32 fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/NodeI.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeI.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/PlatformInfo.cpp | 33 | ||||
-rw-r--r-- | cpp/src/IceGrid/PlatformInfo.h | 4 |
4 files changed, 32 insertions, 12 deletions
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 1a5be80b694..e3d7c47c7d1 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -8,7 +8,6 @@ // ********************************************************************** #include <Ice/Ice.h> -#include <Ice/ProtocolPluginFacade.h> // Just to get the hostname #include <IcePatch2/Util.h> #include <IcePatch2/ClientUtil.h> #include <IceGrid/NodeI.h> @@ -188,11 +187,10 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, _waitQueue(waitQueue), _traceLevels(traceLevels), _name(name), - _hostname(IceInternal::getProtocolPluginFacade(adapter->getCommunicator())->getDefaultHost()), _proxy(proxy), _waitTime(adapter->getCommunicator()->getProperties()->getPropertyAsIntWithDefault("IceGrid.Node.WaitTime", 60)), _serial(1), - _platform(_traceLevels) + _platform(adapter->getCommunicator(), _traceLevels) { string dataDir = _adapter->getCommunicator()->getProperties()->getProperty("IceGrid.Node.Data"); if(!isAbsolute(dataDir)) @@ -329,7 +327,7 @@ NodeI::getName(const Ice::Current&) const std::string NodeI::getHostname(const Ice::Current&) const { - return _hostname; + return _platform.getHostname(); } void diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h index 2df4c0cfa21..963da84a190 100644 --- a/cpp/src/IceGrid/NodeI.h +++ b/cpp/src/IceGrid/NodeI.h @@ -66,7 +66,6 @@ private: const WaitQueuePtr _waitQueue; const TraceLevelsPtr _traceLevels; const std::string _name; - const std::string _hostname; const NodePrx _proxy; const Ice::Int _waitTime; std::string _serversDir; diff --git a/cpp/src/IceGrid/PlatformInfo.cpp b/cpp/src/IceGrid/PlatformInfo.cpp index 607a88f3101..b03793cfd1c 100644 --- a/cpp/src/IceGrid/PlatformInfo.cpp +++ b/cpp/src/IceGrid/PlatformInfo.cpp @@ -9,6 +9,7 @@ #include <Ice/LocalException.h> #include <Ice/LoggerUtil.h> +#include <Ice/ProtocolPluginFacade.h> // Just to get the hostname #include <IceGrid/PlatformInfo.h> #include <IceGrid/TraceLevels.h> @@ -30,7 +31,9 @@ using namespace std; using namespace IceGrid; -PlatformInfo::PlatformInfo(const TraceLevelsPtr& traceLevels) : _traceLevels(traceLevels) +PlatformInfo::PlatformInfo(const Ice::CommunicatorPtr& communicator, const TraceLevelsPtr& traceLevels) : + _traceLevels(traceLevels), + _hostname(IceInternal::getProtocolPluginFacade(communicator)->getDefaultHost()) { // // Initialization of the necessary data structures to get the load average. @@ -83,7 +86,9 @@ PlatformInfo::PlatformInfo(const TraceLevelsPtr& traceLevels) : _traceLevels(tra // Get the number of processors. // #if defined(_WIN32) - _info.nProcessors = 1; + SYSTEM_INFO sysInfo; + GetSystemInfo(&sysInfo); + _info.nProcessors = sysInfo.dwNumberOfProcessors; #elif defined(__APPLE__) static int ncpu[2] = { CTL_HW, HW_NCPU }; size_t sz = sizeof(_info.nProcessors); @@ -102,10 +107,20 @@ PlatformInfo::PlatformInfo(const TraceLevelsPtr& traceLevels) : _traceLevels(tra // #ifdef _WIN32 _info.os = "Windows"; - _info.hostname = ""; // TODO - _info.release = ""; // TODO - _info.version = ""; // TODO - _info.machine = ""; // TODO + char hostname[MAX_COMPUTERNAME_LENGTH + 1]; + unsigned long size = sizeof(hostname); + if(GetComputerName(hostname, &size)) + { + _info.hostname = hostname; + } + OSVERSIONINFO osInfo; + osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osInfo); + ostringstream os; + os << osInfo.dwMajorVersion << "." << osInfo.dwMinorVersion; + _info.release = os.str(); + _info.version = osInfo.szCSDVersion; + _info.machine = ""; // TODO? #else struct utsname utsinfo; uname(&utsinfo); @@ -208,3 +223,9 @@ PlatformInfo::getLoadInfo() #endif return info; } + +std::string +PlatformInfo::getHostname() const +{ + return _hostname; +} diff --git a/cpp/src/IceGrid/PlatformInfo.h b/cpp/src/IceGrid/PlatformInfo.h index ba41071bd32..6f0b2a4e63c 100644 --- a/cpp/src/IceGrid/PlatformInfo.h +++ b/cpp/src/IceGrid/PlatformInfo.h @@ -27,16 +27,18 @@ class PlatformInfo { public: - PlatformInfo(const TraceLevelsPtr&); + PlatformInfo(const Ice::CommunicatorPtr&, const TraceLevelsPtr&); ~PlatformInfo(); NodeInfo getNodeInfo() const; LoadInfo getLoadInfo(); + std::string getHostname() const; private: const TraceLevelsPtr _traceLevels; NodeInfo _info; + std::string _hostname; #if defined(_WIN32) HQUERY _query; |