mirror of https://github.com/lukechilds/node.git
Browse Source
This commit enables writev for Unix Domain Sockets on supported platforms thus enabling cork/uncork functionality for them and improving IPC performance. Fixes: https://github.com/nodejs/node/issues/5095 PR-URL: https://github.com/nodejs/node/pull/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>v6.x
Alexey Orlenko
8 years ago
committed by
Myles Borins
2 changed files with 50 additions and 0 deletions
@ -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(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue