use TEMP_FAILURE_RETRY with some restartable funcs
authorRobert Swiecki <robert@swiecki.net>
Wed, 17 Apr 2019 21:10:18 +0000 (23:10 +0200)
committerRobert Swiecki <robert@swiecki.net>
Wed, 17 Apr 2019 21:10:18 +0000 (23:10 +0200)
config.cc
util.cc

index cf2b86e386d8ff27f7b69c1e72a0ce32fd8c145a..5c50271a4811b6a6febe2b096e56cb4921c20702 100644 (file)
--- a/config.cc
+++ b/config.cc
@@ -289,7 +289,7 @@ static void LogHandler(
 bool parseFile(nsjconf_t* nsjconf, const char* file) {
        LOG_D("Parsing configuration from '%s'", file);
 
-       int fd = open(file, O_RDONLY | O_CLOEXEC);
+       int fd = TEMP_FAILURE_RETRY(open(file, O_RDONLY | O_CLOEXEC));
        if (fd == -1) {
                PLOG_W("Couldn't open config file '%s'", file);
                return false;
diff --git a/util.cc b/util.cc
index 2fbe30cb27378d8ad24c27569e0fa70a09df212f..c3088b6b2c7a324e9e7145c36e60f7c83da626b7 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -64,8 +64,7 @@ ssize_t readFromFd(int fd, void* buf, size_t len) {
 }
 
 ssize_t readFromFile(const char* fname, void* buf, size_t len) {
-       int fd;
-       TEMP_FAILURE_RETRY(fd = open(fname, O_RDONLY | O_CLOEXEC));
+       int fd = TEMP_FAILURE_RETRY(open(fname, O_RDONLY | O_CLOEXEC));
        if (fd == -1) {
                LOG_E("open('%s', O_RDONLY|O_CLOEXEC)", fname);
                return -1;
@@ -216,7 +215,7 @@ static void rndInitThread(void) {
                return;
        }
 #endif /* defined(__NR_getrandom) */
-       int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
+       int fd = TEMP_FAILURE_RETRY(open("/dev/urandom", O_RDONLY | O_CLOEXEC));
        if (fd == -1) {
                PLOG_D(
                    "Couldn't open /dev/urandom for reading. Using gettimeofday "