From 69f9eb93e27a7a81b53f3749e0c4d3b03aeea6cc Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Fri, 24 Feb 2017 09:36:17 +0100 Subject: [PATCH] When terminating the Context, wait for the background goroutine to sync on c.done channel before exiting. --- usb/usb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/usb.go b/usb/usb.go index 47784fb..bde7434 100644 --- a/usb/usb.go +++ b/usb/usb.go @@ -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) }