Skip to content

Commit

Permalink
Fix aws_future_wait() with UINT64_MAX timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed May 6, 2024
1 parent 7e04b86 commit a5fdbee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/future.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,16 @@ bool aws_future_impl_wait(const struct aws_future_impl *future, uint64_t timeout
/* this function is conceptually const, but we need to use synchronization primitives */
struct aws_future_impl *mutable_future = (struct aws_future_impl *)future;

/* condition-variable takes signed timeout, so clamp to INT64_MAX (292+ years) */
int64_t timeout_i64 = aws_min_u64(timeout_ns, INT64_MAX);

/* BEGIN CRITICAL SECTION */
aws_mutex_lock(&mutable_future->lock);

bool is_done = aws_condition_variable_wait_for_pred(
&mutable_future->wait_cvar,
&mutable_future->lock,
(int64_t)timeout_ns,
timeout_i64,
s_future_impl_is_done_pred,
mutable_future) == AWS_OP_SUCCESS;

Expand Down

0 comments on commit a5fdbee

Please sign in to comment.