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

tracing: make Entered !Send #1001

Merged
merged 5 commits into from
Sep 30, 2020
Merged

tracing: make Entered !Send #1001

merged 5 commits into from
Sep 30, 2020

Commits on Sep 29, 2020

  1. tracing: make Entered !Send

    The `Entered` guard returned by `Span::enter` represents entering and
    exiting a span _on the current thread_. Calling `Span::enter` enters the
    span, returning an `Entered`, and dropping the `Entered` ensures that
    the span is exited. This ensures that all spans, once entered, are
    eventually exited.
    
    However, `Entered` has an auto-impl of `Send`, because it doesn't
    contain any `!Send` types. This means that the `Entered` guard _could_
    be sent to another thread and dropped. This would cause the original
    thread to never exit the span,. and the thread to which the `Entered`
    guard was sent would exit a span that it never observed an enter for.
    This is incorrect.
    
    This PR adds a `*mut ()` field to `Entered` so that it no longer
    implements `Send`. There's now a manual `Sync` impl so structs holding
    an `Entered` can still be `Sync`.
    
    Fixes #698
    
    Signed-off-by: Eliza Weisman <eliza@buoyant.io>
    hawkw committed Sep 29, 2020
    Configuration menu
    Copy the full SHA
    7eef5d3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    89ce4fd View commit details
    Browse the repository at this point in the history
  3. !Send + Sync without unsafe!

    thanks @MikailBag for the suggestion!
    
    Signed-off-by: Eliza Weisman <eliza@buoyant.io>
    hawkw committed Sep 29, 2020
    Configuration menu
    Copy the full SHA
    81e9e5b View commit details
    Browse the repository at this point in the history
  4. Merge branch 'eliza/0.2-api-fixes' of github.com:tokio-rs/tracing int…

    …o eliza/0.2-api-fixes
    hawkw committed Sep 29, 2020
    Configuration menu
    Copy the full SHA
    bdb80e7 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2020

  1. Revert "!Send + Sync without unsafe!"

    This reverts commit 81e9e5b. .
    
    Ut turns out this approach doesn't actually work in this specific case.
    Because `tracing` has conditional support for `no_std`, we can't use the
    `std::sync` version of `MutexGuard`. I thought we could use the
    `MutexGuard` from the spinlock implementation that's used as a fallback
    on no-std platforms, but I'd forgotten that this is defined in
    `tracing-core`, not `tracing`, and isn't publicly visible. I'll probably
    go back to the previous approach of just accepting the additional
    `unsafe` keyword necessary to manually impl `Sync`.
    hawkw committed Sep 30, 2020
    Configuration menu
    Copy the full SHA
    674aa38 View commit details
    Browse the repository at this point in the history