Commit 9cce3b90 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Add IoUringBackend::NotAvailable exception

Summary: Add IoUringBackend::NotAvailable exception

Reviewed By: kevin-vigor

Differential Revision: D19143143

fbshipit-source-id: 7b55106d50882d34fc6100a81ff2a4e5748e9b85
parent ed74c95c
...@@ -37,7 +37,7 @@ IoUringBackend::IoUringBackend(size_t capacity, size_t maxSubmit, size_t maxGet) ...@@ -37,7 +37,7 @@ IoUringBackend::IoUringBackend(size_t capacity, size_t maxSubmit, size_t maxGet)
<< params_.cq_entries << ") " << params_.cq_entries << ") "
<< "failed errno = " << errno << ":\"" << folly::errnoStr(errno) << "failed errno = " << errno << ":\"" << folly::errnoStr(errno)
<< "\" " << this; << "\" " << this;
throw std::runtime_error("io_uring_queue_init error"); throw NotAvailable("io_uring_queue_init error");
} }
sqRingMask_ = *ioRing_.sq.kring_mask; sqRingMask_ = *ioRing_.sq.kring_mask;
...@@ -63,7 +63,7 @@ IoUringBackend::IoUringBackend(size_t capacity, size_t maxSubmit, size_t maxGet) ...@@ -63,7 +63,7 @@ IoUringBackend::IoUringBackend(size_t capacity, size_t maxSubmit, size_t maxGet)
if (!addTimerFd()) { if (!addTimerFd()) {
cleanup(); cleanup();
entries_.reset(); entries_.reset();
throw std::runtime_error("io_uring_submit error"); throw NotAvailable("io_uring_submit error");
} }
} }
...@@ -87,7 +87,7 @@ bool IoUringBackend::isAvailable() { ...@@ -87,7 +87,7 @@ bool IoUringBackend::isAvailable() {
folly::call_once(initFlag, [&]() { folly::call_once(initFlag, [&]() {
try { try {
IoUringBackend backend(1024, 128); IoUringBackend backend(1024, 128);
} catch (const std::runtime_error&) { } catch (const NotAvailable&) {
sAvailable = false; sAvailable = false;
} }
}); });
......
...@@ -27,6 +27,12 @@ namespace folly { ...@@ -27,6 +27,12 @@ namespace folly {
class IoUringBackend : public PollIoBackend { class IoUringBackend : public PollIoBackend {
public: public:
class NotAvailable : public std::runtime_error {
public:
explicit NotAvailable(const std::string& what) noexcept
: std::runtime_error(what) {}
};
explicit IoUringBackend( explicit IoUringBackend(
size_t capacity, size_t capacity,
size_t maxSubmit = 128, size_t maxSubmit = 128,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment