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