From a767a16022de0b08050368c6ec620d5a514c48cb Mon Sep 17 00:00:00 2001 From: Bret McGuire Date: Mon, 25 Sep 2023 15:30:39 -0500 Subject: [PATCH 1/2] Play nicely with the predicate guards in the future wait operation --- src/future.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/future.cpp b/src/future.cpp index 1d4ad5347..818c00c93 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -189,7 +189,6 @@ bool Future::set_callback(Future::Callback callback, void* data) { } void Future::internal_set(ScopedMutex& lock) { - is_set_ = true; if (callback_) { Callback callback = callback_; void* data = data_; @@ -197,6 +196,11 @@ void Future::internal_set(ScopedMutex& lock) { callback(CassFuture::to(this), data); lock.lock(); } + + // CPP-987 Set this after the callbacks run to avoid unexpected exits from wait ops in the callbacks + // due to spurious wakeups + is_set_ = true; + // Broadcast after we've run the callback so that threads waiting // on this future see the side effects of the callback. uv_cond_broadcast(&cond_); From 4b533c9bec82d67e252357cc2792ac95684ffbea Mon Sep 17 00:00:00 2001 From: Bret McGuire Date: Thu, 28 Sep 2023 15:44:38 -0500 Subject: [PATCH 2/2] Clean up comment a bit --- src/future.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/future.cpp b/src/future.cpp index 818c00c93..9b882add8 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -197,8 +197,8 @@ void Future::internal_set(ScopedMutex& lock) { lock.lock(); } - // CPP-987 Set this after the callbacks run to avoid unexpected exits from wait ops in the callbacks - // due to spurious wakeups + // CPP-987 Set this after the callbacks run to avoid unexpected exits + // from wait ops due to spurious wakeups is_set_ = true; // Broadcast after we've run the callback so that threads waiting