From b686ff35977c3ea5076efce780449d8d8abe66c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Grimmtj=C3=A4rn?= Date: Thu, 21 Feb 2019 13:10:40 +0100 Subject: [PATCH] Changed interlocks in Disconnect method --- device_connection.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/device_connection.go b/device_connection.go index 2a61f7a..64a1afa 100644 --- a/device_connection.go +++ b/device_connection.go @@ -119,23 +119,19 @@ func (d *Device) connect() error { } func (d *Device) Disconnect() { + d.Lock() if d.conn != nil { - d.RLock() for _, subscription := range d.subscriptions { subscription.Handler.Disconnect() } - d.RUnlock() - d.Lock() d.subscriptions = make(map[string]*Subscription, 0) d.Dispatch(events.Disconnected{}) d.conn.Close() d.conn = nil - d.Unlock() } - d.Lock() d.connected = false d.Unlock() }