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.
tls: properly track writeQueueSize during writes
Make writeQueueSize represent the actual size of the write queue within the TLS socket. Add tls test to confirm that bufferSize works as expected. PR-URL: nodejs#15791 Fixes: nodejs#15005 Refs: nodejs#15006 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
- Loading branch information
1 parent
1136741
commit 7533f59
Showing
4 changed files
with
68 additions
and
5 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
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,43 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const fixtures = require('../common/fixtures'); | ||
const tls = require('tls'); | ||
|
||
const iter = 10; | ||
const overhead = 30; | ||
|
||
const server = tls.createServer({ | ||
key: fixtures.readKey('agent2-key.pem'), | ||
cert: fixtures.readKey('agent2-cert.pem') | ||
}, common.mustCall((socket) => { | ||
socket.on('readable', common.mustCallAtLeast(() => { | ||
socket.read(); | ||
}, 1)); | ||
|
||
socket.on('end', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = tls.connect({ | ||
port: server.address().port, | ||
rejectUnauthorized: false | ||
}, common.mustCall(() => { | ||
assert.strictEqual(client.bufferSize, 0); | ||
|
||
for (let i = 1; i < iter; i++) { | ||
client.write('a'); | ||
assert.strictEqual(client.bufferSize, i + overhead); | ||
} | ||
|
||
client.on('finish', common.mustCall(() => { | ||
assert.strictEqual(client.bufferSize, 0); | ||
})); | ||
|
||
client.end(); | ||
})); | ||
})); |