usb 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.2] - 2021-12-05
4
+
5
+ ### Fixed
6
+ - Fixed exit delay and hang by moving queue start/stop to device open/close - [`460`](https://github.com/node-usb/node-usb/pull/460) ([MikeColeGuru](https://github.com/MikeColeGuru))
7
+
3
8
  ## [1.9.1] - 2021-11-14
4
9
 
5
10
  ### Fixed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "usb",
3
3
  "description": "Library to access USB devices",
4
- "version": "1.9.1",
4
+ "version": "1.9.2",
5
5
  "engines": {
6
6
  "node": ">=10.16.0"
7
7
  },
Binary file
Binary file
Binary file
package/src/device.cc CHANGED
@@ -19,18 +19,12 @@ Device::Device(const Napi::CallbackInfo & info) : Napi::ObjectWrap<Device>(info)
19
19
  device = info[0].As<Napi::External<libusb_device>>().Data();
20
20
  libusb_ref_device(device);
21
21
  byPtr.insert(std::make_pair(device, this));
22
- #ifndef USE_POLL
23
- completionQueue.start(info.Env());
24
- #endif
25
22
  DEBUG_LOG("Created device %p", this);
26
23
  Constructor(info);
27
24
  }
28
25
 
29
26
  Device::~Device(){
30
27
  DEBUG_LOG("Freed device %p", this);
31
- #ifndef USE_POLL
32
- completionQueue.stop();
33
- #endif
34
28
  byPtr.erase(device);
35
29
  libusb_close(device_handle);
36
30
  libusb_unref_device(device);
@@ -194,6 +188,9 @@ Napi::Value Device::Open(const Napi::CallbackInfo& info) {
194
188
  ENTER_METHOD(Device, 0);
195
189
  if (!self->device_handle){
196
190
  CHECK_USB(libusb_open(self->device, &self->device_handle));
191
+ #ifndef USE_POLL
192
+ completionQueue.start(info.Env());
193
+ #endif
197
194
  }
198
195
  return env.Undefined();
199
196
  }
@@ -203,6 +200,9 @@ Napi::Value Device::Close(const Napi::CallbackInfo& info) {
203
200
  if (self->canClose()){
204
201
  libusb_close(self->device_handle);
205
202
  self->device_handle = NULL;
203
+ #ifndef USE_POLL
204
+ completionQueue.stop();
205
+ #endif
206
206
  }else{
207
207
  THROW_ERROR("Can't close device with a pending request");
208
208
  }