diff --git a/cmd/olliesrv/server.go b/cmd/olliesrv/server.go index 88d31ea..392fbca 100644 --- a/cmd/olliesrv/server.go +++ b/cmd/olliesrv/server.go @@ -602,7 +602,9 @@ func read(root *fs.Tree, cs *connState, fc *plan9.Fcall, ctx context.Context) *p if path == "event" { cs.mu.RLock() f, fidOK := cs.fids[fc.Fid] - connCtx := cs.ctx // Use connection context, not request context + // Use 9P connection context (not request context) so subscription + // lives until the client disconnects or clunks the fid + clientConnCtx := cs.ctx cs.mu.RUnlock() if fidOK { f.mu.Lock() @@ -615,7 +617,7 @@ func read(root *fs.Tree, cs *connState, fc *plan9.Fcall, ctx context.Context) *p if filter == "" { filter = "*" } - subCtx, cancel := context.WithCancel(connCtx) + subCtx, cancel := context.WithCancel(clientConnCtx) ch := session.SubscribeEventsFiltered(subCtx, filter) f.mu.Lock() f.eventFilter = filter