Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
Trying to fix new stats command.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfolkman committed Aug 25, 2009
1 parent 9eca153 commit b1d1329
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pubsub/pubsub.c
Expand Up @@ -14,9 +14,9 @@ typedef struct cli {
} cli;
TAILQ_HEAD(, cli) clients;

void argtoi(struct evkeyvalq *args, char *key, int *val, int def);
void finalize_json(struct evhttp_request *req, struct evbuffer *evb,
struct evkeyvalq *args, struct json_object *jsobj);
void argtoi(struct evkeyvalq *args, char *key, int *val, int def);

uint32_t totalConns = 0;
uint32_t currentConns = 0;
Expand Down Expand Up @@ -56,30 +56,30 @@ void
stats(struct evhttp_request *req, struct evbuffer *evb, void *ctx)
{
struct evkeyvalq args;
struct json_object *jsobj;
int reset;
struct json_object *jsobj;
int reset;
char *uri, *queue, *total_gets, *total_puts, *total;
char kbuf[BUFSZ];

uri = evhttp_decode_uri(req->uri);
evhttp_parse_query(uri, &args);
free(uri);

argtoi(&args, "reset", &reset, 0);
jsobj = json_object_new_object();
json_object_object_add(jsobj, "totalConnections", json_object_new_int(totalConns));
json_object_object_add(jsobj, "currentConnections", json_object_new_int(currentConns));
json_object_object_add(jsobj, "messagesReceived", json_object_new_int(msgRecv));
json_object_object_add(jsobj, "messagesSent", json_object_new_int(msgSent));
if (reset) {
argtoi(&args, "reset", &reset, 0);
jsobj = json_object_new_object();
json_object_object_add(jsobj, "totalConnections", json_object_new_int(totalConns));
json_object_object_add(jsobj, "currentConnections", json_object_new_int(currentConns));
json_object_object_add(jsobj, "messagesReceived", json_object_new_int(msgRecv));
json_object_object_add(jsobj, "messagesSent", json_object_new_int(msgSent));

if (reset) {
totalConns = 0;
currentConns = 0;
msgRecv = 0;
msgSent = 0;
}

finalize_json(req, evb, &args, jsobj);
finalize_json(req, evb, &args, jsobj);
}

void on_close(struct evhttp_connection *evcon, void *ctx)
Expand Down

0 comments on commit b1d1329

Please sign in to comment.