this should prevent some write callbacks to be called twice

This commit is contained in:
Oliver Schneider 2014-10-05 14:18:59 +02:00
parent e45a662829
commit 88966c405a

View file

@ -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);