From b9e1831167f153c36337a12760fbf2976cf19d86 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 30 Jul 2026 00:29:28 +0200 Subject: [PATCH] fix session.All/Get to use rootState.sessions map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All() and Get() were looking at root.Children() (mounted child trees) but sessions are stored in rootState.sessions. They were never mounted as children, so All() always returned empty — breaking D-Bus ListSessions and WatchExisting, causing the KDE GUI to see no restored sessions. --- session/session.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/session/session.go b/session/session.go index eb99d96..7a158f4 100644 --- a/session/session.go +++ b/session/session.go @@ -1,31 +1,25 @@ // Package session builds the session/ file tree for the 9P namespace. -// The tree IS the session collection — sessions are mounted children. -// No manager, no store. Package functions for lifecycle. +// The tree IS the session collection — rootState holds the sessions map. +// Package functions for lifecycle, lookup, and enumeration. package session import ( "olliesrv/fs" ) -// Get returns the Session mounted at id, or nil. +// Get returns the Session for id, or nil. func Get(root *fs.Tree, id string) *Session { - child := root.Child(id) - if child == nil { - return nil - } - if sess, ok := child.Data.(*Session); ok { - return sess - } - return nil + return Lookup(root, id) } -// All returns all mounted sessions. +// All returns all active sessions. func All(root *fs.Tree) []*Session { - var sessions []*Session - for _, child := range root.Children() { - if sess, ok := child.Data.(*Session); ok { - sessions = append(sessions, sess) - } + rs := state(root) + rs.mu.RLock() + defer rs.mu.RUnlock() + sessions := make([]*Session, 0, len(rs.sessions)) + for _, sess := range rs.sessions { + sessions = append(sessions, sess) } return sessions }