diff --git a/cmd.c b/cmd.c index f8700d0..2a1f0aa 100644 --- a/cmd.c +++ b/cmd.c @@ -35,11 +35,9 @@ cmd_free(struct cmd *c) { free(c); } -struct pubsub_client { - struct server *s; - struct evhttp_request *rq; -}; - +/** + * Detect disconnection of a pub/sub client. We need to clean up the command. + */ void on_http_disconnect(struct evhttp_connection *evcon, void *ctx) { struct pubsub_client *ps = ctx; @@ -139,7 +137,7 @@ cmd_run(struct server *s, struct evhttp_request *rq, evhttp_parse_query(uri, &cmd->uri_params); /* get output formatting function */ - fun = get_formatting_funtion(&cmd->uri_params); + fun = get_formatting_function(&cmd->uri_params); /* there is always a first parameter, it's the command name */ cmd->argv[0] = uri; @@ -194,7 +192,7 @@ cmd_run(struct server *s, struct evhttp_request *rq, formatting_fun -get_formatting_funtion(struct evkeyvalq *params) { +get_formatting_function(struct evkeyvalq *params) { struct evkeyval *kv; diff --git a/cmd.h b/cmd.h index 468d630..a30f339 100644 --- a/cmd.h +++ b/cmd.h @@ -24,6 +24,11 @@ struct cmd { int started_responding; }; +struct pubsub_client { + struct server *s; + struct evhttp_request *rq; +}; + struct cmd * cmd_new(struct evhttp_request *rq, int count); @@ -35,7 +40,7 @@ cmd_run(struct server *s, struct evhttp_request *rq, const char *uri, size_t uri_len); formatting_fun -get_formatting_funtion(struct evkeyvalq *params); +get_formatting_function(struct evkeyvalq *params); int cmd_is_subscribe(struct cmd *cmd); diff --git a/formats/json.c b/formats/json.c index 82abad9..5a63f73 100644 --- a/formats/json.c +++ b/formats/json.c @@ -6,8 +6,6 @@ #include #include -extern int __redisPushCallback(redisCallbackList *list, redisCallback *source); - static json_t * json_wrap_redis_reply(const struct cmd *cmd, const redisReply *r); diff --git a/server.c b/server.c index 273370f..e04d99a 100644 --- a/server.c +++ b/server.c @@ -66,11 +66,6 @@ webdis_connect(struct server *s) { evtimer_add(&s->ev_reconnect, &s->tv_reconnect); } -static void -turnip_connect_now(struct server *s) { - on_timer_reconnect(0, 0, s); -} - struct server * server_copy(const struct server *s) { struct server *ret = calloc(1, sizeof(struct server)); @@ -79,7 +74,7 @@ server_copy(const struct server *s) { /* create a new connection */ ret->ac = NULL; - turnip_connect_now(ret); + on_timer_reconnect(0, 0, ret); return ret; }