summaryrefslogtreecommitdiffstats
path: root/src/librados
diff options
context:
space:
mode:
authorLucian Petrut <lpetrut@cloudbasesolutions.com>2023-02-17 11:55:07 +0100
committerLucian Petrut <lpetrut@cloudbasesolutions.com>2023-02-20 13:59:30 +0100
commitc93daea80a18e87a2267c350dca81b8ed8c99687 (patch)
treed32d7d82fa46d7734214a8dc8e139d03af4a4348 /src/librados
parenttest/librados: avoid using rlimit on Windows (diff)
downloadceph-c93daea80a18e87a2267c350dca81b8ed8c99687.tar.xz
ceph-c93daea80a18e87a2267c350dca81b8ed8c99687.zip
librados/asio: use boost::system::generic_category on Windows
librados uses "errno.h" error codes. On Windows, boost::system::system_category refers to errors from winerror.h. That being considered, we'll add a platform check and use boost::system::generic_category on Windows. This ensures that error code comparisons work as expected. This issue was brought up by the following test assertion failure: ft2.4: ceph_test_rados_api_asio.AsioRados.AsyncWriteCallbacktesttools. testresult.real._StringException: details: {{{ /ceph/src/test/librados/asio.cc:148 Expected equality of these values: boost::system::errc::read_only_file_system Which is: 30 ec Which is: system:30 }}} Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Diffstat (limited to 'src/librados')
-rw-r--r--src/librados/librados_asio.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/librados/librados_asio.h b/src/librados/librados_asio.h
index c9b5ffba7e3..bd672d951f7 100644
--- a/src/librados/librados_asio.h
+++ b/src/librados/librados_asio.h
@@ -32,6 +32,15 @@ namespace librados {
namespace detail {
+#ifndef _WIN32
+constexpr auto err_category = boost::system::system_category;
+#else
+// librados uses "errno.h" error codes. On Windows,
+// boost::system::system_category refers to errors from winerror.h.
+// That being considered, we'll use boost::system::generic_category.
+constexpr auto err_category = boost::system::generic_category;
+#endif
+
/// unique_ptr with custom deleter for AioCompletion
struct AioCompletionDeleter {
void operator()(AioCompletion *c) { c->release(); }
@@ -76,7 +85,7 @@ struct AsyncOp : Invoker<Result> {
const int ret = op.aio_completion->get_return_value();
boost::system::error_code ec;
if (ret < 0) {
- ec.assign(-ret, boost::system::system_category());
+ ec.assign(-ret, librados::detail::err_category());
}
op.dispatch(std::move(p), ec);
}
@@ -107,7 +116,7 @@ auto async_read(ExecutionContext& ctx, IoCtx& io, const std::string& oid,
int ret = io.aio_read(oid, op.aio_completion.get(), &op.result, len, off);
if (ret < 0) {
- auto ec = boost::system::error_code{-ret, boost::system::system_category()};
+ auto ec = boost::system::error_code{-ret, librados::detail::err_category()};
ceph::async::post(std::move(p), ec, bufferlist{});
} else {
p.release(); // release ownership until completion
@@ -130,7 +139,7 @@ auto async_write(ExecutionContext& ctx, IoCtx& io, const std::string& oid,
int ret = io.aio_write(oid, op.aio_completion.get(), bl, len, off);
if (ret < 0) {
- auto ec = boost::system::error_code{-ret, boost::system::system_category()};
+ auto ec = boost::system::error_code{-ret, librados::detail::err_category()};
ceph::async::post(std::move(p), ec);
} else {
p.release(); // release ownership until completion
@@ -154,7 +163,7 @@ auto async_operate(ExecutionContext& ctx, IoCtx& io, const std::string& oid,
int ret = io.aio_operate(oid, op.aio_completion.get(), read_op,
flags, &op.result);
if (ret < 0) {
- auto ec = boost::system::error_code{-ret, boost::system::system_category()};
+ auto ec = boost::system::error_code{-ret, librados::detail::err_category()};
ceph::async::post(std::move(p), ec, bufferlist{});
} else {
p.release(); // release ownership until completion
@@ -177,7 +186,7 @@ auto async_operate(ExecutionContext& ctx, IoCtx& io, const std::string& oid,
int ret = io.aio_operate(oid, op.aio_completion.get(), write_op, flags);
if (ret < 0) {
- auto ec = boost::system::error_code{-ret, boost::system::system_category()};
+ auto ec = boost::system::error_code{-ret, librados::detail::err_category()};
ceph::async::post(std::move(p), ec);
} else {
p.release(); // release ownership until completion
@@ -200,7 +209,7 @@ auto async_notify(ExecutionContext& ctx, IoCtx& io, const std::string& oid,
int ret = io.aio_notify(oid, op.aio_completion.get(),
bl, timeout_ms, &op.result);
if (ret < 0) {
- auto ec = boost::system::error_code{-ret, boost::system::system_category()};
+ auto ec = boost::system::error_code{-ret, librados::detail::err_category()};
ceph::async::post(std::move(p), ec, bufferlist{});
} else {
p.release(); // release ownership until completion