net: use `_server` for internal book-keeping
authorFedor Indutny <fedor@indutny.com>
Tue, 16 Feb 2016 20:09:31 +0000 (15:09 -0500)
committerMyles Borins <mborins@us.ibm.com>
Wed, 2 Mar 2016 22:01:11 +0000 (14:01 -0800)
commitd9bf6e0b795a888d2d5ed6a225b7c8a9667221a1
tree4537d5fe068f5b25077c00a374e8270e236fe700
parent2f6cf0a3eb5d5f3379cf182b928b00e76973cbca
net: use `_server` for internal book-keeping

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>
lib/_tls_wrap.js
lib/net.js
test/parallel/test-net-stream.js
test/parallel/test-tls-server-connection-server.js [new file with mode: 0644]