Permalink
Browse files

Trying to fix new stats command.

  • Loading branch information...
1 parent 9eca153 commit b1d1329cce670148d1f5690094c29d011801949e @nathanfolkman nathanfolkman committed Aug 25, 2009
Showing with 12 additions and 12 deletions.
  1. +12 −12 pubsub/pubsub.c
View
@@ -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;
@@ -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)

0 comments on commit b1d1329

Please sign in to comment.