1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Fix send_command always returning should_buffer boolean

Fix .auth, .select and .exec to return the should_buffer boolean
This commit is contained in:
Ruben Bridgewater
2015-10-05 11:16:24 +02:00
parent e47ba4a583
commit 146d88154c
5 changed files with 24 additions and 18 deletions

View File

@@ -677,10 +677,11 @@ RedisClient.prototype.send_command = function (command, args, callback) {
err = new Error('send_command: ' + command + ' value must not be undefined or null');
err.command = command;
if (callback) {
return callback && callback(err);
callback(err);
} else {
this.emit('error', err);
}
this.emit('error', err);
return;
return false;
}
}
@@ -715,7 +716,8 @@ RedisClient.prototype.send_command = function (command, args, callback) {
this.offline_queue.push(command_obj);
this.should_buffer = true;
}
return;
// Return false to signal no buffering
return false;
}
if (command === 'subscribe' || command === 'psubscribe' || command === 'unsubscribe' || command === 'punsubscribe') {
@@ -728,7 +730,7 @@ RedisClient.prototype.send_command = function (command, args, callback) {
err = new Error('Connection in subscriber mode, only subscriber commands may be used');
err.command = command.toUpperCase();
this.emit('error', err);
return;
return false;
}
this.command_queue.push(command_obj);
this.commands_sent += 1;
@@ -916,8 +918,7 @@ commands.forEach(function (fullCommand) {
// store db in this.select_db to restore it on reconnect
RedisClient.prototype.select = RedisClient.prototype.SELECT = function (db, callback) {
var self = this;
this.send_command('select', [db], function (err, res) {
return this.send_command('select', [db], function (err, res) {
if (err === null) {
self.selected_db = db;
}
@@ -939,16 +940,16 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function (pass, callba
} else {
this.emit('error', err);
}
return;
return false;
}
this.auth_pass = pass;
debug('Saving auth as ' + this.auth_pass);
// Only run the callback once. So do not safe it if already connected
if (this.connected) {
this.send_command('auth', [this.auth_pass], callback);
} else {
this.auth_callback = callback;
return this.send_command('auth', [this.auth_pass], callback);
}
this.auth_callback = callback;
return false;
};
RedisClient.prototype.hmset = RedisClient.prototype.HMSET = function (key, args, callback) {
@@ -1048,7 +1049,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = function (callback) {
this.send_command(command, args, index, cb);
}
this._client.send_command('exec', [], function(err, replies) {
return this._client.send_command('exec', [], function(err, replies) {
self.execute_callback(err, replies);
});
};