Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1028)

Unified Diff: base/posix/file_descriptor_shuffle.cc

Issue 114603009: posix LaunchProcess: Don't use STL iterators after fork. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/process/launch_posix.cc » ('j') | base/process/launch_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/posix/file_descriptor_shuffle.cc
diff --git a/base/posix/file_descriptor_shuffle.cc b/base/posix/file_descriptor_shuffle.cc
index 7bc9e26eb5825879fe5aa2eddd3ec991c91a0dd2..d2fd39a95aacf78a578cbd301073266d12fa51c8 100644
--- a/base/posix/file_descriptor_shuffle.cc
+++ b/base/posix/file_descriptor_shuffle.cc
@@ -19,20 +19,24 @@ bool PerformInjectiveMultimapDestructive(
int extra_fds[kMaxExtraFDs];
unsigned next_extra_fd = 0;
- // DANGER: this function may not allocate.
+ // DANGER: this function must not allocate or lock.
+ // Cannot use STL iterators here, since debug iterators use locks.
- for (InjectiveMultimap::iterator i = m->begin(); i != m->end(); ++i) {
+ for (size_t i_index = 0; i_index < m->size(); ++i_index) {
+ InjectiveMultimap::value_type* i = &(*m)[i_index];
int temp_fd = -1;
// We DCHECK the injectiveness of the mapping.
- for (InjectiveMultimap::iterator j = i + 1; j != m->end(); ++j) {
+ for (size_t j_index = i_index + 1; j_index < m->size(); ++j_index) {
+ InjectiveMultimap::value_type* j = &(*m)[j_index];
DCHECK(i->dest != j->dest) << "Both fd " << i->source
<< " and " << j->source << " map to " << i->dest;
}
const bool is_identity = i->source == i->dest;
- for (InjectiveMultimap::iterator j = i + 1; j != m->end(); ++j) {
+ for (size_t j_index = i_index + 1; j_index < m->size(); ++j_index) {
+ InjectiveMultimap::value_type* j = &(*m)[j_index];
if (!is_identity && i->dest == j->source) {
if (temp_fd == -1) {
if (!delegate->Duplicate(&temp_fd, i->dest))
« no previous file with comments | « no previous file | base/process/launch_posix.cc » ('j') | base/process/launch_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698