mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
this should prevent some write callbacks to be called twice
This commit is contained in:
parent
e45a662829
commit
88966c405a
1 changed files with 8 additions and 8 deletions
|
|
@ -151,6 +151,14 @@ void EIO_AfterWrite(uv_work_t* req) {
|
|||
QueuedWrite* queuedWrite = static_cast<QueuedWrite*>(req->data);
|
||||
WriteBaton* data = static_cast<WriteBaton*>(queuedWrite->baton);
|
||||
|
||||
if (data->offset < data->bufferLength && !data->errorString[0]) {
|
||||
// We're not done with this baton, so throw it right back onto the queue.
|
||||
// Don't re-push the write in the event loop if there was an error; because same error could occur again!
|
||||
// TODO: Add a uv_poll here for unix...
|
||||
uv_queue_work(uv_default_loop(), req, EIO_Write, (uv_after_work_cb)EIO_AfterWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> argv[2];
|
||||
if(data->errorString[0]) {
|
||||
argv[0] = v8::Exception::Error(NanNew<v8::String>(data->errorString));
|
||||
|
|
@ -161,14 +169,6 @@ void EIO_AfterWrite(uv_work_t* req) {
|
|||
}
|
||||
data->callback->Call(2, argv);
|
||||
|
||||
if (data->offset < data->bufferLength && !data->errorString[0]) {
|
||||
// We're not done with this baton, so throw it right back onto the queue.
|
||||
// Don't re-push the write in the event loop if there was an error; because same error could occur again!
|
||||
// TODO: Add a uv_poll here for unix...
|
||||
uv_queue_work(uv_default_loop(), req, EIO_Write, (uv_after_work_cb)EIO_AfterWrite);
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&write_queue_mutex);
|
||||
QUEUE_REMOVE(&queuedWrite->queue);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue