Skip to content

Retry the NQPTP probe at startup so a fresh shared-memory name does not fail - #2278

Merged
mikebrady merged 1 commit into
mikebrady:developmentfrom
haavar:poc/nqptp-probe-retry
Sep 10, 2026
Merged

mikebrady merged 1 commit into
mikebrady:developmentfrom
haavar:poc/nqptp-probe-retry

Conversation

@haavar

@haavar haavar commented Sep 4, 2026

Copy link
Copy Markdown

nqptp creates the named shared-memory interface only when it receives the "T"
message shairport-sync sends at startup, so with a brand-new interface name --
for example a per-instance general.nqptp_shared_memory_interface_name -- the
interface does not exist yet when the single probe runs a moment later. The probe
then reports "NQPTP service not found" and, on that first start, the instance
either dies (service_type "airplay2") or silently falls back to classic AirPlay
on port 5000 ("auto"). A restart succeeds only because the interface now exists,
so it is invisible under a supervisor that restarts -- but it bites anyone adding
a fresh instance, and "it silently came up as AirPlay 1 on port 5000" is
unpleasant to debug.

This re-enables the retry loop that was already present but commented out: the
probe polls for a short window (up to 2s, 50ms interval) on ENOENT before giving
up. Only ENOENT ("not created yet") is retried; any other result falls through
immediately.

Verified: with a fresh shm name the current code fatals on first start; with the
retry the interface is found at ~50ms and the instance comes up in AirPlay 2.
Surfaced independently by @jslove and in #2266 once instances stop sharing the
default shm name.

@mikebrady

Copy link
Copy Markdown
Owner

Thanks for this. You'll see that there was a version of this commented out. The reason was that it wasn't needed in the setups tried, but it would certainly be useful to re-enable it.

However, the timeout is a problem:

The intention is to release just one version of Shairport Sync in the future, which will do AirPlay 2 if NQPTP is present and Classic AirPlay otherwise. For someone who only wants Classic AirPlay, the timeout is an unnecessary delay at startup. So, what about a timeout of 0.5 seconds? Would that cover our needs?

nqptp creates the named shared-memory interface only when it receives the "T"
message shairport-sync sends at startup, so with a brand-new interface name
(for example a per-instance general.nqptp_shared_memory_interface_name) the
interface does not exist yet when the probe runs a moment later. The single
probe then reports "NQPTP service not found" and the instance dies
(service_type "airplay2") or silently falls back to classic AirPlay on port
5000 ("auto") on its first start; a restart succeeds only because the interface
now exists.

Re-enable the retry loop that was already present but commented out, so the
probe polls for a short window (up to 0.5s, 50ms interval) on ENOENT before
giving up. Only ENOENT ("not created yet") is retried; any other result falls
through immediately -- so a Classic-only start (no NQPTP) is not delayed beyond
that window.
@haavar
haavar force-pushed the poc/nqptp-probe-retry branch from 88d9a4a to 7d8212d Compare September 8, 2026 15:07
@haavar

haavar commented Sep 8, 2026

Copy link
Copy Markdown
Author

Makes sense, and 0.5s is fine. In my testing the segment showed up about 50 ms after the T -- the first 50 ms retry already caught it -- so half a second is roughly a 10x margin over what I actually saw, and it keeps the Classic-only start from waiting. I've pushed it as 0.5s.

@mikebrady
mikebrady merged commit 67b90d1 into mikebrady:development Sep 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants