Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe: enable writev for pipe handles on Unix #10677

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pipe_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ void PipeWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "ref", HandleWrap::Ref);
env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef);

#ifdef _WIN32
StreamWrap::AddMethods(env, t);
#else
StreamWrap::AddMethods(env, t, StreamBase::kFlagHasWritev);
#endif

env->SetProtoMethod(t, "bind", Bind);
env->SetProtoMethod(t, "listen", Listen);
Expand Down
46 changes: 46 additions & 0 deletions test/parallel/test-pipe-writev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const net = require('net');

if (common.isWindows) {
common.skip('Unix-specific test');
return;
}

common.refreshTmpDir();

const server = net.createServer((connection) => {
connection.on('error', (err) => {
throw err;
});

const writev = connection._writev.bind(connection);
connection._writev = common.mustCall(writev);

connection.cork();
connection.write('pi');
connection.write('ng');
connection.end();
});

server.on('error', (err) => {
throw err;
});

server.listen(common.PIPE, () => {
const client = net.connect(common.PIPE);

client.on('error', (err) => {
throw err;
});

client.on('data', common.mustCall((data) => {
assert.strictEqual(data.toString(), 'ping');
}));

client.on('end', () => {
server.close();
});
});