Skip to content

Stream hooks are unbounded and unordered: a slow start hook can outlive its stop hook #33

Closed

Description

@chrisuthe

Stream hooks are spawned and never ordered against each other, so a start hook that runs long can finish after the stop hook of the same stream and leave an amplifier on while the player is idle — the exact failure the hooks exist to prevent.

HookRunner::run() (src/hooks.cpp) forks per event and returns immediately; poll() reaps with WNOHANG from the main loop. Nothing serialises the pair, and nothing bounds how many children may be outstanding, so repeated stream transitions with a hook that hangs accumulate processes until something runs out.

Not blocking today: the documented hook is a one-shot amixer, which finishes in milliseconds. It becomes real for anything that talks to a network relay or sleeps.

The shape of a fix, without giving up the "nothing waits on a hook" property that made the current design right:

  • Serialise per player: one hook at a time, later events queued rather than forked immediately.
  • Coalesce the queue — a start followed by a stop while the start is still running should collapse to the final state, not run both in order.
  • Bound the queue, and say so in the log when an event is dropped.

Raised by Copilot on #29 against src/hooks.cpp:110; the code is #28's, so it belongs here rather than on that PR.

Activity

  1. added
    bug
    on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions