Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86216 - trunk/libs/thread/src/pthread
From: tim_at_[hidden]
Date: 2013-10-09 11:25:31


Author: timblechmann
Date: 2013-10-09 11:25:31 EDT (Wed, 09 Oct 2013)
New Revision: 86216
URL: http://svn.boost.org/trac/boost/changeset/86216

Log:
thread: physical_concurrency - work around getline issue in libc++

Text files modified:
   trunk/libs/thread/src/pthread/thread.cpp | 10 ++++++++--
   1 files changed, 8 insertions(+), 2 deletions(-)

Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp Wed Oct 9 11:24:58 2013 (r86215)
+++ trunk/libs/thread/src/pthread/thread.cpp 2013-10-09 11:25:31 EDT (Wed, 09 Oct 2013) (r86216)
@@ -560,7 +560,6 @@
 
             ifstream proc_cpuinfo ("/proc/cpuinfo");
 
- unsigned current_processor = 0;
             const string physical_id("physical id"), core_id("core id");
 
             typedef std::pair<unsigned, unsigned> core_entry; // [physical ID, core id]
@@ -569,10 +568,17 @@
 
             core_entry current_core_entry;
 
- for (string line; getline(proc_cpuinfo, line); ) {
+ string line;
+ while ( getline(proc_cpuinfo, line) ) {
+ if (line.empty())
+ continue;
+
                 vector<string> key_val(2);
                 boost::split(key_val, line, boost::is_any_of(":"));
 
+ if (key_val.size() != 2)
+ return 0;
+
                 string key = key_val[0];
                 string value = key_val[1];
                 boost::trim(key);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk