diff --git a/checkin_notes b/checkin_notes index 0ba9ba1a95..9bad5747ce 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5255,3 +5255,13 @@ David 23 May 2007 client/ hostinfo_unix.C + +David 23 May 2007 + - client, Unix: always use 1 (rather than slot#) in ftok(). + Slot is already encoded in path. + - client, Linux: get memory size from /proc/meminfo + rather than sysconf() + + client/ + app_start.C + hostinfo_unix.C diff --git a/client/app_start.C b/client/app_start.C index 3023cb7dd8..caddf0cf18 100644 --- a/client/app_start.C +++ b/client/app_start.C @@ -147,7 +147,7 @@ int ACTIVE_TASK::get_shmem_seg_name() { // FILE* f = boinc_fopen(init_data_path, "w"); if (f) fclose(f); - shmem_seg_name = ftok(init_data_path, slot); + shmem_seg_name = ftok(init_data_path, 1); if (shmem_seg_name == -1) return ERR_SHMEM_NAME; #endif return 0; diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 5c764b862d..f211569074 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -243,6 +243,25 @@ bool HOST_INFO::host_is_running_on_batteries() { } #ifdef linux +static void parse_meminfo_linux(HOST_INFO& host) { + char buf[256]; + double x; + FILE* f = fopen("/proc/meminfo", "r"); + if (!f) return; + while (fgets(buf, 256, f)) { + if (strstr(buf, "MemTotal:")) { + sscanf(buf, "MemTotal: %lf", &x); + host.m_nbytes = x*1024; + } else if (strstr(buf, "SwapTotal:")) { + sscanf(buf, "SwapTotal: %lf", &x); + host.m_swap = x*1024; + } else if (strstr(buf, "Mem:")) { + sscanf(buf, "Mem: %lf", &host.m_nbytes); + } else if (strstr(buf, "Swap:")) { + sscanf(buf, "Swap: %lf", &host.m_swap); + } + } +} // Unfortunately the format of /proc/cpuinfo is not standardized. // See http://people.nl.linux.org/~hch/cpuinfo/ for some examples. @@ -574,12 +593,13 @@ int HOST_INFO::get_host_info() { DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulMem, sizeof(ulMem)); m_swap = ulMem; } +#elif defined(linux) + parse_meminfo_linux(*this); #elif defined(_SC_USEABLE_MEMORY) // UnixWare m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_USEABLE_MEMORY); #elif defined(_SC_PHYS_PAGES) - // Linux m_nbytes = (double)sysconf(_SC_PAGESIZE) * (double)sysconf(_SC_PHYS_PAGES); if (m_nbytes < 0) { msg_printf(NULL, MSG_INTERNAL_ERROR,