From 6a3e96ad2149584e441b0e8a5827dc6c2624035b Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Thu, 25 Aug 2022 12:08:20 -0700 Subject: Maintain backward compatibiliy withour onConnect callback. In f69fac7690fb22a7fc19dba61ef70e5f79ccb2e9, our async onConnect callback was improved to take a non-const redisAsyncContext allowing it to be reentrant. Unfortunately, this is a breaking change we can't make until hiredis v2.0.0. This commit creates a separate callback member and corresponding function that allows us to use the new functionality, while maintaining our existing API for legacy code. Fixes #1086 --- async.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'async.h') diff --git a/async.h b/async.h index 690b31f..4f94660 100644 --- a/async.h +++ b/async.h @@ -57,7 +57,8 @@ typedef struct redisCallbackList { /* Connection callback prototypes */ typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status); -typedef void (redisConnectCallback)(struct redisAsyncContext*, int status); +typedef void (redisConnectCallback)(const struct redisAsyncContext*, int status); +typedef void (redisConnectCallbackNC)(struct redisAsyncContext *, int status); typedef void(redisTimerCallback)(void *timer, void *privdata); /* Context for an async connection to Redis */ @@ -93,6 +94,7 @@ typedef struct redisAsyncContext { /* Called when the first write event was received. */ redisConnectCallback *onConnect; + redisConnectCallbackNC *onConnectNC; /* Regular command callbacks */ redisCallbackList replies; @@ -121,6 +123,7 @@ redisAsyncContext *redisAsyncConnectBindWithReuse(const char *ip, int port, const char *source_addr); redisAsyncContext *redisAsyncConnectUnix(const char *path); int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn); +int redisAsyncSetConnectCallbackNC(redisAsyncContext *ac, redisConnectCallbackNC *fn); int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn); redisAsyncPushFn *redisAsyncSetPushCallback(redisAsyncContext *ac, redisAsyncPushFn *fn); -- cgit v1.2.3