Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't auto-advance time when a spawn_blocking task is running. #5115

Merged
merged 18 commits into from Dec 17, 2022

Commits on Nov 16, 2022

  1. Don't auto-advance time when a spawn_blocking task is running.

    Time shouldn't auto-advance unless there's really nothing else going on. In
    general that is hard to fix, but this special case is relatively easy.
    
    Fixes: tokio-rs#4614
    jorendorff committed Nov 16, 2022
    Copy the full SHA
    6d16ce1 View commit details
    Browse the repository at this point in the history
  2. spawn_blocking: Re-enable auto-advance if the task panics.

    This uses a destructor, so it will also work if tokio machinery panics while
    trying to e.g. spawn a thread.
    jorendorff committed Nov 16, 2022
    Copy the full SHA
    282236f View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    53053f9 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    0474462 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    5887558 View commit details
    Browse the repository at this point in the history
  6. Copy the full SHA
    d62c616 View commit details
    Browse the repository at this point in the history
  7. Attempt to fix race condition with blocking tasks and paused time.

    The auto-advance inhibit count must be decremented after the blocking task is
    finished, and crucially after waking the JoinHandle, to prevent the tokio
    thread from auto-advancing before tasks awaiting that JoinHandle are
    rescheduled.
    jorendorff committed Nov 16, 2022
    Copy the full SHA
    0e6f71b View commit details
    Browse the repository at this point in the history
  8. Copy the full SHA
    b8aee57 View commit details
    Browse the repository at this point in the history
  9. Address review comments.

    jorendorff committed Nov 16, 2022
    Copy the full SHA
    895bd52 View commit details
    Browse the repository at this point in the history
  10. Fix race when main thread is parked as auto-advance is re-enabled.

    Specifically, when a blocking task is spawned, but no thread immediately awaits
    the JoinHandle, if the main thread parks itself, we previously failed to unpark
    it when the blocking task completed. Auto-advance would be re-enabled but could
    not happen, a potential deadlock.
    jorendorff committed Nov 16, 2022
    Copy the full SHA
    4ec397e View commit details
    Browse the repository at this point in the history
  11. Copy the full SHA
    9c1bee9 View commit details
    Browse the repository at this point in the history
  12. fmt

    jorendorff committed Nov 16, 2022
    Copy the full SHA
    f84b6b4 View commit details
    Browse the repository at this point in the history
  13. BlockingSchedule::new: Avoid calling Handle::current().

    It does not always work; and is it happens, the caller has a handle already and
    can just pass it in.
    jorendorff committed Nov 16, 2022
    Copy the full SHA
    9ebd9ee View commit details
    Browse the repository at this point in the history
  14. fmt

    jorendorff committed Nov 16, 2022
    Copy the full SHA
    939841f View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2022

  1. Copy the full SHA
    2de8eef View commit details
    Browse the repository at this point in the history

Commits on Dec 2, 2022

  1. Copy the full SHA
    a044bc6 View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2022

  1. Copy the full SHA
    5241fa3 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    1104a8b View commit details
    Browse the repository at this point in the history