diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2002-09-20 20:00:33 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2002-09-20 20:00:33 +0000 |
commit | a2f897ebd40ff1c51bec62dcbb156d3282a39ac6 (patch) | |
tree | ac691ce2d9f5cbb4067a76f2a83ca9aa435e9306 | |
parent | b1c4ecfee4238f552193d7cd08f88d1852e1d96f (diff) | |
download | ATCD-a2f897ebd40ff1c51bec62dcbb156d3282a39ac6.tar.gz |
ChangeLogTag:Fri Sep 20 12:53:58 2002 Ossama Othman <ossama@uci.edu>
-rw-r--r-- | TAO/ChangeLog | 12 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp | 31 |
2 files changed, 43 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 9940ee58cc8..1423a31307c 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,15 @@ +Fri Sep 20 12:53:58 2002 Ossama Othman <ossama@uci.edu> + + * orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp (loads): + + For the Linux case, only obtain the load average via + ::getloadavg() if Glibc 2.2 or better is used, and if either + _BSD_SOURCE or _GNU_SOURCE is defined. Otherwise, obtain the + load average directly from the `/proc/loadavg' virtual file. + This address problems compiling the new load balancer on older + Linux distributions. Thanks to Knut-Ha*vard Aksnes for + reporting the problem. [Bug 1311] + Wed Sep 18 09:23:44 2002 Priyanka Gontla <pgontla@ociweb.com> * orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp (reregister_server): diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp index dda6d288e4a..e768d7722be 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_CPU_Monitor.cpp @@ -101,8 +101,39 @@ TAO_LB_CPU_Monitor::loads (ACE_ENV_SINGLE_ARG_DECL) // last 5 and 15 minutes can be used instead. double loadavg[1]; +# if defined (linux) \ + && ((defined (__GLIBC__) && defined (__GLIBC_MINOR__) \ + && __GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \ + || (!defined (_BSD_SOURCE) && !defined (_GNU_SOURCE))) + + // GLibc < 2.2 does not implement getloadavg(). Furthermore, + // getloadavg() is only "visible" if _BSD_SOURCE or _GNU_SOURCE is + // defined. + + // Obtain the load average directly from the `/proc' filesystem. + FILE * s = ::fopen ("/proc/loadavg", "r"); + + if (s == 0) + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + errno)), + 0); + + ACE_OS::fscanf (s, "%f", &loadavg[0]); + + (void) fclose (s); + + const int samples = 1; + +# else + const int samples = ::getloadavg (loadavg, 1); +# endif /* linux + && ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) + || (!_BSD_SOURCE && !_GNU_SOURCE)) */ + if (samples == 1) { const long num_processors = ::sysconf (_SC_NPROCESSORS_ONLN); |