diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-04-29 07:41:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-04-29 07:41:48 +0000 |
commit | 5474ff8eae33b31f0d6f9ea0498d5e39432cb28b (patch) | |
tree | 47fdad07962c14ae5c1e68c9d400b7bb9c5325fa /src/datacache | |
parent | 7581e114280c0c33f375b5d3ba49508b82680755 (diff) |
-add counter for #items
Diffstat (limited to 'src/datacache')
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 8c95381a0a..90b33d8779 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) + Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -58,6 +58,11 @@ struct Plugin * Filename used for the DB. */ char *fn; + + /** + * Number of key-value pairs in the database. + */ + unsigned int num_items; }; @@ -95,7 +100,7 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded * @param data data to store * @param type type of the value * @param discard_time when to discard the value in any case - * @param path_info_len number of entries in 'path_info' + * @param path_info_len number of entries in @a path_info * @param path_info array of peers that have processed the request * @return 0 if duplicate, -1 on error, number of bytes used otherwise */ @@ -154,6 +159,7 @@ sqlite_plugin_put (void *cls, sqlite3_finalize (stmt); return -1; } + plugin->num_items++; if (SQLITE_OK != sqlite3_finalize (stmt)) LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_finalize"); @@ -365,6 +371,7 @@ sqlite_plugin_del (void *cls) (void) sqlite3_finalize (dstmt); return GNUNET_SYSERR; } + plugin->num_items--; plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD); if (SQLITE_OK != sqlite3_finalize (dstmt)) LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |