When terminating the Context, wait for the background goroutine

to sync on c.done channel before exiting.
This commit is contained in:
Sebastian Zagrodzki
2017-02-24 09:36:17 +01:00
parent 6afb417224
commit 69f9eb93e2

View File

@@ -133,7 +133,7 @@ func (c *Context) OpenDeviceWithVidPid(vid, pid int) (*Device, error) {
}
func (c *Context) Close() error {
close(c.done)
c.done <- struct{}{}
if c.ctx != nil {
C.libusb_exit(c.ctx)
}