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

Unified Diff: runtime/bin/directory_linux.cc

Issue 165723007: Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tiny fix. Created 6 years, 9 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 | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index c37b58b1ebd42179b52212eb7198bd0f107deca8..f6b09c436d3008d690f5d67980addc030b183190 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.cc
@@ -15,6 +15,7 @@
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
+#include "platform/signal_blocker.h"
#include "bin/file.h"
#include "bin/platform.h"
@@ -105,9 +106,9 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
int status = 0;
dirent entry;
dirent* result;
- if ((status = TEMP_FAILURE_RETRY(readdir_r(reinterpret_cast<DIR*>(lister_),
- &entry,
- &result))) == 0 &&
+ if ((status = NO_RETRY_EXPECTED(readdir_r(reinterpret_cast<DIR*>(lister_),
+ &entry,
+ &result))) == 0 &&
result != NULL) {
if (!listing->path_buffer().Add(entry.d_name)) {
done_ = true;
@@ -133,7 +134,7 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
// the file pointed to.
struct stat64 entry_info;
int stat_success;
- stat_success = TEMP_FAILURE_RETRY(
+ stat_success = NO_RETRY_EXPECTED(
lstat64(listing->path_buffer().AsString(), &entry_info));
if (stat_success == -1) {
return kListError;
@@ -152,7 +153,7 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
}
previous = previous->next;
}
- stat_success = TEMP_FAILURE_RETRY(
+ stat_success = NO_RETRY_EXPECTED(
stat64(listing->path_buffer().AsString(), &entry_info));
if (stat_success == -1) {
// Report a broken link as a link, even if follow_links is true.
@@ -196,7 +197,7 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
DirectoryListingEntry::~DirectoryListingEntry() {
ResetLink();
if (lister_ != 0) {
- closedir(reinterpret_cast<DIR*>(lister_));
+ VOID_NO_RETRY_EXPECTED(closedir(reinterpret_cast<DIR*>(lister_)));
}
}
@@ -217,7 +218,8 @@ static bool DeleteRecursively(PathBuffer* path);
static bool DeleteFile(char* file_name,
PathBuffer* path) {
- return path->Add(file_name) && unlink(path->AsString()) == 0;
+ return path->Add(file_name) &&
+ NO_RETRY_EXPECTED(unlink(path->AsString())) == 0;
}
@@ -233,10 +235,10 @@ static bool DeleteRecursively(PathBuffer* path) {
// Do not recurse into links for deletion. Instead delete the link.
// If it's a file, delete it.
struct stat64 st;
- if (TEMP_FAILURE_RETRY(lstat64(path->AsString(), &st)) == -1) {
+ if (NO_RETRY_EXPECTED(lstat64(path->AsString(), &st)) == -1) {
return false;
} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
- return (unlink(path->AsString()) == 0);
+ return (NO_RETRY_EXPECTED(unlink(path->AsString())) == 0);
}
if (!path->Add(File::PathSeparator())) return false;
@@ -258,11 +260,10 @@ static bool DeleteRecursively(PathBuffer* path) {
bool success = true;
dirent entry;
dirent* result;
- while ((read = TEMP_FAILURE_RETRY(readdir_r(dir_pointer,
- &entry,
- &result))) == 0 &&
- result != NULL &&
- success) {
+ while ((read = NO_RETRY_EXPECTED(
+ readdir_r(dir_pointer, &entry, &result))) == 0 &&
+ result != NULL &&
+ success) {
switch (entry.d_type) {
case DT_DIR:
success = success && DeleteDir(entry.d_name, path);
@@ -283,7 +284,7 @@ static bool DeleteRecursively(PathBuffer* path) {
// readdir_r. For those we use lstat to determine the entry
// type.
struct stat64 entry_info;
- int lstat_success = TEMP_FAILURE_RETRY(
+ int lstat_success = NO_RETRY_EXPECTED(
lstat64(path->AsString(), &entry_info));
if (lstat_success == -1) {
success = false;
@@ -307,8 +308,8 @@ static bool DeleteRecursively(PathBuffer* path) {
}
if ((read != 0) ||
- (closedir(dir_pointer) == -1) ||
- (remove(path->AsString()) == -1)) {
+ (NO_RETRY_EXPECTED(closedir(dir_pointer)) == -1) ||
+ (NO_RETRY_EXPECTED(remove(path->AsString())) == -1)) {
return false;
}
return success;
@@ -317,7 +318,7 @@ static bool DeleteRecursively(PathBuffer* path) {
Directory::ExistsResult Directory::Exists(const char* dir_name) {
struct stat64 entry_info;
- int success = TEMP_FAILURE_RETRY(stat64(dir_name, &entry_info));
+ int success = NO_RETRY_EXPECTED(stat64(dir_name, &entry_info));
if (success == 0) {
if (S_ISDIR(entry_info.st_mode)) {
return EXISTS;
@@ -361,15 +362,14 @@ char* Directory::Current() {
bool Directory::SetCurrent(const char* path) {
- int result = TEMP_FAILURE_RETRY(chdir(path));
- return result == 0;
+ return NO_RETRY_EXPECTED(chdir(path)) == 0;
}
bool Directory::Create(const char* dir_name) {
// Create the directory with the permissions specified by the
// process umask.
- int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777));
+ int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777));
// If the directory already exists, treat it as a success.
if (result == -1 && errno == EEXIST) {
return (Exists(dir_name) == EXISTS);
@@ -422,9 +422,9 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
if (File::GetType(dir_name, false) == File::kIsLink &&
File::GetType(dir_name, true) == File::kIsDirectory) {
- return (TEMP_FAILURE_RETRY(unlink(dir_name)) == 0);
+ return NO_RETRY_EXPECTED(unlink(dir_name)) == 0;
}
- return (TEMP_FAILURE_RETRY(rmdir(dir_name)) == 0);
+ return NO_RETRY_EXPECTED(rmdir(dir_name)) == 0;
} else {
PathBuffer path;
if (!path.Add(dir_name)) {
@@ -438,7 +438,7 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
bool Directory::Rename(const char* path, const char* new_path) {
ExistsResult exists = Exists(path);
if (exists != EXISTS) return false;
- return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0);
+ return NO_RETRY_EXPECTED(rename(path, new_path)) == 0;
}
} // namespace bin
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698