summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2011-01-17 10:03:21 +0100
committerPieter Noordhuis <pcnoordhuis@gmail.com>2011-01-17 10:03:21 +0100
commite18b59ae7e1cf8f75614af194616d6c50852f87e (patch)
treee6a62390f5ddd0cf93765ee8725aa30e0a8a7539
parent8ff13537668370b38d0830dc87f8c9e4c12732b7 (diff)
downloadredis-e18b59ae7e1cf8f75614af194616d6c50852f87e.tar.gz
Remove client from list of unblocked clients when it is free'd
-rw-r--r--src/networking.c7
-rw-r--r--src/redis.c1
-rw-r--r--src/redis.h2
-rw-r--r--src/t_list.c3
4 files changed, 12 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index 9716ca319..6145bbb12 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -457,6 +457,13 @@ void freeClient(redisClient *c) {
ln = listSearchKey(server.clients,c);
redisAssert(ln != NULL);
listDelNode(server.clients,ln);
+ /* When client was just unblocked because of a blocking operation,
+ * remove it from the list with unblocked clients. */
+ if (c->flags & REDIS_UNBLOCKED) {
+ ln = listSearchKey(server.unblocked_clients,c);
+ redisAssert(ln != NULL);
+ listDelNode(server.unblocked_clients,ln);
+ }
/* Remove from the list of clients waiting for swapped keys, or ready
* to be restarted, but not yet woken up again. */
if (c->flags & REDIS_IO_WAIT) {
diff --git a/src/redis.c b/src/redis.c
index 2b7935e3a..d928c52b0 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -687,6 +687,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
redisAssert(ln != NULL);
c = ln->value;
listDelNode(server.unblocked_clients,ln);
+ c->flags &= ~REDIS_UNBLOCKED;
/* Process remaining data in the input buffer. */
if (c->querybuf && sdslen(c->querybuf) > 0)
diff --git a/src/redis.h b/src/redis.h
index aa5ed24f9..b833150b4 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -141,6 +141,8 @@
#define REDIS_IO_WAIT 32 /* The client is waiting for Virtual Memory I/O */
#define REDIS_DIRTY_CAS 64 /* Watched keys modified. EXEC will fail. */
#define REDIS_CLOSE_AFTER_REPLY 128 /* Close after writing entire reply. */
+#define REDIS_UNBLOCKED 256 /* This client was unblocked and is stored in
+ server.unblocked_clients */
/* Client request types */
#define REDIS_REQ_INLINE 1
diff --git a/src/t_list.c b/src/t_list.c
index 8ee3b9872..4416d6fd2 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -773,7 +773,8 @@ void unblockClientWaitingData(redisClient *c) {
zfree(c->bpop.keys);
c->bpop.keys = NULL;
c->bpop.target = NULL;
- c->flags &= (~REDIS_BLOCKED);
+ c->flags &= ~REDIS_BLOCKED;
+ c->flags |= REDIS_UNBLOCKED;
server.bpop_blocked_clients--;
listAddNodeTail(server.unblocked_clients,c);
}