Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b89d848

Browse filesBrowse files
aqrlnItalo A. Casas
authored andcommitted
src: enable writev for pipe handles on Unix
This commit enables writev for Unix Domain Sockets on supported platforms thus enabling cork/uncork functionality for them and improving IPC performance. Fixes: #5095 PR-URL: #10677 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 06a1e9e commit b89d848
Copy full SHA for b89d848

File tree

Expand file treeCollapse file tree

2 files changed

+50
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+50
-0
lines changed
Open diff view settings
Collapse file

‎src/pipe_wrap.cc‎

Copy file name to clipboardExpand all lines: src/pipe_wrap.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ void PipeWrap::Initialize(Local<Object> target,
5353
env->SetProtoMethod(t, "ref", HandleWrap::Ref);
5454
env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef);
5555

56+
#ifdef _WIN32
5657
StreamWrap::AddMethods(env, t);
58+
#else
59+
StreamWrap::AddMethods(env, t, StreamBase::kFlagHasWritev);
60+
#endif
5761

5862
env->SetProtoMethod(t, "bind", Bind);
5963
env->SetProtoMethod(t, "listen", Listen);
Collapse file

‎test/parallel/test-pipe-writev.js‎

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const net = require('net');
6+
7+
if (common.isWindows) {
8+
common.skip('Unix-specific test');
9+
return;
10+
}
11+
12+
common.refreshTmpDir();
13+
14+
const server = net.createServer((connection) => {
15+
connection.on('error', (err) => {
16+
throw err;
17+
});
18+
19+
const writev = connection._writev.bind(connection);
20+
connection._writev = common.mustCall(writev);
21+
22+
connection.cork();
23+
connection.write('pi');
24+
connection.write('ng');
25+
connection.end();
26+
});
27+
28+
server.on('error', (err) => {
29+
throw err;
30+
});
31+
32+
server.listen(common.PIPE, () => {
33+
const client = net.connect(common.PIPE);
34+
35+
client.on('error', (err) => {
36+
throw err;
37+
});
38+
39+
client.on('data', common.mustCall((data) => {
40+
assert.strictEqual(data.toString(), 'ping');
41+
}));
42+
43+
client.on('end', () => {
44+
server.close();
45+
});
46+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.