Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit ac55fba

Browse files
authored
Merge pull request #405 from pbatey/master
destroy socket if auto-bind fails
2 parents 95ee4f5 + 5f21dbf commit ac55fba

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/client/client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ function Client(options) {
348348
this.on('setup', function (clt, cb) {
349349
clt.bind(options.bindDN, options.bindCredentials, function (err) {
350350
if (err) {
351+
if (self._socket) {
352+
self._socket.destroy()
353+
}
351354
self.emit('error', err);
352355
}
353356
cb(err);

test/client.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ test('auto-bind bad credentials', function (t) {
334334
});
335335
clt.once('error', function (err) {
336336
t.equal(err.code, ldap.LDAP_INVALID_CREDENTIALS);
337+
t.ok(clt._socket.destroyed, 'expect socket to be destroyed');
337338
clt.destroy();
338339
t.end();
339340
});

0 commit comments

Comments
 (0)