diff --git a/tensorflow/core/common_runtime/executor.h b/tensorflow/core/common_runtime/executor.h index b5f4ebb0053..3fd932da5b6 100644 --- a/tensorflow/core/common_runtime/executor.h +++ b/tensorflow/core/common_runtime/executor.h @@ -202,11 +202,12 @@ class ExecutorBarrier { // below. if (--pending_ == 0) { CHECK(done_cb_ != nullptr); - done = done_cb_; - done_cb_ = nullptr; + std::swap(done, done_cb_); } - status = status_; + if (!status_.ok()) { + status = status_; + } } if (error) {