Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd6d2cde authored by Yifan Hong's avatar Yifan Hong
Browse files

Wrap flock with TEMP_FAILURE_RETRY.

flock may return EINTR. There are code using LockShared() to test
existance of the directory. Don't fail spuriously.

Test: pass
Bug: 160457903
Change-Id: I51628abe05599422eb3f344781d8f3acd653c822
parent 44033e75
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1846,7 +1846,7 @@ auto SnapshotManager::OpenFile(const std::string& file, int lock_flags)
        PLOG(ERROR) << "Open failed: " << file;
        return nullptr;
    }
    if (lock_flags != 0 && flock(fd, lock_flags) < 0) {
    if (lock_flags != 0 && TEMP_FAILURE_RETRY(flock(fd, lock_flags)) < 0) {
        PLOG(ERROR) << "Acquire flock failed: " << file;
        return nullptr;
    }
@@ -1857,7 +1857,7 @@ auto SnapshotManager::OpenFile(const std::string& file, int lock_flags)
}

SnapshotManager::LockedFile::~LockedFile() {
    if (flock(fd_, LOCK_UN) < 0) {
    if (TEMP_FAILURE_RETRY(flock(fd_, LOCK_UN)) < 0) {
        PLOG(ERROR) << "Failed to unlock file: " << path_;
    }
}