fix(daemon): use parent ctx for MarkSessionReady so cancel propagates
Critico flag: rctx was rooted at context.Background() instead of the session's hlsCtx, so a tab close / session cancel mid-POST left the goroutine blocking on the in-flight webhook for up to 10 s. Switched to a child of hlsCtx — the same scope the watchSessionReady loop already respects via the outer ctx.Done() select. Idempotent webhook means a now-orphan session getting marked ready is cosmetic; the savings here are goroutine pinning + a slow webhook on a torn-down session.
This commit is contained in:
parent
4ccd37aa5d
commit
69fff32420
1 changed files with 4 additions and 1 deletions
|
|
@ -962,7 +962,10 @@ func watchSessionReady(ctx context.Context, client *agent.Client, hsess *engine.
|
||||||
for {
|
for {
|
||||||
// Cache HIT or seg-0 ready → notify + done.
|
// Cache HIT or seg-0 ready → notify + done.
|
||||||
if hsess.FromCache() || hsess.ReadyCount() >= 1 {
|
if hsess.FromCache() || hsess.ReadyCount() >= 1 {
|
||||||
rctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
// Parent ctx so a session cancel mid-POST (user closed tab,
|
||||||
|
// daemon shutdown) tears down the in-flight webhook instead of
|
||||||
|
// blocking the goroutine for up to 10 s on a now-orphan call.
|
||||||
|
rctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
if err := client.MarkSessionReady(rctx, sessionID); err != nil {
|
if err := client.MarkSessionReady(rctx, sessionID); err != nil {
|
||||||
log.Printf("[hls %s] mark-ready failed: %v", agent.ShortID(sessionID), err)
|
log.Printf("[hls %s] mark-ready failed: %v", agent.ShortID(sessionID), err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue