summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 15:45:01 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 15:45:01 +0000
commit1f094b3ad544437ec1446d9f951ebbcee8f44365 (patch)
treee9e065de820e9a405065a80d72542dd2f33afe0b /base
parentca225b4bb17ca2b440a7ac7c6b4a74dfb5201a44 (diff)
downloadchromium_src-1f094b3ad544437ec1446d9f951ebbcee8f44365.zip
chromium_src-1f094b3ad544437ec1446d9f951ebbcee8f44365.tar.gz
chromium_src-1f094b3ad544437ec1446d9f951ebbcee8f44365.tar.bz2
Fix bug in ProcessIterator::CheckForNextProcess(). Under load it's
very easy for the processes to change between the time we get a proc id from /proc then try to get other status. We shouldn't stop iterating in this case, just continue on. BUG=52022 TEST=none Review URL: http://codereview.chromium.org/6398005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util_linux.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index b6c6a2c..4cd27f6 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -200,18 +200,18 @@ bool ProcessIterator::CheckForNextProcess() {
std::string pid_string(slot->d_name);
int pid;
if (StringToInt(pid_string, &pid) && !GetProcCmdline(pid, &cmd_line_args))
- return false;
+ continue;
// Read the process's status.
char buf[NAME_MAX + 12];
sprintf(buf, "/proc/%s/stat", slot->d_name);
FILE *fp = fopen(buf, "r");
if (!fp)
- return false;
+ continue;
const char* result = fgets(buf, sizeof(buf), fp);
fclose(fp);
if (!result)
- return false;
+ continue;
// Parse the status. It is formatted like this:
// %d (%s) %c %d %d ...
@@ -221,7 +221,7 @@ bool ProcessIterator::CheckForNextProcess() {
openparen = strchr(buf, '(');
closeparen = strrchr(buf, ')');
if (!openparen || !closeparen)
- return false;
+ continue;
char runstate = closeparen[2];
// Is the process in 'Zombie' state, i.e. dead but waiting to be reaped?