Skip to content

Commit

Permalink
fs: use fs.writev() internally
Browse files Browse the repository at this point in the history
Avoid using internal API in fs implementation.

PR-URL: #29189
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
ronag authored and Trott committed Aug 20, 2019
1 parent 5116a6a commit 490ec9b
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions lib/internal/fs/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

const { Math, Object } = primordials;

const {
FSReqCallback,
writeBuffers
} = internalBinding('fs');
const {
ERR_INVALID_ARG_TYPE,
ERR_OUT_OF_RANGE
Expand Down Expand Up @@ -325,18 +321,6 @@ WriteStream.prototype._write = function(data, encoding, cb) {
};


function writev(fd, chunks, position, callback) {
function wrapper(err, written) {
// Retain a reference to chunks so that they can't be GC'ed too soon.
callback(err, written || 0, chunks);
}

const req = new FSReqCallback();
req.oncomplete = wrapper;
writeBuffers(fd, chunks, position, req);
}


WriteStream.prototype._writev = function(data, cb) {
if (typeof this.fd !== 'number') {
return this.once('open', function() {
Expand All @@ -356,7 +340,7 @@ WriteStream.prototype._writev = function(data, cb) {
size += chunk.length;
}

writev(this.fd, chunks, this.pos, function(er, bytes) {
fs.writev(this.fd, chunks, this.pos, function(er, bytes) {
if (er) {
self.destroy();
return cb(er);
Expand Down

0 comments on commit 490ec9b

Please sign in to comment.