Free Redis context for custom connections

GitHub issue #72
master
Nicolas Favre-Felix 12 years ago
parent 34bb0b8090
commit f616c2992a

@ -6,6 +6,7 @@
#include "worker.h"
#include "http.h"
#include "server.h"
#include "slog.h"
#include "formats/json.h"
#include "formats/raw.h"
@ -51,6 +52,11 @@ cmd_free(struct cmd *c) {
free(c->if_none_match);
if(c->mime_free) free(c->mime);
if (c->ac && /* we have a connection */
(c->database != c->w->s->cfg->database /* custom DB */
|| cmd_is_subscribe(c))) {
pool_free_context(c->ac);
}
free(c);
}

@ -22,6 +22,15 @@ pool_new(struct worker *w, int count) {
return p;
}
void
pool_free_context(redisAsyncContext *ac) {
if (ac) {
redisAsyncDisconnect(ac);
redisAsyncFree(ac);
}
}
static void
pool_on_connect(const redisAsyncContext *ac, int status) {
struct pool *p = ac->data;

@ -21,6 +21,9 @@ struct pool {
struct pool *
pool_new(struct worker *w, int count);
void
pool_free_context(redisAsyncContext *ac);
redisAsyncContext *
pool_connect(struct pool *p, int db_num, int attach);

Loading…
Cancel
Save