Permalink
Browse files

Fixed a bug in stats returned by the 'INFO' command. Misc code cleanu…

…p and organization changes.
  • Loading branch information...
1 parent d709402 commit 8048b1a6d9b0b2bfe5ec92fbf4e0e36e357dee18 @ngerakines committed Mar 8, 2010
Showing with 5 additions and 10 deletions.
  1. +4 −3 src/barbershop.c
  2. +1 −1 src/benchmark.c
  3. +0 −2 src/client.c
  4. +0 −4 src/stats.h
View
7 src/barbershop.c
@@ -35,6 +35,7 @@ THE SOFTWARE.
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
@@ -175,9 +176,9 @@ void on_read(int fd, short ev, void *arg) {
time(&current_time);
sprintf(out, "uptime:%d\r\n", (int)(current_time - app_stats.started_at)); reply(fd, out);
sprintf(out, "version:%s\r\n", app_stats.version); reply(fd, out);
- sprintf(out, "updates:%d\r\n", app_stats.updates); reply(fd, out);
- sprintf(out, "items:%d\r\n", app_stats.items); reply(fd, out);
- sprintf(out, "pools:%d\r\n", app_stats.pools); reply(fd, out);
+ sprintf(out, "updates:%u\r\n", app_stats.updates); reply(fd, out);
+ sprintf(out, "items:%u\r\n", app_stats.items); reply(fd, out);
+ sprintf(out, "pools:%u\r\n", app_stats.pools); reply(fd, out);
} else {
reply(fd, "-ERROR\r\n");
}
View
2 src/benchmark.c
@@ -131,7 +131,7 @@ int main(int argc, char **argv) {
send_command(sd, msg);
n++;
}
- send_command(sd, "stats\r\n");
+ send_command(sd, "INFO\r\n");
close(sd);
View
2 src/client.c
@@ -208,7 +208,6 @@ void send_command(int sd, char *command) {
if (buf_len >= 2) {
resp = malloc(1 + buf_len);
memcpy(resp, buf+1, buf_len);
- resp[buf_len] = 0;
printf("%s\n", resp);
free(resp);
} else {
@@ -217,7 +216,6 @@ void send_command(int sd, char *command) {
break;
default:
printf("%s\n", buf);
- // printf("protocol error, got '%c' as reply type byte\n", buf[0]);
break;
}
}
View
4 src/stats.h
@@ -32,12 +32,8 @@ struct _app_stats {
unsigned int updates;
// Number of items created/inserted into `items`
unsigned int items;
- // Number of items created/inserted into `items` that reflects successful `next` calls
- unsigned int items_gc;
// Number of created pools
unsigned int pools;
- // Number of pools that reflects successful `next` calls that empty pools
- unsigned int pools_gc;
} app_stats;
#endif

0 comments on commit 8048b1a

Please sign in to comment.