dcsctp: Handle starting timer from timer callback

This was caught in an integration test which had stricter assertions
than the FakeTimeout which is used in unit tests, so the first thing was
to add the same assertions to the FakeTimeout.

The issue is that when a Timer triggers, and if it's set to
automatically restart (possibly with an exponential backoff), the
`is_running_` field was set to true while the timer callback was called
to allow the client to know that the timer is in fact running, but the
timer was actually not started until the callback returned. Which made
sense, as the callback can with its return value override the duration,
which should affect the backoff algorithm.

The problem was when a timer was manually started within the callback.
As the Timer itself thought that it was already running, it first would
Stop() the underlying Timeout, then Start(). But calling Stop() on a
timeout that is not running is illegal, which set of assertions.

So the solution is to don't lie; Don't say that a timer is running when
it's not. Make sure that the timer is running when the timer callback is
triggered, which makes it consistent at all times. That may result in
unnecessary timeout invocations (stopping and starting), but that's not
too expensive.

Bug: webrtc:12614
Change-Id: I7b4447ccd88bd43d181e158f0d29b0770c8a3fd6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217522
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33926}
3 files changed
tree: 33b42c611a1b3109330e5405a7ec80eee56d0462
  1. api/
  2. audio/
  3. build_overrides/
  4. call/
  5. common_audio/
  6. common_video/
  7. data/
  8. docs/
  9. examples/
  10. g3doc/
  11. logging/
  12. media/
  13. modules/
  14. net/
  15. p2p/
  16. pc/
  17. resources/
  18. rtc_base/
  19. rtc_tools/
  20. sdk/
  21. stats/
  22. style-guide/
  23. system_wrappers/
  24. test/
  25. tools_webrtc/
  26. video/
  27. .clang-format
  28. .git-blame-ignore-revs
  29. .gitignore
  30. .gn
  31. .vpython
  32. abseil-in-webrtc.md
  33. AUTHORS
  34. BUILD.gn
  35. CODE_OF_CONDUCT.md
  36. codereview.settings
  37. DEPS
  38. DIR_METADATA
  39. ENG_REVIEW_OWNERS
  40. g3doc.lua
  41. LICENSE
  42. license_template.txt
  43. native-api.md
  44. OWNERS
  45. PATENTS
  46. PRESUBMIT.py
  47. presubmit_test.py
  48. presubmit_test_mocks.py
  49. pylintrc
  50. README.chromium
  51. README.md
  52. style-guide.md
  53. WATCHLISTS
  54. webrtc.gni
  55. webrtc_lib_link_test.cc
  56. whitespace.txt
README.md

WebRTC is a free, open software project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.

Our mission: To enable rich, high-quality RTC applications to be developed for the browser, mobile platforms, and IoT devices, and allow them all to communicate via a common set of protocols.

The WebRTC initiative is a project supported by Google, Mozilla and Opera, amongst others.

Development

See here for instructions on how to get started developing with the native code.

Authoritative list of directories that contain the native API header files.

More info