You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix bug not allowing you to quit while in subscribe mode - added test
This commit is contained in:
5
index.js
5
index.js
@@ -564,11 +564,10 @@ RedisClient.prototype.send_command = function () {
|
|||||||
}
|
}
|
||||||
this.subscriptions = true;
|
this.subscriptions = true;
|
||||||
} else {
|
} else {
|
||||||
if (this.subscriptions === true) {
|
|
||||||
throw new Error("Connection in pub/sub mode, only pub/sub commands may be used");
|
|
||||||
}
|
|
||||||
if (command === "QUIT") {
|
if (command === "QUIT") {
|
||||||
this.closing = true;
|
this.closing = true;
|
||||||
|
} else if (this.subscriptions === true) {
|
||||||
|
throw new Error("Connection in pub/sub mode, only pub/sub commands may be used");
|
||||||
}
|
}
|
||||||
this.command_queue.push(command_obj);
|
this.command_queue.push(command_obj);
|
||||||
}
|
}
|
||||||
|
8
test.js
8
test.js
@@ -2,6 +2,7 @@
|
|||||||
var redis = require("./index"),
|
var redis = require("./index"),
|
||||||
client = redis.createClient(),
|
client = redis.createClient(),
|
||||||
client2 = redis.createClient(),
|
client2 = redis.createClient(),
|
||||||
|
client3 = redis.createClient(),
|
||||||
assert = require("assert"),
|
assert = require("assert"),
|
||||||
sys = require('sys'),
|
sys = require('sys'),
|
||||||
tests = {}, iterations = 10000;
|
tests = {}, iterations = 10000;
|
||||||
@@ -238,6 +239,13 @@ tests.SUBSCRIBE = function () {
|
|||||||
client1.subscribe("chan1", "chan2");
|
client1.subscribe("chan1", "chan2");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tests.SUBSCRIBE_QUIT = function () {
|
||||||
|
var name = "SUBSCRIBE_QUIT";
|
||||||
|
client3.on("end", function() { next(name) });
|
||||||
|
client3.on("subscribe", function (channel, count) { client3.quit(); });
|
||||||
|
client3.subscribe("chan3");
|
||||||
|
}
|
||||||
|
|
||||||
tests.EXISTS = function () {
|
tests.EXISTS = function () {
|
||||||
var name = "EXISTS";
|
var name = "EXISTS";
|
||||||
client.del("foo", "foo2", require_number_any(name));
|
client.del("foo", "foo2", require_number_any(name));
|
||||||
|
Reference in New Issue
Block a user