diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-06 21:16:46 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-06 21:16:46 +0200 |
commit | c51a44aa2181e66ff4d529ba89c1177b0abc37de (patch) | |
tree | fb2a7c4d3c5fc6d1e96e63ba14f5d42da9adcf35 /src | |
parent | 99cddd6954061f16571adb90fcf9f5dddf159f4e (diff) | |
download | gnunet-c51a44aa2181e66ff4d529ba89c1177b0abc37de.tar.gz gnunet-c51a44aa2181e66ff4d529ba89c1177b0abc37de.zip |
fix datacache bytes stored calculation
Diffstat (limited to 'src')
-rw-r--r-- | src/datacache/datacache.c | 40 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 3 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index 92cc40b53..0646019bd 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -170,10 +170,14 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
170 | ret = GNUNET_new (struct GNUNET_DATACACHE_Handle); | 170 | ret = GNUNET_new (struct GNUNET_DATACACHE_Handle); |
171 | 171 | ||
172 | if (GNUNET_YES != | 172 | if (GNUNET_YES != |
173 | GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF")) | 173 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
174 | section, | ||
175 | "DISABLE_BF")) | ||
174 | { | 176 | { |
175 | if (GNUNET_YES != | 177 | if (GNUNET_YES != |
176 | GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF_RC")) | 178 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
179 | section, | ||
180 | "DISABLE_BF_RC")) | ||
177 | { | 181 | { |
178 | ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom"); | 182 | ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom"); |
179 | } | 183 | } |
@@ -230,7 +234,9 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | |||
230 | if (NULL != h->filter) | 234 | if (NULL != h->filter) |
231 | GNUNET_CONTAINER_bloomfilter_free (h->filter); | 235 | GNUNET_CONTAINER_bloomfilter_free (h->filter); |
232 | if (NULL != h->api) | 236 | if (NULL != h->api) |
233 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api)); | 237 | GNUNET_break (NULL == |
238 | GNUNET_PLUGIN_unload (h->lib_name, | ||
239 | h->api)); | ||
234 | GNUNET_free (h->lib_name); | 240 | GNUNET_free (h->lib_name); |
235 | GNUNET_free (h->short_name); | 241 | GNUNET_free (h->short_name); |
236 | GNUNET_free (h->section); | 242 | GNUNET_free (h->section); |
@@ -243,7 +249,8 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | |||
243 | h->bloom_name); | 249 | h->bloom_name); |
244 | GNUNET_free (h->bloom_name); | 250 | GNUNET_free (h->bloom_name); |
245 | } | 251 | } |
246 | GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); | 252 | GNUNET_STATISTICS_destroy (h->stats, |
253 | GNUNET_NO); | ||
247 | GNUNET_free (h); | 254 | GNUNET_free (h); |
248 | } | 255 | } |
249 | 256 | ||
@@ -273,10 +280,14 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
273 | { | 280 | { |
274 | ssize_t used; | 281 | ssize_t used; |
275 | 282 | ||
276 | used = h->api->put (h->api->cls, key, | 283 | used = h->api->put (h->api->cls, |
277 | data_size, data, | 284 | key, |
278 | type, discard_time, | 285 | data_size, |
279 | path_info_len, path_info); | 286 | data, |
287 | type, | ||
288 | discard_time, | ||
289 | path_info_len, | ||
290 | path_info); | ||
280 | if (-1 == used) | 291 | if (-1 == used) |
281 | { | 292 | { |
282 | GNUNET_break (0); | 293 | GNUNET_break (0); |
@@ -290,16 +301,17 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
290 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 301 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
291 | "Stored data under key `%s' in cache\n", | 302 | "Stored data under key `%s' in cache\n", |
292 | GNUNET_h2s (key)); | 303 | GNUNET_h2s (key)); |
304 | if (NULL != h->filter) | ||
305 | GNUNET_CONTAINER_bloomfilter_add (h->filter, | ||
306 | key); | ||
293 | GNUNET_STATISTICS_update (h->stats, | 307 | GNUNET_STATISTICS_update (h->stats, |
294 | gettext_noop ("# bytes stored"), | 308 | gettext_noop ("# bytes stored"), |
295 | data_size, | 309 | used, |
296 | GNUNET_NO); | 310 | GNUNET_NO); |
297 | GNUNET_STATISTICS_update (h->stats, | 311 | GNUNET_STATISTICS_update (h->stats, |
298 | gettext_noop ("# items stored"), | 312 | gettext_noop ("# items stored"), |
299 | 1, | 313 | 1, |
300 | GNUNET_NO); | 314 | GNUNET_NO); |
301 | if (NULL != h->filter) | ||
302 | GNUNET_CONTAINER_bloomfilter_add (h->filter, key); | ||
303 | while (h->utilization + used > h->env.quota) | 315 | while (h->utilization + used > h->env.quota) |
304 | GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); | 316 | GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); |
305 | h->utilization += used; | 317 | h->utilization += used; |
@@ -345,8 +357,10 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | |||
345 | return 0; /* can not be present */ | 357 | return 0; /* can not be present */ |
346 | } | 358 | } |
347 | return h->api->get (h->api->cls, | 359 | return h->api->get (h->api->cls, |
348 | key, type, | 360 | key, |
349 | iter, iter_cls); | 361 | type, |
362 | iter, | ||
363 | iter_cls); | ||
350 | } | 364 | } |
351 | 365 | ||
352 | 366 | ||
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index dd79d0125..15438b29b 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -138,7 +138,8 @@ sq_prepare (sqlite3 *dbh, | |||
138 | char *dummy; | 138 | char *dummy; |
139 | 139 | ||
140 | return sqlite3_prepare (dbh, | 140 | return sqlite3_prepare (dbh, |
141 | zSql, strlen (zSql), | 141 | zSql, |
142 | strlen (zSql), | ||
142 | ppStmt, | 143 | ppStmt, |
143 | (const char **) &dummy); | 144 | (const char **) &dummy); |
144 | } | 145 | } |