tarantool / tarantool/doc

`fiber_join`, `fiber_join_timeout` and `fiber_set_joinable`

Open
#3,853 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.0 c api fiber
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Related dev. issue(s): https://github.com/tarantool/tarantool/issues/7562

Product: Tarantool
Since: 3.0
Root document: https://www.tarantool.io/en/doc/latest/dev_guide/reference_capi/fiber/
SME: @ mkostoevr

Note: looks like a bug fix that doesn't require significant documentation changes.

Details

fiber_join, fiber_join_timeout, and fiber_set_joinable behave differently now.

fiber_join and fiber_join_timeout now panic in case if double
join of the given fiber is detected.

fiber_set_joinable now panics if the given fiber is dead or is
joined already. This prevents some amount of error conditions that
could happen when using the API in an unexpected way, including:

  • Making a dead joinable fiber non-joinable could lead to a memory
    leak: one can't join the fiber anymore.
  • Making a dead joinable fiber joinable again is a sign of attempt
    to join the fiber later. That means the fiber struct may be joined
    later, when it's been recycled and reused. This could lead to a
    very hard to debug double join.
  • Making an alive joined fiber non-joinable would lead to the double
    free: once on the fiber function finish, and secondly in the active
    fiber join finish. Risks of making it joinable are described above.
  • Making a dead and recycled fiber joinable allowed to join the fiber
    once again leading to a double free.

Any given by the API struct fiber should only be joined once. If a
fiber is joined after the first join on it has finished the behavior
is undefined: it can either be a panic or an incidental join to a
totally foreign fiber.
Requested by @ mkostoevr in https://github.com/tarantool/tarantool/commit/44401529a2253cbf00583a3680ae01f0cb74693c.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the fiber C API root document and locate the entries for fiber_join, fiber_join_timeout, and fiber_set_joinable. Compare their descriptions with the panic conditions, single-join rule, and undefined behavior listed here; the documentation is done when it accurately reflects the current API behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.