Share one VNC session agent manager across all accept loops

This commit is contained in:
Viktor Liu
2026-07-30 14:29:34 +02:00
parent c88950e9c5
commit 34669a0be8
6 changed files with 98 additions and 17 deletions
+12 -2
View File
@@ -29,8 +29,11 @@ func (s *Server) serviceAcceptLoop(ln net.Listener) {
return
}
mgr := newDarwinAgentManager(s.ctx)
defer mgr.stop()
mgr := s.serviceAgent()
if mgr == nil {
s.log.Error("service mode: no agent manager available")
return
}
log.Info("service mode, proxying connections to per-user agent over Unix socket")
@@ -61,3 +64,10 @@ func (s *Server) serviceAcceptLoop(ln net.Listener) {
}(conn)
}
}
// newServiceAgentManager starts the manager that owns the per-user agent.
// Called once per server via Server.serviceAgent.
func (s *Server) newServiceAgentManager() (sessionAgent, func()) {
mgr := newDarwinAgentManager(s.ctx)
return mgr, mgr.stop
}