src: handle last event before exiting status threads
- Avoid 2 consecutive calls to uv_async_send when exiting the cardreader.cpp check status thread. - Fix mutex unlock location in cardreader.cpp check status thread. PR-URL: https://github.com/santigimeno/node-pcsclite/pull/46 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
committed by
Santiago Gimeno
parent
0a3eaafb2b
commit
3800c39291
@@ -124,11 +124,6 @@ void PCSCLite::HandleReaderStatusChange(uv_async_t *handle, int status) {
|
||||
AsyncBaton* async_baton = static_cast<AsyncBaton*>(handle->data);
|
||||
AsyncResult* ar = async_baton->async_result;
|
||||
|
||||
if (ar->do_exit) {
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&async_baton->async), CloseCallback); // necessary otherwise UV will block
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ar->result == SCARD_S_SUCCESS) || (ar->result == (LONG)SCARD_E_NO_READERS_AVAILABLE)) {
|
||||
const unsigned argc = 2;
|
||||
Local<Value> argv[argc] = {
|
||||
@@ -145,6 +140,12 @@ void PCSCLite::HandleReaderStatusChange(uv_async_t *handle, int status) {
|
||||
Nan::Callback(Nan::New(async_baton->callback)).Call(argc, argv);
|
||||
}
|
||||
|
||||
// Do exit, after throwing last events
|
||||
if (ar->do_exit) {
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&async_baton->async), CloseCallback); // necessary otherwise UV will block
|
||||
return;
|
||||
}
|
||||
|
||||
/* reset AsyncResult */
|
||||
delete [] ar->readers_name;
|
||||
ar->readers_name = NULL;
|
||||
|
||||
Reference in New Issue
Block a user