diff options
author | Alex Leverington <nessence@gmail.com> | 2012-07-11 02:53:58 -0500 |
---|---|---|
committer | Alex Leverington <nessence@gmail.com> | 2012-07-11 02:53:58 -0500 |
commit | 01cce89d9d6d6d91c464fa8d755899a7d5322c86 (patch) | |
tree | 4bab4ec31ed33cb0e2a312a9a7e40c1f9a82edbe /async.c | |
parent | f8debbfdbebb97f5d0ee2218edf1425ac219cff5 (diff) |
async: support for determining monitor mode, if so, repush replies callback in expectation of another reply.
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -372,6 +372,11 @@ void redisProcessCallbacks(redisAsyncContext *ac) { __redisAsyncDisconnect(ac); return; } + + /* If monitor mode, repush callback */ + if(c->flags & REDIS_MONITORING) { + __redisPushCallback(&ac->replies,&cb); + } /* When the connection is not being disconnected, simply stop * trying to get replies and wait for the next loop tick. */ @@ -394,9 +399,10 @@ void redisProcessCallbacks(redisAsyncContext *ac) { __redisAsyncDisconnect(ac); return; } - /* No more regular callbacks and no errors, the context *must* be subscribed. */ - assert(c->flags & REDIS_SUBSCRIBED); - __redisGetSubscribeCallback(ac,reply,&cb); + /* No more regular callbacks and no errors, the context *must* be subscribed or monitoring. */ + assert((c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING)); + if(c->flags & REDIS_SUBSCRIBED) + __redisGetSubscribeCallback(ac,reply,&cb); } if (cb.fn != NULL) { @@ -557,6 +563,10 @@ static int __redisAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void /* (P)UNSUBSCRIBE does not have its own response: every channel or * pattern that is unsubscribed will receive a message. This means we * should not append a callback function for this command. */ + } else if(strncasecmp(cstr,"monitor\r\n",9) == 0) { + /* Set monitor flag and push callback */ + c->flags |= REDIS_MONITORING; + __redisPushCallback(&ac->replies,&cb); } else { if (c->flags & REDIS_SUBSCRIBED) /* This will likely result in an error reply, but it needs to be |