aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/datacache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datacache/datacache.c')
-rw-r--r--src/datacache/datacache.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index a17eb9628..9d12fbc3e 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -105,8 +105,8 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
105 GNUNET_assert (h->utilization >= size); 105 GNUNET_assert (h->utilization >= size);
106 h->utilization -= size; 106 h->utilization -= size;
107 GNUNET_CONTAINER_bloomfilter_remove (h->filter, key); 107 GNUNET_CONTAINER_bloomfilter_remove (h->filter, key);
108 GNUNET_STATISTICS_update (h->stats, 108 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), -size,
109 gettext_noop ("# bytes stored"), -size, GNUNET_NO); 109 GNUNET_NO);
110} 110}
111 111
112 112
@@ -131,16 +131,16 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
131 GNUNET_CONFIGURATION_get_value_number (cfg, section, "QUOTA", &quota)) 131 GNUNET_CONFIGURATION_get_value_number (cfg, section, "QUOTA", &quota))
132 { 132 {
133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
134 _("No `%s' specified for `%s' in configuration!\n"), 134 _("No `%s' specified for `%s' in configuration!\n"), "QUOTA",
135 "QUOTA", section); 135 section);
136 return NULL; 136 return NULL;
137 } 137 }
138 if (GNUNET_OK != 138 if (GNUNET_OK !=
139 GNUNET_CONFIGURATION_get_value_string (cfg, section, "DATABASE", &name)) 139 GNUNET_CONFIGURATION_get_value_string (cfg, section, "DATABASE", &name))
140 { 140 {
141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
142 _("No `%s' specified for `%s' in configuration!\n"), 142 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE",
143 "DATABASE", section); 143 section);
144 return NULL; 144 return NULL;
145 } 145 }
146 bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */ 146 bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */
@@ -164,8 +164,8 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
164 ret->env.cls = ret; 164 ret->env.cls = ret;
165 ret->env.delete_notify = &env_delete_notify; 165 ret->env.delete_notify = &env_delete_notify;
166 ret->env.quota = quota; 166 ret->env.quota = quota;
167 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 167 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datacache plugin\n"),
168 _("Loading `%s' datacache plugin\n"), name); 168 name);
169 GNUNET_asprintf (&libname, "libgnunet_plugin_datacache_%s", name); 169 GNUNET_asprintf (&libname, "libgnunet_plugin_datacache_%s", name);
170 ret->short_name = name; 170 ret->short_name = name;
171 ret->lib_name = libname; 171 ret->lib_name = libname;
@@ -199,8 +199,8 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
199 if (h->bloom_name != NULL) 199 if (h->bloom_name != NULL)
200 { 200 {
201 if (0 != UNLINK (h->bloom_name)) 201 if (0 != UNLINK (h->bloom_name))
202 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 202 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
203 "unlink", h->bloom_name); 203 h->bloom_name);
204 GNUNET_free (h->bloom_name); 204 GNUNET_free (h->bloom_name);
205 } 205 }
206 GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); 206 GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO);
@@ -221,10 +221,8 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
221 */ 221 */
222int 222int
223GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, 223GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
224 const GNUNET_HashCode * key, 224 const GNUNET_HashCode * key, size_t size,
225 size_t size, 225 const char *data, enum GNUNET_BLOCK_Type type,
226 const char *data,
227 enum GNUNET_BLOCK_Type type,
228 struct GNUNET_TIME_Absolute discard_time) 226 struct GNUNET_TIME_Absolute discard_time)
229{ 227{
230 uint32_t used; 228 uint32_t used;
@@ -235,8 +233,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
235 GNUNET_break (0); 233 GNUNET_break (0);
236 return GNUNET_SYSERR; 234 return GNUNET_SYSERR;
237 } 235 }
238 GNUNET_STATISTICS_update (h->stats, 236 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
239 gettext_noop ("# bytes stored"), size, GNUNET_NO); 237 GNUNET_NO);
240 GNUNET_CONTAINER_bloomfilter_add (h->filter, key); 238 GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
241 while (h->utilization + used > h->env.quota) 239 while (h->utilization + used > h->env.quota)
242 GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); 240 GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls));
@@ -258,12 +256,11 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
258 */ 256 */
259unsigned int 257unsigned int
260GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, 258GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
261 const GNUNET_HashCode * key, 259 const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type,
262 enum GNUNET_BLOCK_Type type,
263 GNUNET_DATACACHE_Iterator iter, void *iter_cls) 260 GNUNET_DATACACHE_Iterator iter, void *iter_cls)
264{ 261{
265 GNUNET_STATISTICS_update (h->stats, 262 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
266 gettext_noop ("# requests received"), 1, GNUNET_NO); 263 GNUNET_NO);
267 if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) 264 if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
268 { 265 {
269 GNUNET_STATISTICS_update (h->stats, 266 GNUNET_STATISTICS_update (h->stats,