summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 255f24f)
raw | patch | inline | side by side (parent: 255f24f)
author | Paul Sadauskas <psadauskas@gmail.com> | |
Mon, 6 Jul 2009 20:02:46 +0000 (14:02 -0600) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 6 Jul 2009 20:39:39 +0000 (22:39 +0200) |
src/tokyotyrant.c | patch | blob | history |
diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c
index 977e11b59dd4e16d69d19386651036a1ea69853f..87001a05eb1107361f1bb95e97fe78cbac7b69b5 100644 (file)
--- a/src/tokyotyrant.c
+++ b/src/tokyotyrant.c
static char *config_host = NULL;
static char *config_port = NULL;
+TCRDB *rdb = NULL;
+
static int tt_config (const char *key, const char *value)
{
if (strcasecmp ("Host", key) == 0)
static int tt_read (void) {
gauge_t rnum, size;
+ rnum = tcrdbrnum(rdb);
+ size = tcrdbsize(rdb);
+ tt_submit (rnum, "records");
+ tt_submit (size, "file_size");
+
+ return (0);
+}
+
+static int tt_init(void)
+{
char* host = NULL;
int port;
host = ((config_host != NULL) ? config_host : DEFAULT_HOST);
port = ((config_port != NULL) ? atoi(config_port) : DEFAULT_PORT);
- TCRDB *rdb = tcrdbnew();
+ rdb = tcrdbnew();
if (!tcrdbopen(rdb, host, port))
{
return (1);
}
- rnum = tcrdbrnum(rdb);
- size = tcrdbsize(rdb);
- tt_submit (rnum, "records");
- tt_submit (size, "file_size");
+ return(0);
+}
+
+static int tt_shutdown(void)
+{
+ sfree(config_host);
+ sfree(config_port);
if (!tcrdbclose(rdb))
{
}
tcrdbdel (rdb);
- return (0);
-}
-
-static int tt_shutdown(void)
-{
- sfree(config_host);
- sfree(config_port);
return(0);
}
plugin_register_config("tokyotyrant", tt_config,
config_keys, config_keys_num);
plugin_register_read("tokyotyrant", tt_read);
+ plugin_register_init("tokyotyrant", tt_init);
plugin_register_shutdown("tokyotyrant", tt_shutdown);
}