-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
streams: support unlimited synchronous cork/uncork cycles
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: 89aeab9 (#4354). Fixes: #6154 PR-URL: #6164 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Mathias Buus <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
6 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,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('aa'); | ||
|
||
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(); | ||
}); | ||
} |