summaryrefslogtreecommitdiff
path: root/async.c
diff options
context:
space:
mode:
authorMark Nunberg <mnunberg@haskalah.org>2019-02-21 11:49:25 -0500
committerMark Nunberg <mnunberg@haskalah.org>2019-02-21 11:49:25 -0500
commit5eb6958870b71d30e3ed63e65e9f1d546dc419ec (patch)
treee2ac8ce65fa180fd28c1177089e450e3554ea868 /async.c
parent1ec4aefba6d3690c461ea870eab0984a2cb597f0 (diff)
Allow option for async connections to not automatically free
Diffstat (limited to 'async.c')
-rw-r--r--async.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/async.c b/async.c
index 0ed973e..0a2659c 100644
--- a/async.c
+++ b/async.c
@@ -361,7 +361,9 @@ static void __redisAsyncDisconnect(redisAsyncContext *ac) {
/* For non-clean disconnects, __redisAsyncFree() will execute pending
* callbacks with a NULL-reply. */
- __redisAsyncFree(ac);
+ if (!(c->flags & REDIS_NO_AUTO_FREE)) {
+ __redisAsyncFree(ac);
+ }
}
/* Tries to do a clean disconnect from Redis, meaning it stops new commands
@@ -373,6 +375,9 @@ static void __redisAsyncDisconnect(redisAsyncContext *ac) {
void redisAsyncDisconnect(redisAsyncContext *ac) {
redisContext *c = &(ac->c);
c->flags |= REDIS_DISCONNECTING;
+
+ /** unset the auto-free flag here, because disconnect undoes this */
+ c->flags &= ~REDIS_NO_AUTO_FREE;
if (!(c->flags & REDIS_IN_CALLBACK) && ac->replies.head == NULL)
__redisAsyncDisconnect(ac);
}