[starnix] Only remove the timer when deadline hasn't changed

Previously we would always remove the "same timer" from the heap, even
if the deadline for it had changed. This introduced a race condition
where:

  1. An interval timer was scheduled with deadline A.
  2. The "local" timer triggered, the outstanding hrtimer call was
     cancelled, and the timer's deadline was updated.
  3. The hrtimer actually had time to trigger, so the callback was
     called. This callback removed the timer from the timer heap, since
     it relies on the interval timer logic to reschedule the timer
     appropriately.

However, the timer had already been re-added (with a new deadline) to
the heap, so removing it caused us to remove the next instance of the
timer.

Longer term we likely need to come up with a different structure for
managing the timer <-> hrtimer relationship. We could also introduce an
API that is easier to use for us to schedule Fuchsia wake alarms in a
hardware-agnostic way. That component could then be responsible for
managing the actual hrtimers.

Test: This will be tested by the sysfs suspend tests in a future change.

Fixed: 371006392
Change-Id: Ieba9af4275941e186b0bc74a0f934ee40aba3ecb
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1130458
Reviewed-by: Guocheng Wei <guochengwei@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Kevin Lindkvist <lindkvist@google.com>
1 file changed
tree: abc2259f5a776ce86d52563638c821a69bc54c0f
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. infra/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .editorconfig
  17. .git-blame-ignore-revs
  18. .gitattributes
  19. .gitignore
  20. .gitmodules
  21. .gn
  22. .ignore
  23. analysis_options.yaml
  24. AUTHORS
  25. BUILD.gn
  26. CODE_OF_CONDUCT.md
  27. CONTRIBUTING.md
  28. fuchsia.code-workspace
  29. LICENSE
  30. OWNERS
  31. PATENTS
  32. pyproject.toml
  33. pyrightconfig.json
  34. README.md
  35. rustfmt.toml
  36. shac.star
  37. shac.textproto
README.md

Fuchsia

What is Fuchsia?

Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.

We expect everyone interacting with our project to respect our code of conduct.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.