summaryrefslogtreecommitdiff
path: root/hiredis.c
diff options
context:
space:
mode:
Diffstat (limited to 'hiredis.c')
-rw-r--r--hiredis.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/hiredis.c b/hiredis.c
index fdbbd6d..15bc2a7 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -587,6 +587,21 @@ static redisContext *redisContextInit(redisReplyFunctions *fn) {
}
void redisDisconnect(redisContext *c) {
+ int i;
+ redisCallback cb;
+
+ /* Non-blocking context: call pending callbacks with the NULL reply */
+ if (!(c->flags & REDIS_BLOCK)) {
+ for (i = 0; i < c->cpos; i++) {
+ cb = c->callbacks[i];
+ if (cb.fn != NULL) {
+ cb.fn(c,NULL,cb.privdata);
+ }
+ }
+ /* Reset callback index */
+ c->cpos = 0;
+ }
+
if (c->cbDisconnect.fn != NULL)
c->cbDisconnect.fn(c,c->cbDisconnect.privdata);
close(c->fd);