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

Fix multi not being executed on node 0.10 if not yet ready. Closes #889

This commit is contained in:
Ruben Bridgewater
2015-10-14 02:24:11 +02:00
parent a408235a38
commit 0d4d4d7416
3 changed files with 40 additions and 8 deletions

View File

@@ -38,9 +38,13 @@ function RedisClient(stream, options) {
this.pipeline = 0;
if (!stream.cork) {
stream.cork = function noop() {
self.pipeline_queue = new Queue();
};
this.cork = function noop (len) {};
this.once('ready', function () {
self.cork = function (len) {
self.pipeline = len;
self.pipeline_queue = new Queue(len);
};
});
stream.uncork = function noop() {};
this.write = this.writeStream;
}
@@ -128,6 +132,10 @@ RedisClient.prototype.install_stream_listeners = function() {
});
};
RedisClient.prototype.cork = function (len) {
this.stream.cork();
};
RedisClient.prototype.initialize_retry_vars = function () {
this.retry_timer = null;
this.retry_totaltime = 0;
@@ -1074,8 +1082,7 @@ Multi.prototype.exec_transaction = function (callback) {
var cb;
this.errors = [];
this.callback = callback;
this._client.stream.cork();
this._client.pipeline = len + 2;
this._client.cork(len + 2);
this.wants_buffers = new Array(len);
this.send_command('multi', []);
// drain queue, callback will catch 'QUEUED' or error
@@ -1192,8 +1199,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct
return true;
}
this.results = new Array(len);
this._client.stream.cork();
this._client.pipeline = len;
this._client.cork(len);
var lastCallback = function (cb) {
return function (err, res) {
cb(err, res);