aboutsummaryrefslogtreecommitdiff
path: root/src/datacache
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-04-29 07:41:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-04-29 07:41:48 +0000
commit5474ff8eae33b31f0d6f9ea0498d5e39432cb28b (patch)
tree47fdad07962c14ae5c1e68c9d400b7bb9c5325fa /src/datacache
parent7581e114280c0c33f375b5d3ba49508b82680755 (diff)
downloadgnunet-5474ff8eae33b31f0d6f9ea0498d5e39432cb28b.tar.gz
gnunet-5474ff8eae33b31f0d6f9ea0498d5e39432cb28b.zip
-add counter for #items
Diffstat (limited to 'src/datacache')
-rw-r--r--src/datacache/plugin_datacache_sqlite.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 8c95381a0..90b33d877 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -58,6 +58,11 @@ struct Plugin
58 * Filename used for the DB. 58 * Filename used for the DB.
59 */ 59 */
60 char *fn; 60 char *fn;
61
62 /**
63 * Number of key-value pairs in the database.
64 */
65 unsigned int num_items;
61}; 66};
62 67
63 68
@@ -95,7 +100,7 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded
95 * @param data data to store 100 * @param data data to store
96 * @param type type of the value 101 * @param type type of the value
97 * @param discard_time when to discard the value in any case 102 * @param discard_time when to discard the value in any case
98 * @param path_info_len number of entries in 'path_info' 103 * @param path_info_len number of entries in @a path_info
99 * @param path_info array of peers that have processed the request 104 * @param path_info array of peers that have processed the request
100 * @return 0 if duplicate, -1 on error, number of bytes used otherwise 105 * @return 0 if duplicate, -1 on error, number of bytes used otherwise
101 */ 106 */
@@ -154,6 +159,7 @@ sqlite_plugin_put (void *cls,
154 sqlite3_finalize (stmt); 159 sqlite3_finalize (stmt);
155 return -1; 160 return -1;
156 } 161 }
162 plugin->num_items++;
157 if (SQLITE_OK != sqlite3_finalize (stmt)) 163 if (SQLITE_OK != sqlite3_finalize (stmt))
158 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 164 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
159 "sqlite3_finalize"); 165 "sqlite3_finalize");
@@ -365,6 +371,7 @@ sqlite_plugin_del (void *cls)
365 (void) sqlite3_finalize (dstmt); 371 (void) sqlite3_finalize (dstmt);
366 return GNUNET_SYSERR; 372 return GNUNET_SYSERR;
367 } 373 }
374 plugin->num_items--;
368 plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD); 375 plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD);
369 if (SQLITE_OK != sqlite3_finalize (dstmt)) 376 if (SQLITE_OK != sqlite3_finalize (dstmt))
370 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 377 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,