diff --git a/common/exception/Errnum.cpp b/common/exception/Errnum.cpp index b92077cd9c85fd828dc725f643ac707033e50ae8..3daddc8765c0f399a21cbeb46d97dd924da818be 100644 --- a/common/exception/Errnum.cpp +++ b/common/exception/Errnum.cpp @@ -66,3 +66,7 @@ void Errnum::throwOnNegative(const int ret, const std::string &context) { void Errnum::throwOnMinusOne(const int ret, const std::string &context) { if (-1 == ret) throw Errnum(context); } + +void Errnum::throwOnNegativeErrnoIfNegative(const int ret, const std::string& context) { + if (ret < 0) throw Errnum(-ret, context); +} diff --git a/common/exception/Errnum.hpp b/common/exception/Errnum.hpp index 926acbfef5570283dcbdee9eb8fd93f2f5187c11..23f7e72d8e96b4d84d9edac4b65e11081382a2d3 100644 --- a/common/exception/Errnum.hpp +++ b/common/exception/Errnum.hpp @@ -35,6 +35,7 @@ namespace exception { static void throwOnNull(const void *const f, const std::string &context = ""); static void throwOnNegative(const int ret, const std::string &context = ""); static void throwOnMinusOne(const int ret, const std::string &context = ""); + static void throwOnNegativeErrnoIfNegative(const int ret, const std::string &context = ""); protected: void ErrnumConstructorBottomHalf(const std::string & what); int m_errnum; diff --git a/objectstore/BackendRados.cpp b/objectstore/BackendRados.cpp index b0c735e9439c4ce8aad3bb4c921d09f475f254af..9f7a12c30a4be0c29d31f24e538da1ed66f43f90 100644 --- a/objectstore/BackendRados.cpp +++ b/objectstore/BackendRados.cpp @@ -79,16 +79,11 @@ void BackendRados::atomicOverwrite(std::string name, std::string content) { std::string BackendRados::read(std::string name) { std::string ret; - uint64_t size; - time_t time; - cta::exception::Errnum::throwOnReturnedErrno(-m_radosCtx.stat(name, &size, &time), - std::string("In ObjectStoreRados::read, failed to stat: ") - + name); librados::bufferlist bl; - cta::exception::Errnum::throwOnNegative(m_radosCtx.read(name, bl, size, 0), + cta::exception::Errnum::throwOnNegativeErrnoIfNegative(m_radosCtx.read(name, bl, std::numeric_limits<int32_t>::max(), 0), std::string("In ObjectStoreRados::read, failed to read: ") + name); - bl.copy(0, size, ret); + bl.copy(0, bl.length(), ret); return ret; }