diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-05-25 15:28:54 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-05-29 09:52:18 -0700 |
commit | 1c29aafd4701b92cd743a1635af640f1f3330689 (patch) | |
tree | db583d240fc66ad8583bf9ef0b12716ef8da095e /async.c | |
parent | 63dcf9b741b5b1f7eebbcefab47b755a3fc0a9e2 (diff) |
Clarify rationale behind issue #43
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -361,17 +361,20 @@ 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) { - // error reply before any callbacks were setup + /* 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 ) { c->err = REDIS_ERR_OTHER; - err_len = strlen(((redisReply*)reply)->str); - err_len = err_len < (sizeof(c->errstr)-1) ? err_len : (sizeof(c->errstr)-1); - memcpy(c->errstr, ((redisReply*)reply)->str, err_len); - c->errstr[err_len] = '\0'; + snprintf(c->errstr,sizeof(c->errstr),"%s",((redisReply*)reply)->str); __redisAsyncDisconnect(ac); return; } - /* No more regular callbacks and no errors, the context *must* be subscribed. */ + /* No more regular callbacks and no errors, the context *must* be subscribed. */ assert(c->flags & REDIS_SUBSCRIBED); __redisGetSubscribeCallback(ac,reply,&cb); } |