-
Notifications
You must be signed in to change notification settings - Fork 320
Open
Description
Conn.StartUnitContext, which actually calls internally startJob uses the given context only for the dbus call but not for the job listener.
Line 61 in d843340
err := c.sysobj.CallWithContext(ctx, job, 0, args...).Store(&p) |
This call returns nearly immediately in most cases, when dbus and systemd is reachable.
But the jobComplete signal is only received after the system job is finished, which can take more time.
So the jobListener should be removed after the context is finished.
Like this:
if ch != nil {
c.jobListener.jobs[p] = ch
go func(ctx context.Context, p dbus.ObjectPath) {
<-ctx.Done()
c.jobListener.Lock()
defer c.jobListener.Unlock()
_, ok := c.jobListener.jobs[p]
if !ok {
return
}
fmt.Println("delete job listener after context is done")
delete(c.jobListener.jobs, dbus.ObjectPath(p))
}(ctx, p)
}
But this not ideal, because it creates a go function for each call.
Metadata
Metadata
Assignees
Labels
No labels