Skip to content

Commit 7094a79

Browse files
jlhe97meta-codesync[bot]
authored andcommitted
c++|be| fix active events bug in iourinbackend
Summary: 1. inlining this one-liner functions 2. we were setting `gettingEvents_ = true;` after throwing which is deadcode. Instead we are setting right after (if we enter again then do throw). Once we exit the function scope then set flag back to false. Reviewed By: vishwanath1306 Differential Revision: D92342550 fbshipit-source-id: 21f6a4fd00ca6709963ea66993a06cbba839811d
1 parent e8527ee commit 7094a79

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

folly/io/async/IoUringBackend.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,9 +1475,13 @@ int IoUringBackend::cancelOne(IoSqe* ioSqe) {
14751475
size_t IoUringBackend::getActiveEvents(WaitForEventsMode waitForEvents) {
14761476
struct io_uring_cqe* cqe;
14771477

1478-
setGetActiveEvents();
1478+
if (kIsDebug && gettingEvents_) {
1479+
throw std::runtime_error("getting events is not reentrant");
1480+
}
1481+
gettingEvents_ = true;
1482+
14791483
SCOPE_EXIT {
1480-
doneGetActiveEvents();
1484+
gettingEvents_ = false;
14811485
};
14821486

14831487
auto inner_do_wait = [&]() -> int {

folly/io/async/IoUringBackend.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,6 @@ class IoUringBackend : public EventBaseBackendBase {
11721172
void dCheckSubmitTid();
11731173
void setSubmitting() noexcept { isSubmitting_++; }
11741174
void doneSubmitting() noexcept { isSubmitting_--; }
1175-
void setGetActiveEvents() {
1176-
if (kIsDebug && gettingEvents_) {
1177-
throw std::runtime_error("getting events is not reentrant");
1178-
gettingEvents_ = true;
1179-
}
1180-
}
1181-
void doneGetActiveEvents() noexcept { gettingEvents_ = false; }
11821175
bool isSubmitting() const noexcept { return isSubmitting_; }
11831176
};
11841177

0 commit comments

Comments
 (0)