Skip to content

Commit

Permalink
Merge pull request #7 from stampzilla/stamp/panic-fix
Browse files Browse the repository at this point in the history
Changed interlocks in Disconnect method
  • Loading branch information
stamp authored Feb 21, 2019
2 parents d0c2faf + b686ff3 commit 0a779e5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions device_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 0a779e5

Please sign in to comment.