summaryrefslogtreecommitdiff
path: root/src/stream_wrap.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2014-02-28 12:14:05 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2014-02-28 18:02:02 +0400
commit3b88dc6f19feda070ae1b9955dad7acfc6ed0142 (patch)
treee8daa627e28f0e9a8d7ebf58d71ba67b9e2b60dd /src/stream_wrap.cc
parent37d3c56c0b7870e5a03f389444c37cde063ca76a (diff)
downloadandroid-node-v8-3b88dc6f19feda070ae1b9955dad7acfc6ed0142.tar.gz
android-node-v8-3b88dc6f19feda070ae1b9955dad7acfc6ed0142.tar.bz2
android-node-v8-3b88dc6f19feda070ae1b9955dad7acfc6ed0142.zip
stream_wrap: don't write twice on uv_try_write err
fix #7155
Diffstat (limited to 'src/stream_wrap.cc')
-rw-r--r--src/stream_wrap.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index 3a2d110efa..62193fd796 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -215,7 +215,9 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
uv_buf_t* bufs = &buf;
size_t count = 1;
int err = wrap->callbacks()->TryWrite(&bufs, &count);
- if (err == 0)
+ if (err != 0)
+ goto done;
+ if (count == 0)
goto done;
assert(count == 1);
@@ -296,11 +298,15 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
size_t count = 1;
err = wrap->callbacks()->TryWrite(&bufs, &count);
+ // Failure
+ if (err != 0)
+ goto done;
+
// Success
- if (err == 0)
+ if (count == 0)
goto done;
- // Failure, or partial write
+ // Partial write
assert(count == 1);
}
@@ -603,6 +609,8 @@ int StreamWrapCallbacks::TryWrite(uv_buf_t** bufs, size_t* count) {
size_t vcount = *count;
err = uv_try_write(wrap()->stream(), vbufs, vcount);
+ if (err == UV_ENOSYS)
+ return 0;
if (err < 0)
return err;
@@ -626,10 +634,7 @@ int StreamWrapCallbacks::TryWrite(uv_buf_t** bufs, size_t* count) {
*bufs = vbufs;
*count = vcount;
- if (vcount == 0)
- return 0;
- else
- return -1;
+ return 0;
}