-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: use
.destroy(err)
instead of destroy+emit
Emit errors using `.destroy(err)` instead of `.destroy()` and `.emit('error', err)`. Otherwise `close` event is emitted with the `error` argument set to `false`, even if the connection was torn down because of the error. See: #1119 PR-URL: #1711 Reviewed-By: Chris Dickinson <[email protected]>
- Loading branch information
Showing
2 changed files
with
64 additions
and
14 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,42 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var common = require('../common'); | ||
|
||
if (!common.hasCrypto) { | ||
console.log('1..0 # Skipped: missing crypto'); | ||
process.exit(); | ||
} | ||
var tls = require('tls'); | ||
|
||
var fs = require('fs'); | ||
var net = require('net'); | ||
|
||
var errorCount = 0; | ||
var closeCount = 0; | ||
|
||
var server = tls.createServer({ | ||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') | ||
}, function(c) { | ||
}).listen(common.PORT, function() { | ||
var c = tls.connect(common.PORT, function() { | ||
assert(false, 'should not be called'); | ||
}); | ||
|
||
c.on('error', function(err) { | ||
errorCount++; | ||
}); | ||
|
||
c.on('close', function(err) { | ||
if (err) | ||
closeCount++; | ||
|
||
server.close(); | ||
}); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.equal(errorCount, 1); | ||
assert.equal(closeCount, 1); | ||
}); |