From e670afbac865d864b4d8df547d683246264bc6e7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 8 May 2019 19:08:28 -0700 Subject: [PATCH] ircd::fs: Return zero rather than propagating exception from write_life getter. --- include/ircd/fs/fd.h | 2 +- ircd/fs.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/ircd/fs/fd.h b/include/ircd/fs/fd.h index 7df8e63f6..2a3fb8be8 100644 --- a/include/ircd/fs/fd.h +++ b/include/ircd/fs/fd.h @@ -19,7 +19,7 @@ namespace ircd::fs size_t block_size(const fd &); ulong fstype(const fd &); ulong device(const fd &); - uint64_t write_life(const fd &); + uint64_t write_life(const fd &) noexcept; void write_life(const fd &, const uint64_t &); } diff --git a/ircd/fs.cc b/ircd/fs.cc index 6bf93a047..b21f53770 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -1551,11 +1551,23 @@ ircd::fs::write_life(const fd &fd, #if defined(HAVE_FCNTL_H) && defined(F_GET_FILE_RW_HINT) uint64_t ircd::fs::write_life(const fd &fd) +noexcept try { uint64_t ret; syscall(::fcntl, int(fd), F_GET_FILE_RW_HINT, &ret); return ret; } +catch(const std::system_error &e) +{ + log::derror + { + log, "fcntl(F_GET_FILE_RW_HINT) fd:%d :%s", + int(fd), + e.what() + }; + + return 0; +} #else #warning "F_GET_FILE_RW_HINT not supported on platform." uint64_t