From fb95e7f4d2b72d6a255467d8690afe38e8427f1a Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 2 Oct 2014 14:53:20 -0400 Subject: [PATCH] Add Close method to go-systemd/dbus --- dbus/dbus.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbus/dbus.go b/dbus/dbus.go index a6bd1fd0..e105b932 100644 --- a/dbus/dbus.go +++ b/dbus/dbus.go @@ -86,16 +86,23 @@ type Conn struct { } // New establishes a connection to the system bus and authenticates. +// Callers should call Close() when done with the connection. func New() (*Conn, error) { return newConnection(dbus.SystemBusPrivate) } // NewUserConnection establishes a connection to the session bus and // authenticates. This can be used to connect to systemd user instances. +// Callers should call Close() when done with the connection. func NewUserConnection() (*Conn, error) { return newConnection(dbus.SessionBusPrivate) } +// Close closes an established connection +func (c *Conn) Close() { + c.sysconn.Close() +} + func newConnection(createBus func() (*dbus.Conn, error)) (*Conn, error) { sysconn, err := dbusConnection(createBus) if err != nil {