Skip to content

buffer, interval, to_stream, and to_typed_stream deadlock with a delay of timespan::zero() #2030

Description

@dominiklohmann

The interval flow operator deadlocks when passing in caf::timespan::zero() for the max_delay argument.

We tracked it down to the loop in this code which never finishes when period_ <= timespan::zero():

auto now = parent_->steady_time();
auto next = last_ + period_;
while (next <= now)
next += period_;
last_ = next;
schedule_next(next);

Besides the interval operator, this also affects the buffer operator and the to_stream and to_typed_stream methods on observables, which use interval internally.

I think the following changes should be made to fix the issues:

  1. The interval and buffer should assert that max_delay >= timespan::zero() holds true.
  2. The to_stream and to_typed_stream methods should support an unbuffered mode where they do not even attempt to create the interval operator.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions