mirror of https://github.com/lukechilds/node.git
Browse Source
The role of `this.server` is now split between `this._server` and `this.server`. Where the first one is used for counting active connections of `net.Server`, and the latter one is just a public API for users' consumption. The reasoning for this is simple, `TLSSocket` instances wrap `net.Socket` instances, thus both refer to the `net.Server` through the `this.server` property. However, only one of them should be used for `net.Server` connection count book-keeping, otherwise double-decrement will happen on socket destruction. Fix: #5083 PR-URL: https://github.com/nodejs/node/pull/5262 Reviewed-By: James M Snell <jasnell@gmail.com>v5.x
Fedor Indutny
9 years ago
committed by
Rod Vagg
4 changed files with 44 additions and 10 deletions
@ -0,0 +1,34 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
|
|||
if (!common.hasCrypto) { |
|||
console.log('1..0 # Skipped: missing crypto'); |
|||
return; |
|||
} |
|||
|
|||
const assert = require('assert'); |
|||
const tls = require('tls'); |
|||
const fs = require('fs'); |
|||
|
|||
const options = { |
|||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), |
|||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') |
|||
}; |
|||
|
|||
const server = tls.createServer(options, function(s) { |
|||
s.end('hello'); |
|||
}).listen(common.PORT, function() { |
|||
const opts = { |
|||
port: common.PORT, |
|||
rejectUnauthorized: false |
|||
}; |
|||
|
|||
server.on('connection', common.mustCall(function(socket) { |
|||
assert(socket.server === server); |
|||
server.close(); |
|||
})); |
|||
|
|||
const client = tls.connect(opts, function() { |
|||
client.end(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue