aboutsummaryrefslogtreecommitdiff
path: root/src/datacache
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/datacache
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
downloadgnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz
gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/datacache')
-rw-r--r--src/datacache/datacache.c9
-rw-r--r--src/datacache/plugin_datacache_mysql.c1
-rw-r--r--src/datacache/plugin_datacache_postgres.c44
-rw-r--r--src/datacache/plugin_datacache_sqlite.c20
4 files changed, 17 insertions, 57 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 936031b91..b440af1b2 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -29,7 +29,6 @@
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_datacache_plugin.h" 30#include "gnunet_datacache_plugin.h"
31 31
32#define DEBUG_DATACACHE GNUNET_EXTRA_LOGGING
33 32
34#define LOG(kind,...) GNUNET_log_from (kind, "datacache", __VA_ARGS__) 33#define LOG(kind,...) GNUNET_log_from (kind, "datacache", __VA_ARGS__)
35 34
@@ -108,10 +107,8 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
108{ 107{
109 struct GNUNET_DATACACHE_Handle *h = cls; 108 struct GNUNET_DATACACHE_Handle *h = cls;
110 109
111#if DEBUG_DATACACHE
112 LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n", 110 LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n",
113 GNUNET_h2s (key)); 111 GNUNET_h2s (key));
114#endif
115 GNUNET_assert (h->utilization >= size); 112 GNUNET_assert (h->utilization >= size);
116 h->utilization -= size; 113 h->utilization -= size;
117 GNUNET_CONTAINER_bloomfilter_remove (h->filter, key); 114 GNUNET_CONTAINER_bloomfilter_remove (h->filter, key);
@@ -248,10 +245,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
248 GNUNET_break (0); 245 GNUNET_break (0);
249 return GNUNET_SYSERR; 246 return GNUNET_SYSERR;
250 } 247 }
251#if DEBUG_DATACACHE
252 LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n", 248 LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
253 GNUNET_h2s (key)); 249 GNUNET_h2s (key));
254#endif
255 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size, 250 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
256 GNUNET_NO); 251 GNUNET_NO);
257 GNUNET_CONTAINER_bloomfilter_add (h->filter, key); 252 GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
@@ -280,20 +275,16 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
280{ 275{
281 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1, 276 GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
282 GNUNET_NO); 277 GNUNET_NO);
283#if DEBUG_DATACACHE
284 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n", 278 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n",
285 GNUNET_h2s (key)); 279 GNUNET_h2s (key));
286#endif
287 if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) 280 if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
288 { 281 {
289 GNUNET_STATISTICS_update (h->stats, 282 GNUNET_STATISTICS_update (h->stats,
290 gettext_noop 283 gettext_noop
291 ("# requests filtered by bloom filter"), 1, 284 ("# requests filtered by bloom filter"), 1,
292 GNUNET_NO); 285 GNUNET_NO);
293#if DEBUG_DATACACHE
294 LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n", 286 LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n",
295 GNUNET_h2s (key)); 287 GNUNET_h2s (key));
296#endif
297 return 0; /* can not be present */ 288 return 0; /* can not be present */
298 } 289 }
299 return h->api->get (h->api->cls, key, type, iter, iter_cls); 290 return h->api->get (h->api->cls, key, type, iter, iter_cls);
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c
index d618e07b8..810342908 100644
--- a/src/datacache/plugin_datacache_mysql.c
+++ b/src/datacache/plugin_datacache_mysql.c
@@ -83,7 +83,6 @@
83#include "gnunet_mysql_lib.h" 83#include "gnunet_mysql_lib.h"
84#include <mysql/mysql.h> 84#include <mysql/mysql.h>
85 85
86#define DEBUG_DATACACHE_MYSQL GNUNET_EXTRA_LOGGING
87 86
88/** 87/**
89 * Estimate of the per-entry overhead (including indices). 88 * Estimate of the per-entry overhead (including indices).
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index cd4286b92..b40f1fd04 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -29,7 +29,7 @@
29#include "gnunet_datacache_plugin.h" 29#include "gnunet_datacache_plugin.h"
30#include <postgresql/libpq-fe.h> 30#include <postgresql/libpq-fe.h>
31 31
32#define DEBUG_POSTGRES GNUNET_EXTRA_LOGGING 32#define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__)
33 33
34/** 34/**
35 * Per-entry overhead estimate 35 * Per-entry overhead estimate
@@ -236,20 +236,16 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
236 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", 236 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared",
237 (type == 0) ? "getk" : "getkt")) 237 (type == 0) ? "getk" : "getkt"))
238 { 238 {
239#if DEBUG_POSTGRES 239 LOG (GNUNET_ERROR_TYPE_DEBUG,
240 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 240 "Ending iteration (postgres error)\n");
241 "Ending iteration (postgres error)\n");
242#endif
243 return 0; 241 return 0;
244 } 242 }
245 243
246 if (0 == (cnt = PQntuples (res))) 244 if (0 == (cnt = PQntuples (res)))
247 { 245 {
248 /* no result */ 246 /* no result */
249#if DEBUG_POSTGRES 247 LOG (GNUNET_ERROR_TYPE_DEBUG,
250 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 248 "Ending iteration (no more results)\n");
251 "Ending iteration (no more results)\n");
252#endif
253 PQclear (res); 249 PQclear (res);
254 return 0; 250 return 0;
255 } 251 }
@@ -271,19 +267,15 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
271 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0)); 267 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0));
272 type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1)); 268 type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1));
273 size = PQgetlength (res, i, 2); 269 size = PQgetlength (res, i, 2);
274#if DEBUG_POSTGRES 270 LOG (GNUNET_ERROR_TYPE_DEBUG,
275 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 271 "Found result of size %u bytes and type %u in database\n",
276 "Found result of size %u bytes and type %u in database\n", 272 (unsigned int) size, (unsigned int) type);
277 (unsigned int) size, (unsigned int) type);
278#endif
279 if (GNUNET_SYSERR == 273 if (GNUNET_SYSERR ==
280 iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2), 274 iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2),
281 (enum GNUNET_BLOCK_Type) type)) 275 (enum GNUNET_BLOCK_Type) type))
282 { 276 {
283#if DEBUG_POSTGRES 277 LOG (GNUNET_ERROR_TYPE_DEBUG,
284 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 278 "Ending iteration (client error)\n");
285 "Ending iteration (client error)\n");
286#endif
287 PQclear (res); 279 PQclear (res);
288 return cnt; 280 return cnt;
289 } 281 }
@@ -313,19 +305,15 @@ postgres_plugin_del (void *cls)
313 if (GNUNET_OK != 305 if (GNUNET_OK !=
314 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm")) 306 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm"))
315 { 307 {
316#if DEBUG_POSTGRES 308 LOG (GNUNET_ERROR_TYPE_DEBUG,
317 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 309 "Ending iteration (postgres error)\n");
318 "Ending iteration (postgres error)\n");
319#endif
320 return 0; 310 return 0;
321 } 311 }
322 if (0 == PQntuples (res)) 312 if (0 == PQntuples (res))
323 { 313 {
324 /* no result */ 314 /* no result */
325#if DEBUG_POSTGRES 315 LOG (GNUNET_ERROR_TYPE_DEBUG,
326 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 316 "Ending iteration (no more results)\n");
327 "Ending iteration (no more results)\n");
328#endif
329 PQclear (res); 317 PQclear (res);
330 return GNUNET_SYSERR; 318 return GNUNET_SYSERR;
331 } 319 }
@@ -375,8 +363,8 @@ libgnunet_plugin_datacache_postgres_init (void *cls)
375 api->get = &postgres_plugin_get; 363 api->get = &postgres_plugin_get;
376 api->put = &postgres_plugin_put; 364 api->put = &postgres_plugin_put;
377 api->del = &postgres_plugin_del; 365 api->del = &postgres_plugin_del;
378 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datacache-postgres", 366 LOG (GNUNET_ERROR_TYPE_INFO,
379 _("Postgres datacache running\n")); 367 _("Postgres datacache running\n"));
380 return api; 368 return api;
381} 369}
382 370
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index f852d3b06..db27de3e2 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -28,8 +28,6 @@
28#include "gnunet_datacache_plugin.h" 28#include "gnunet_datacache_plugin.h"
29#include <sqlite3.h> 29#include <sqlite3.h>
30 30
31#define DEBUG_DATACACHE_SQLITE GNUNET_EXTRA_LOGGING
32
33#define LOG(kind,...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__) 31#define LOG(kind,...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__)
34 32
35#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn) 33#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache-sqlite", op, fn)
@@ -108,13 +106,11 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
108 sqlite3_stmt *stmt; 106 sqlite3_stmt *stmt;
109 int64_t dval; 107 int64_t dval;
110 108
111#if DEBUG_DATACACHE_SQLITE
112 LOG (GNUNET_ERROR_TYPE_DEBUG, 109 LOG (GNUNET_ERROR_TYPE_DEBUG,
113 "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n", 110 "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n",
114 "PUT", (unsigned int) size, GNUNET_h2s (key), 111 "PUT", (unsigned int) size, GNUNET_h2s (key),
115 (unsigned long long) 112 (unsigned long long)
116 GNUNET_TIME_absolute_get_remaining (discard_time).rel_value); 113 GNUNET_TIME_absolute_get_remaining (discard_time).rel_value);
117#endif
118 dval = (int64_t) discard_time.abs_value; 114 dval = (int64_t) discard_time.abs_value;
119 if (dval < 0) 115 if (dval < 0)
120 dval = INT64_MAX; 116 dval = INT64_MAX;
@@ -182,10 +178,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
182 int64_t ntime; 178 int64_t ntime;
183 179
184 now = GNUNET_TIME_absolute_get (); 180 now = GNUNET_TIME_absolute_get ();
185#if DEBUG_DATACACHE_SQLITE
186 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET", 181 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET",
187 GNUNET_h2s (key)); 182 GNUNET_h2s (key));
188#endif
189 if (sq_prepare 183 if (sq_prepare
190 (plugin->dbh, 184 (plugin->dbh,
191 "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", 185 "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?",
@@ -214,23 +208,19 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
214 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 208 LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
215 "sqlite_step"); 209 "sqlite_step");
216 sqlite3_finalize (stmt); 210 sqlite3_finalize (stmt);
217#if DEBUG_DATACACHE_SQLITE
218 LOG (GNUNET_ERROR_TYPE_DEBUG, 211 LOG (GNUNET_ERROR_TYPE_DEBUG,
219 "No content found when processing `%s' for key `%4s'\n", "GET", 212 "No content found when processing `%s' for key `%4s'\n", "GET",
220 GNUNET_h2s (key)); 213 GNUNET_h2s (key));
221#endif
222 return 0; 214 return 0;
223 } 215 }
224 total = sqlite3_column_int (stmt, 0); 216 total = sqlite3_column_int (stmt, 0);
225 sqlite3_finalize (stmt); 217 sqlite3_finalize (stmt);
226 if ((total == 0) || (iter == NULL)) 218 if ((total == 0) || (iter == NULL))
227 { 219 {
228#if DEBUG_DATACACHE_SQLITE
229 if (0 == total) 220 if (0 == total)
230 LOG (GNUNET_ERROR_TYPE_DEBUG, 221 LOG (GNUNET_ERROR_TYPE_DEBUG,
231 "No content found when processing `%s' for key `%4s'\n", "GET", 222 "No content found when processing `%s' for key `%4s'\n", "GET",
232 GNUNET_h2s (key)); 223 GNUNET_h2s (key));
233#endif
234 return total; 224 return total;
235 } 225 }
236 226
@@ -268,11 +258,9 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
268 if (ntime == INT64_MAX) 258 if (ntime == INT64_MAX)
269 exp = GNUNET_TIME_UNIT_FOREVER_ABS; 259 exp = GNUNET_TIME_UNIT_FOREVER_ABS;
270 cnt++; 260 cnt++;
271#if DEBUG_DATACACHE_SQLITE
272 LOG (GNUNET_ERROR_TYPE_DEBUG, 261 LOG (GNUNET_ERROR_TYPE_DEBUG,
273 "Found %u-byte result when processing `%s' for key `%4s'\n", 262 "Found %u-byte result when processing `%s' for key `%4s'\n",
274 (unsigned int) size, "GET", GNUNET_h2s (key)); 263 (unsigned int) size, "GET", GNUNET_h2s (key));
275#endif
276 if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type)) 264 if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type))
277 { 265 {
278 sqlite3_finalize (stmt); 266 sqlite3_finalize (stmt);
@@ -301,9 +289,7 @@ sqlite_plugin_del (void *cls)
301 sqlite3_stmt *dstmt; 289 sqlite3_stmt *dstmt;
302 GNUNET_HashCode hc; 290 GNUNET_HashCode hc;
303 291
304#if DEBUG_DATACACHE_SQLITE
305 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL"); 292 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL");
306#endif
307 stmt = NULL; 293 stmt = NULL;
308 dstmt = NULL; 294 dstmt = NULL;
309 if (sq_prepare 295 if (sq_prepare
@@ -458,15 +444,11 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
458 stmt = sqlite3_next_stmt (plugin->dbh, NULL); 444 stmt = sqlite3_next_stmt (plugin->dbh, NULL);
459 while (stmt != NULL) 445 while (stmt != NULL)
460 { 446 {
461#if DEBUG_SQLITE
462 LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing statement %p\n", stmt); 447 LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing statement %p\n", stmt);
463#endif
464 result = sqlite3_finalize (stmt); 448 result = sqlite3_finalize (stmt);
465#if DEBUG_SQLITE
466 if (result != SQLITE_OK) 449 if (result != SQLITE_OK)
467 LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to close statement %p: %d\n", 450 LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to close statement %p: %d\n"),
468 stmt, result); 451 stmt, result);
469#endif
470 stmt = sqlite3_next_stmt (plugin->dbh, NULL); 452 stmt = sqlite3_next_stmt (plugin->dbh, NULL);
471 } 453 }
472 result = sqlite3_close (plugin->dbh); 454 result = sqlite3_close (plugin->dbh);