Handle broken subscribe connections.

master
Nicolas Favre-Felix 14 years ago
parent 351f83b83b
commit bd9f72399f

15
cmd.c

@ -46,14 +46,13 @@ void on_http_disconnect(struct evhttp_connection *evcon, void *ctx) {
(void)evcon;
if(ps->s->ac->replies.head) {
struct cmd *cmd = ps->s->ac->replies.head->privdata;
if(cmd) {
cmd_free(cmd);
}
ps->s->ac->replies.head->privdata = NULL;
}
/* clean up redis object */
redisAsyncFree(ps->s->ac);
/* clean up command object */
if(ps->cmd) {
cmd_free(ps->cmd);
}
free(ps);
}
@ -144,8 +143,8 @@ cmd_run(struct server *s, struct evhttp_request *rq,
ps = calloc(1, sizeof(struct pubsub_client));
ps->s = s = server_copy(s);
ps->cmd = cmd;
ps->rq = rq;
evhttp_connection_set_closecb(rq->evcon, on_http_disconnect, ps);
}

@ -33,6 +33,7 @@ struct cmd {
struct pubsub_client {
struct server *s;
struct cmd *cmd;
struct evhttp_request *rq;
};

Loading…
Cancel
Save