Skip to content

Commit

Permalink
Remove client from list of unblocked clients when it is free'd
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Jan 17, 2011
1 parent 8ff1353 commit e18b59a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/networking.c
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/redis.c
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/redis.h
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/t_list.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit e18b59a

Please sign in to comment.