Skip to content

Commit

Permalink
prevent use WaitFor with temporary futures (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpeye authored Apr 26, 2024
1 parent 5417fad commit b4ff2c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cloud/storage/core/libs/coroutine/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TExecutor final
template <typename T>
const T& WaitFor(NThreading::TFuture<T> future)
{
struct TRequestCancelled : T
struct TRequestCancelled: T
{
TRequestCancelled()
: T(TErrorResponse(E_REJECTED, "request cancelled"))
Expand All @@ -56,6 +56,15 @@ class TExecutor final
return future.GetValue();
}

template <typename T>
T WaitFor(NThreading::TFuture<T>&& future)
{
if (!future.HasValue() && !WaitForI(future)) {
return TErrorResponse(E_REJECTED, "request cancelled");
}
return future.ExtractValue();
}

void WaitFor(NThreading::TFuture<void> future)
{
if (!future.HasValue()) {
Expand Down

0 comments on commit b4ff2c5

Please sign in to comment.