Skip to content

Commit fb95e7f

Browse files
author
Vito Caputo
committed
Add Close method to go-systemd/dbus
1 parent cf3cdf7 commit fb95e7f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dbus/dbus.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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.
8990
func 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.
9597
func 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+
99106
func newConnection(createBus func() (*dbus.Conn, error)) (*Conn, error) {
100107
sysconn, err := dbusConnection(createBus)
101108
if err != nil {

0 commit comments

Comments
 (0)