Skip to content

Commit

Permalink
Merge pull request #780 from AntelopeIO/nonatomic_append_fallback
Browse files Browse the repository at this point in the history
[1.0.2] non-atomic append fallback to `random_access_file` for old kernels
  • Loading branch information
spoonincode authored Sep 16, 2024
2 parents 3942cef + 3c21c0e commit ea7fe7c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libraries/libfc/include/fc/io/random_access_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ struct random_access_file_context {

ssize_t wrote = -1;
do {
if(offs == append_t)
if(offs == append_t) {
#ifdef __linux__
wrote = pwritev2(fd, iov, i, 0, RWF_APPEND); //linux *not* opened with O_APPEND, appending requires special flag
if(wrote == -1 && errno == EOPNOTSUPP) //fallback for kernels before 4.16
wrote = pwritev(fd, iov, i, size());
#else
wrote = writev(fd, iov, i); //opened with O_APPEND, just write
#endif
else
} else {
wrote = pwritev(fd, iov, i, offs);
}
} while(wrote == -1 && errno == EINTR);
FC_ASSERT(wrote != -1, "write failure on file ${fn}: ${e}", ("fn", display_path)("e", strerror(errno)));

Expand Down

0 comments on commit ea7fe7c

Please sign in to comment.