aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/hiredis
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-08 15:25:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-08 15:25:12 +0100
commitb05b9bf904edce75c17e63982d5e0a82dd3e9064 (patch)
tree517c034b22cb5863c488422687de88847e492571 /contrib/hiredis
parent2996fbba0a369032f96c0d6689ae2b6b623065d4 (diff)
downloadrspamd-b05b9bf904edce75c17e63982d5e0a82dd3e9064.tar.gz
rspamd-b05b9bf904edce75c17e63982d5e0a82dd3e9064.zip
[Fix] Fix hiredis stupidity
Diffstat (limited to 'contrib/hiredis')
-rw-r--r--contrib/hiredis/async.c8
-rw-r--r--contrib/hiredis/async.h6
2 files changed, 9 insertions, 5 deletions
diff --git a/contrib/hiredis/async.c b/contrib/hiredis/async.c
index d955203f8..84c43585c 100644
--- a/contrib/hiredis/async.c
+++ b/contrib/hiredis/async.c
@@ -129,6 +129,7 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {
ac->onConnect = NULL;
ac->onDisconnect = NULL;
+ ac->disconnectCbdata = NULL;
ac->replies.head = NULL;
ac->replies.tail = NULL;
@@ -215,9 +216,10 @@ int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn
return REDIS_ERR;
}
-int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn) {
+int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn, void *cbdata) {
if (ac->onDisconnect == NULL) {
ac->onDisconnect = fn;
+ ac->disconnectCbdata = cbdata;
return REDIS_OK;
}
return REDIS_ERR;
@@ -306,9 +308,9 @@ static void __redisAsyncFree(redisAsyncContext *ac) {
* this context, the status will always be REDIS_OK. */
if (ac->onDisconnect && (c->flags & REDIS_CONNECTED)) {
if (c->flags & REDIS_FREEING) {
- ac->onDisconnect(ac,REDIS_OK);
+ ac->onDisconnect(ac,REDIS_OK,ac->disconnectCbdata);
} else {
- ac->onDisconnect(ac,(ac->err == 0) ? REDIS_OK : REDIS_ERR);
+ ac->onDisconnect(ac,(ac->err == 0) ? REDIS_OK : REDIS_ERR,ac->disconnectCbdata);
}
}
diff --git a/contrib/hiredis/async.h b/contrib/hiredis/async.h
index 59cbf469b..3d20241c6 100644
--- a/contrib/hiredis/async.h
+++ b/contrib/hiredis/async.h
@@ -54,7 +54,7 @@ typedef struct redisCallbackList {
} redisCallbackList;
/* Connection callback prototypes */
-typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status);
+typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status, void *cbdata);
typedef void (redisConnectCallback)(const struct redisAsyncContext*, int status);
/* Context for an async connection to Redis */
@@ -85,6 +85,8 @@ typedef struct redisAsyncContext {
/* Called when either the connection is terminated due to an error or per
* user request. The status is set accordingly (REDIS_OK, REDIS_ERR). */
redisDisconnectCallback *onDisconnect;
+ /* Hiredis is just brain-damaged here, need to fix it */
+ void *disconnectCbdata;
/* Called when the first write event was received. */
redisConnectCallback *onConnect;
@@ -107,7 +109,7 @@ redisAsyncContext *redisAsyncConnectBindWithReuse(const char *ip, int port,
const char *source_addr);
redisAsyncContext *redisAsyncConnectUnix(const char *path);
int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn);
-int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn);
+int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn, void *cbdata);
void redisAsyncDisconnect(redisAsyncContext *ac);
void redisAsyncFree(redisAsyncContext *ac);