Skip to content

Commit

Permalink
Prevent loops from continuing after succeeding once
Browse files Browse the repository at this point in the history
Co-authored-by: Lawrence Mitchell <[email protected]>
  • Loading branch information
pentschev and wence- authored Nov 16, 2023
1 parent 5bda348 commit 68aef08
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cpp/src/endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void Endpoint::close(uint64_t period, uint64_t maxAttempts)

if (worker->isProgressThreadRunning()) {
bool closeSuccess = false;
for (uint64_t i = 0; i < maxAttempts; ++i) {
for (uint64_t i = 0; i < maxAttempts && !closeSuccess; ++i) {
utils::CallbackNotifier callbackNotifierPre{};
worker->registerGenericPre([this, &callbackNotifierPre, &status, closeMode]() {
status = ucp_ep_close_nb(_handle, closeMode);
Expand Down Expand Up @@ -277,7 +277,7 @@ size_t Endpoint::cancelInflightRequests(uint64_t period, uint64_t maxAttempts)
worker->progress();
} else if (worker->isProgressThreadRunning()) {
bool cancelSuccess = false;
for (uint64_t i = 0; i < maxAttempts; ++i) {
for (uint64_t i = 0; i < maxAttempts && !cancelSuccess; ++i) {
utils::CallbackNotifier callbackNotifierPre{};
worker->registerGenericPre([this, &callbackNotifierPre, &canceled]() {
canceled = _inflightRequests->cancelAll();
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ size_t Worker::cancelInflightRequests(uint64_t period, uint64_t maxAttempts)
progressPending();
} else if (isProgressThreadRunning()) {
bool cancelSuccess = false;
for (uint64_t i = 0; i < maxAttempts; ++i) {
for (uint64_t i = 0; i < maxAttempts && !cancelSuccess; ++i) {
utils::CallbackNotifier callbackNotifierPre{};
registerGenericPre([&callbackNotifierPre, &canceled, &inflightRequestsToCancel]() {
canceled = inflightRequestsToCancel->cancelAll();
Expand Down

0 comments on commit 68aef08

Please sign in to comment.