Skip to content

Commit

Permalink
Merge pull request #10 from vcaputo/fix_conn_double_close
Browse files Browse the repository at this point in the history
Prevent double-close panic in conn.Close
  • Loading branch information
philips committed Oct 7, 2014
2 parents cfab99a + 713a871 commit 25a4b8c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ func (conn *Conn) BusObject() *Object {
// not be called on shared connections.
func (conn *Conn) Close() error {
conn.outLck.Lock()
if conn.closed {
// inWorker calls Close on read error, the read error may
// be caused by another caller calling Close to shutdown the
// dbus connection, a double-close scenario we prevent here.
conn.outLck.Unlock()
return nil
}
close(conn.out)
conn.closed = true
conn.outLck.Unlock()
Expand Down

0 comments on commit 25a4b8c

Please sign in to comment.