diff options
author | James M Snell <jasnell@gmail.com> | 2017-08-18 15:37:35 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-23 10:51:15 -0700 |
commit | 58831b2f24a6b71b172e5f5876cb77096408142e (patch) | |
tree | aff51623b82e17dbc63f48ad1b6692a6f09bf70c /lib/_stream_wrap.js | |
parent | 5e7c69716ecbb7a0ebceaed7cc1c6847f9bc5058 (diff) | |
download | node-new-58831b2f24a6b71b172e5f5876cb77096408142e.tar.gz |
uv: improvements to process.binding('uv')
* ensure that UV_... props are constants
* improve error message ... the error message when passing
in `err >= 0` to `util._errnoException()` was less than
useful.
* refine uses of process.binding('uv')
PR-URL: https://github.com/nodejs/node/pull/14933
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/_stream_wrap.js')
-rw-r--r-- | lib/_stream_wrap.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/_stream_wrap.js b/lib/_stream_wrap.js index 00e6de2fd2..5ae091614f 100644 --- a/lib/_stream_wrap.js +++ b/lib/_stream_wrap.js @@ -129,20 +129,18 @@ StreamWrap.prototype.doWrite = function doWrite(req, bufs) { // Ensure that this is called once in case of error pending = 0; + let errCode = 0; + if (err) { + const code = uv[`UV_${err.code}`]; + errCode = (err.code && code) ? code : uv.UV_EPIPE; + } + // Ensure that write was dispatched setImmediate(function() { // Do not invoke callback twice if (!self._dequeue(item)) return; - var errCode = 0; - if (err) { - if (err.code && uv['UV_' + err.code]) - errCode = uv['UV_' + err.code]; - else - errCode = uv.UV_EPIPE; - } - handle.doAfterWrite(req); handle.finishWrite(req, errCode); }); |