Added debug info, trying to find a way to support SUBSCRIBE.

master
Nicolas Favre-Felix 14 years ago
parent 68c9cdb998
commit 794a76db5f

@ -32,6 +32,13 @@ cmd_free(struct cmd *c) {
free(c);
}
void __redisAsyncDisconnect(redisAsyncContext *ac);
void on_http_disconnect(struct evhttp_connection *evcon, void *ctx) {
struct server *s = ctx;
printf("SUBSCRIBE DISCONNECT (ac=%p)\n", (void*)s->ac);
redisAsyncDisconnect(s->ac);
}
void
cmd_run(struct server *s, struct evhttp_request *rq,
const char *uri, size_t uri_len) {
@ -74,6 +81,7 @@ cmd_run(struct server *s, struct evhttp_request *rq,
/* check if we have to split the connection */
if(strncasecmp(cmd->argv[0], "SUBSCRIBE", cmd->argv_len[0]) == 0) {
s = server_copy(s);
evhttp_connection_set_closecb(rq->evcon, on_http_disconnect, s);
}
if(!slash) {

@ -24,6 +24,7 @@ json_reply(redisAsyncContext *c, void *r, void *privdata) {
int free_reply = 1;
if (reply == NULL) {
printf("reply = NULL, BYE.\n");
evhttp_send_reply(cmd->rq, 404, "Not Found", NULL);
return;
}

@ -159,7 +159,7 @@ void redisAsyncDisconnect(redisAsyncContext *ac) {
}
/* Helper function to make the disconnect happen and clean up. */
static void __redisAsyncDisconnect(redisAsyncContext *ac) {
void __redisAsyncDisconnect(redisAsyncContext *ac) {
redisContext *c = &(ac->c);
redisCallback cb;
int status;

@ -13,6 +13,7 @@
#include "conf.h"
#include "cmd.h"
void
on_request(struct evhttp_request *rq, void *ctx) {
@ -20,10 +21,13 @@ on_request(struct evhttp_request *rq, void *ctx) {
struct server *s = ctx;
if(!s->ac) { /* redis is unavailable */
printf("503\n");
evhttp_send_reply(rq, 503, "Service Unavailable", NULL);
return;
}
switch(rq->type) {
case EVHTTP_REQ_GET:
cmd_run(s, rq, 1+uri, strlen(uri)-1);
@ -36,6 +40,7 @@ on_request(struct evhttp_request *rq, void *ctx) {
break;
default:
printf("405\n");
evhttp_send_reply(rq, 405, "Method Not Allowed", NULL);
return;
}

Loading…
Cancel
Save