Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provides an optional cleanup callback for async data. #768

Merged
merged 1 commit into from Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions async.c
Expand Up @@ -109,6 +109,7 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {
ac->err = 0;
ac->errstr = NULL;
ac->data = NULL;
ac->dataCleanup = NULL;

ac->ev.data = NULL;
ac->ev.addRead = NULL;
Expand Down Expand Up @@ -299,6 +300,10 @@ static void __redisAsyncFree(redisAsyncContext *ac) {
}
}

if (ac->dataCleanup) {
ac->dataCleanup(ac->data);
}

/* Cleanup self */
redisFree(c);
}
Expand Down
1 change: 1 addition & 0 deletions async.h
Expand Up @@ -70,6 +70,7 @@ typedef struct redisAsyncContext {

/* Not used by hiredis */
void *data;
void (*dataCleanup)(void *privdata);

/* Event library data and hooks */
struct {
Expand Down