tls: use `.destroy(err)` instead of destroy+emit
authorFedor Indutny <fedor@indutny.com>
Fri, 15 May 2015 19:21:06 +0000 (21:21 +0200)
committerFedor Indutny <fedor@indutny.com>
Fri, 22 May 2015 11:27:04 +0000 (13:27 +0200)
commit80342f649d8df1f58c1e5ff222778749c1c539c1
tree22393abafde11ba2ec65cd84e79711ece05bb5a5
parent2b1c01c2cc203dd6131c3fc6238cf62a2e697f63
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: https://github.com/nodejs/io.js/issues/1119
PR-URL: https://github.com/nodejs/io.js/pull/1711
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
lib/_tls_wrap.js
test/parallel/test-tls-close-error.js [new file with mode: 0644]