go-systemd icon indicating copy to clipboard operation
go-systemd copied to clipboard

Cannot Start or Stop Units anymore, when nothing reads from the job completion channel

Open j-licht opened this issue 1 year ago • 0 comments

https://github.com/coreos/go-systemd/blob/d843340ab4bd3815fda02e648f9b09ae2dc722a7/dbus/methods.go#L48 The jobHandler used e.g. by Conn.StartUnitContext blocks for ever if nothing reads from the provided channel. I think this write to the result channel should be non-blocking, like this:

	c.jobListener.Lock()
	out, ok := c.jobListener.jobs[job]
	if ok {
		select {
		case out <- result:
		default:
			fmt.Println("failed to write result to job channel")
		}
		delete(c.jobListener.jobs, job)
	}
	c.jobListener.Unlock()

I'm not sure, what is the best way to log something or if it's even necessary,

j-licht avatar Oct 12 '23 16:10 j-licht