diff --git a/src/future.cpp b/src/future.cpp index 1d4ad5347..9b882add8 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 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_);