File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -86,16 +86,23 @@ type Conn struct {
8686}
8787
8888// New establishes a connection to the system bus and authenticates.
89+ // Callers should call Close() when done with the connection.
8990func New () (* Conn , error ) {
9091 return newConnection (dbus .SystemBusPrivate )
9192}
9293
9394// NewUserConnection establishes a connection to the session bus and
9495// authenticates. This can be used to connect to systemd user instances.
96+ // Callers should call Close() when done with the connection.
9597func NewUserConnection () (* Conn , error ) {
9698 return newConnection (dbus .SessionBusPrivate )
9799}
98100
101+ // Close closes an established connection
102+ func (c * Conn ) Close () {
103+ c .sysconn .Close ()
104+ }
105+
99106func newConnection (createBus func () (* dbus.Conn , error )) (* Conn , error ) {
100107 sysconn , err := dbusConnection (createBus )
101108 if err != nil {
You can’t perform that action at this time.
0 commit comments