Refactor the patch to limit its scope to bind actions

This way, other tests keep passing
This commit is contained in:
Thomas P 2019-10-11 23:23:46 +02:00
parent 53d6b36bb2
commit d702c455bd
No known key found for this signature in database
GPG Key ID: 722E1405F9F15F5E
1 changed files with 5 additions and 19 deletions

View File

@ -120,10 +120,6 @@ function Client (options) {
this.log = options.log.child({ clazz: 'Client' }, true)
this.on('error', function (err) {
self.cb(err)
})
this.timeout = parseInt((options.timeout || 0), 10)
this.connectTimeout = parseInt((options.connectTimeout || 0), 10)
this.idleTimeout = parseInt((options.idleTimeout || 0), 10)
@ -172,18 +168,6 @@ function Client (options) {
util.inherits(Client, EventEmitter)
module.exports = Client
/**
* Default handler for error callbacks when
* one isn't set in the instance
*/
Client.prototype.cb = function (err, ret) {
if (err) {
this.log.error('Caught exception:', err)
} else {
this.log.info('Unhandled output:', ret)
}
}
/**
* Sends an abandon request to the LDAP server.
*
@ -298,13 +282,15 @@ Client.prototype.bind = function bind (name,
controls: controls
})
// While we are binding to the server, register the callback as error handler
var self = this
this.cb = function (err, ret) {
delete self.cb
function callbackWrapper (err, ret) {
self.removeListener('error', callbackWrapper)
callback(err, ret)
}
this.addListener('error', callbackWrapper)
return this._send(req, [errors.LDAP_SUCCESS], null, callback, _bypass)
return this._send(req, [errors.LDAP_SUCCESS], null, callbackWrapper, _bypass)
}
/**