system/dbus: dump method prints msgbuf
All checks were successful
Test / Create distribution (push) Successful in 1m27s
Test / Run NixOS test (push) Successful in 4m1s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-02-07 13:16:54 +09:00
parent 568d7758d5
commit 2e52191404
3 changed files with 9 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ func (sys *I) MustProxyDBus(sessionPath string, session *dbus.Config, systemPath
}
}
func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath string) (func(f func(msgbuf []string)), error) {
func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath string) (func(), error) {
d := new(DBus)
// used by waiting goroutine to notify process exit
@@ -65,7 +65,7 @@ func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath st
// seal dbus proxy
d.out = &scanToFmsg{msg: new(strings.Builder)}
return d.out.F, fmsg.WrapErrorSuffix(d.proxy.Seal(session, system),
return d.out.Dump, fmsg.WrapErrorSuffix(d.proxy.Seal(session, system),
"cannot seal message bus proxy:")
}
@@ -195,8 +195,10 @@ func (s *scanToFmsg) write(p []byte, a int) (int, error) {
}
}
func (s *scanToFmsg) F(f func(msgbuf []string)) {
func (s *scanToFmsg) Dump() {
s.mu.RLock()
f(s.msgbuf)
for _, msg := range s.msgbuf {
fmsg.Println(msg)
}
s.mu.RUnlock()
}