mirror of
https://github.com/rspamd/rspamd.git
synced 2024-07-30 08:18:31 +02:00
Revert "[Fix] Fix hiredis stupidity" and use the hiredis api as intended
This reverts commit b05b9bf904
.
This commit is contained in:
parent
192c6b791d
commit
544cea204e
@ -129,7 +129,6 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {
|
||||
|
||||
ac->onConnect = NULL;
|
||||
ac->onDisconnect = NULL;
|
||||
ac->disconnectCbdata = NULL;
|
||||
|
||||
ac->replies.head = NULL;
|
||||
ac->replies.tail = NULL;
|
||||
@ -216,10 +215,9 @@ int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
||||
int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn, void *cbdata) {
|
||||
int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn) {
|
||||
if (ac->onDisconnect == NULL) {
|
||||
ac->onDisconnect = fn;
|
||||
ac->disconnectCbdata = cbdata;
|
||||
return REDIS_OK;
|
||||
}
|
||||
return REDIS_ERR;
|
||||
@ -308,10 +306,10 @@ 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->disconnectCbdata);
|
||||
ac->onDisconnect(ac,REDIS_OK);
|
||||
} else {
|
||||
c->flags |= REDIS_FREEING;
|
||||
ac->onDisconnect(ac,(ac->err == 0) ? REDIS_OK : REDIS_ERR,ac->disconnectCbdata);
|
||||
ac->onDisconnect(ac,(ac->err == 0) ? REDIS_OK : REDIS_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef struct redisCallbackList {
|
||||
} redisCallbackList;
|
||||
|
||||
/* Connection callback prototypes */
|
||||
typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status, void *cbdata);
|
||||
typedef void (redisDisconnectCallback)(const struct redisAsyncContext*, int status);
|
||||
typedef void (redisConnectCallback)(const struct redisAsyncContext*, int status);
|
||||
|
||||
/* Context for an async connection to Redis */
|
||||
@ -85,8 +85,6 @@ 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;
|
||||
@ -109,7 +107,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, void *cbdata);
|
||||
int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn);
|
||||
void redisAsyncDisconnect(redisAsyncContext *ac);
|
||||
void redisAsyncFree(redisAsyncContext *ac);
|
||||
|
||||
|
@ -258,10 +258,9 @@ rspamd_redis_pool_schedule_timeout (struct rspamd_redis_pool_connection *conn)
|
||||
}
|
||||
|
||||
static void
|
||||
rspamd_redis_pool_on_disconnect (const struct redisAsyncContext *ac, int status,
|
||||
void *ud)
|
||||
rspamd_redis_pool_on_disconnect (const struct redisAsyncContext *ac, int status)
|
||||
{
|
||||
struct rspamd_redis_pool_connection *conn = ud;
|
||||
struct rspamd_redis_pool_connection *conn = ac->data;
|
||||
|
||||
/*
|
||||
* Here, we know that redis itself will free this connection
|
||||
@ -313,13 +312,13 @@ rspamd_redis_pool_new_connection (struct rspamd_redis_pool *pool,
|
||||
g_hash_table_insert (elt->pool->elts_by_ctx, ctx, conn);
|
||||
g_queue_push_head_link (elt->active, conn->entry);
|
||||
conn->ctx = ctx;
|
||||
ctx->data = conn;
|
||||
rspamd_random_hex (conn->tag, sizeof (conn->tag));
|
||||
REF_INIT_RETAIN (conn, rspamd_redis_pool_conn_dtor);
|
||||
msg_debug_rpool ("created new connection to %s:%d: %p", ip, port, ctx);
|
||||
|
||||
redisLibevAttach (pool->event_loop, ctx);
|
||||
redisAsyncSetDisconnectCallback (ctx, rspamd_redis_pool_on_disconnect,
|
||||
conn);
|
||||
redisAsyncSetDisconnectCallback (ctx, rspamd_redis_pool_on_disconnect);
|
||||
|
||||
if (password) {
|
||||
redisAsyncCommand (ctx, NULL, NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user