diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2012-07-31 17:40:46 -0700 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2012-07-31 17:40:46 -0700 |
commit | 7ec4df9403e8c5be413693f5984edb8123cc72d5 (patch) | |
tree | 62f4a333bfe73afc64c7f6b54b1408b9844acedb /async.c | |
parent | f2ddeeae9553e7737f7fe371439f95cbd0fca292 (diff) |
Spontaneous error reply can always happen
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -386,14 +386,22 @@ void redisProcessCallbacks(redisAsyncContext *ac) { /* Even if the context is subscribed, pending regular callbacks will * get a reply before pub/sub messages arrive. */ if (__redisShiftCallback(&ac->replies,&cb) != REDIS_OK) { - /* A spontaneous reply in a not-subscribed context can only be the - * error reply that is sent when a new connection exceeds the - * maximum number of allowed connections on the server side. This - * is seen as an error instead of a regular reply because the - * server closes the connection after sending it. To prevent the - * error from being overwritten by an EOF error the connection is - * closed here. See issue #43. */ - if ( !(c->flags & REDIS_SUBSCRIBED) && ((redisReply*)reply)->type == REDIS_REPLY_ERROR ) { + /* + * A spontaneous reply in a not-subscribed context can be the error + * reply that is sent when a new connection exceeds the maximum + * number of allowed connections on the server side. + * + * This is seen as an error instead of a regular reply because the + * server closes the connection after sending it. + * + * To prevent the error from being overwritten by an EOF error the + * connection is closed here. See issue #43. + * + * Another possibility is that the server is loading its dataset. + * In this case we also want to close the connection, and have the + * user wait until the server is ready to take our request. + */ + if (((redisReply*)reply)->type == REDIS_REPLY_ERROR) { c->err = REDIS_ERR_OTHER; snprintf(c->errstr,sizeof(c->errstr),"%s",((redisReply*)reply)->str); __redisAsyncDisconnect(ac); |