Skip to content

Commit

Permalink
post-merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Oct 21, 2015
1 parent f456fe8 commit d50fb59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -53,6 +53,7 @@ function RedisClient(stream, options, cnxOptions) {
this.write = this.writeStream;
}

this.options = options;
this.stream = stream;
this.connection_id = ++connection_id;
this.connected = false;
Expand Down Expand Up @@ -95,7 +96,6 @@ function RedisClient(stream, options, cnxOptions) {
this.parser_module = null;
this.selected_db = null; // Save the selected db here, used when reconnecting
this.old_state = null;
this.options = options;

if (options.failover) failover.prepareOptions(this);

Expand Down Expand Up @@ -592,7 +592,7 @@ function _return_error(client, err, command_obj) {
err.code = match[1];
}

this.emit_drain_idle(queue_len);
client.emit_drain_idle(queue_len);

if (command_obj.callback) {
command_obj.callback(err);
Expand Down
17 changes: 9 additions & 8 deletions lib/failover.js
@@ -1,5 +1,13 @@
'use strict';


function addAuth(auth_pass, toConnection) {
if (toConnection.auth_pass.indexOf(auth_pass) === -1) {
toConnection.auth_pass.push(auth_pass);
}
}


function prepareOptions(client) {
var connections = [ { connectionOption: client.connectionOption, auth_pass: [client.options.auth_pass] } ];

Expand Down Expand Up @@ -44,14 +52,6 @@ function prepareOptions(client) {
return options;
}

function addAuth(auth_pass, toConnection) {
if (toConnection.auth_pass.indexOf(auth_pass) === -1) {
toConnection.auth_pass.push(auth_pass);
} else {
console.error('Same password used more than once');
}
}

function equal(a, b) {
var keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
Expand Down Expand Up @@ -81,6 +81,7 @@ function nextConnection(client) {
function getPasswords(client) {
var fo = client._failover;
var connection = fo.connections[fo.connectionIndex];
addAuth(client.auth_pass, connection);
var passwords = connection.auth_pass;
return passwords.filter(function(p) {return p;});
}
Expand Down

0 comments on commit d50fb59

Please sign in to comment.