mirror of https://github.com/lukechilds/node.git
Browse Source
net streams can request multiple chunks to be written in a synchronous
fashion. If this is combined with cork/uncork, en error is currently
thrown because of a regression introduced in:
89aeab901a
(https://github.com/nodejs/node/pull/4354).
Fixes: https://github.com/nodejs/node/issues/6154
PR-URL: https://github.com/nodejs/node/pull/6164
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Mathias Buus <mathiasbuus@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
committed by
James M Snell
2 changed files with 50 additions and 6 deletions
@ -0,0 +1,41 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const common = require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const net = require('net'); |
||||
|
|
||||
|
const server = net.createServer(handle); |
||||
|
|
||||
|
const N = 100; |
||||
|
const buf = Buffer.alloc(2, 'a'); |
||||
|
|
||||
|
server.listen(common.PORT, function() { |
||||
|
const conn = net.connect(common.PORT); |
||||
|
|
||||
|
conn.on('connect', () => { |
||||
|
let res = true; |
||||
|
let i = 0; |
||||
|
for (; i < N && res; i++) { |
||||
|
conn.cork(); |
||||
|
conn.write(buf); |
||||
|
res = conn.write(buf); |
||||
|
conn.uncork(); |
||||
|
} |
||||
|
assert.equal(i, N); |
||||
|
conn.end(); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
process.on('exit', function() { |
||||
|
assert.equal(server.connections, 0); |
||||
|
}); |
||||
|
|
||||
|
function handle(socket) { |
||||
|
socket.resume(); |
||||
|
|
||||
|
socket.on('error', function(err) { |
||||
|
socket.destroy(); |
||||
|
}).on('close', function() { |
||||
|
server.close(); |
||||
|
}); |
||||
|
} |
Loading…
Reference in new issue