Index: net/disk_cache/simple/simple_index_file_posix.cc |
diff --git a/net/disk_cache/simple/simple_index_file_posix.cc b/net/disk_cache/simple/simple_index_file_posix.cc |
index 4dffbdc78f81cea8056ff922ce9a83a367ceaa2b..e0dd3dd126a98801b5711eb892d8ca79bd9b3bfc 100644 |
--- a/net/disk_cache/simple/simple_index_file_posix.cc |
+++ b/net/disk_cache/simple/simple_index_file_posix.cc |
@@ -34,22 +34,18 @@ |
PLOG(ERROR) << "opendir " << cache_path.value(); |
return false; |
} |
- // In all implementations of the C library that Chromium can run with, |
- // concurrent calls to readdir that specify different directory streams are |
- // thread-safe. This is the case here, since the directory stream is scoped to |
- // the current function. See https://codereview.chromium.org/2411833004/#msg3 |
- errno = 0; |
- for (dirent* entry = readdir(dir.get()); entry; entry = readdir(dir.get())) { |
- const std::string file_name(entry->d_name); |
+ dirent entry, *result; |
+ while (readdir_r(dir.get(), &entry, &result) == 0) { |
+ if (!result) |
+ return true; // The traversal completed successfully. |
+ const std::string file_name(result->d_name); |
if (file_name == "." || file_name == "..") |
continue; |
const base::FilePath file_path = cache_path.Append( |
base::FilePath(file_name)); |
entry_file_callback.Run(file_path); |
} |
- if (!errno) |
- return true; // The traversal completed successfully. |
- PLOG(ERROR) << "readdir " << cache_path.value(); |
+ PLOG(ERROR) << "readdir_r " << cache_path.value(); |
return false; |
} |