destroy socket if auto-bind fails
This commit is contained in:
parent
cf49ee03f8
commit
5f21dbf4cd
|
@ -348,6 +348,9 @@ function Client(options) {
|
|||
this.on('setup', function (clt, cb) {
|
||||
clt.bind(options.bindDN, options.bindCredentials, function (err) {
|
||||
if (err) {
|
||||
if (self._socket) {
|
||||
self._socket.destroy()
|
||||
}
|
||||
self.emit('error', err);
|
||||
}
|
||||
cb(err);
|
||||
|
|
|
@ -334,6 +334,7 @@ test('auto-bind bad credentials', function (t) {
|
|||
});
|
||||
clt.once('error', function (err) {
|
||||
t.equal(err.code, ldap.LDAP_INVALID_CREDENTIALS);
|
||||
t.ok(clt._socket.destroyed, 'expect socket to be destroyed');
|
||||
clt.destroy();
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue