forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: nodejs#5095 PR-URL: nodejs#10677 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
beedd45
commit dd71bf8
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |