Circumvent lack of 'close' event for tls sockets
It appears that in node.js (at least recent versions), the 'close' event is not emitted by TLS sockets. The CleartextStream class specifies that the 'close' event is optional, so such operation is allowed. In order to compensate, the event can be trapped at the raw net.socket instead. Fix mcavage/node-ldapjs#161
This commit is contained in:
parent
c5cfc48da4
commit
d20308265a
|
@ -103,11 +103,14 @@ function setupSocket(socket, opts) {
|
|||
};
|
||||
}
|
||||
|
||||
// Since tls.socket doesn't emit 'close' events, we must register to receive
|
||||
// them on net.socket instead
|
||||
var closeSocket = (opts.secure ? socket.socket : socket);
|
||||
// On close we have to walk the outstanding messages and go invoke their
|
||||
// callback with an error
|
||||
socket.on('close', function onClose(had_err) {
|
||||
// callback with an error.
|
||||
closeSocket.on('close', function onClose(had_err) {
|
||||
socket.removeAllListeners('connect');
|
||||
socket.removeAllListeners('close');
|
||||
closeSocket.removeAllListeners('close');
|
||||
socket.removeAllListeners('data');
|
||||
socket.removeAllListeners('drain');
|
||||
socket.removeAllListeners('end');
|
||||
|
|
Loading…
Reference in New Issue