From 9fac6b6eefdc9144053f736fd388cb2199a97046 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 6 May 2012 01:12:57 +0000 Subject: -removing legacy ifdefs, fixing log statements --- src/datacache/datacache.c | 9 ------- src/datacache/plugin_datacache_mysql.c | 1 - src/datacache/plugin_datacache_postgres.c | 44 +++++++++++-------------------- src/datacache/plugin_datacache_sqlite.c | 20 +------------- 4 files changed, 17 insertions(+), 57 deletions(-) (limited to 'src/datacache') 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 @@ #include "gnunet_statistics_service.h" #include "gnunet_datacache_plugin.h" -#define DEBUG_DATACACHE GNUNET_EXTRA_LOGGING #define LOG(kind,...) GNUNET_log_from (kind, "datacache", __VA_ARGS__) @@ -108,10 +107,8 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size) { struct GNUNET_DATACACHE_Handle *h = cls; -#if DEBUG_DATACACHE LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n", GNUNET_h2s (key)); -#endif GNUNET_assert (h->utilization >= size); h->utilization -= size; GNUNET_CONTAINER_bloomfilter_remove (h->filter, key); @@ -248,10 +245,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, GNUNET_break (0); return GNUNET_SYSERR; } -#if DEBUG_DATACACHE LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n", GNUNET_h2s (key)); -#endif GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size, GNUNET_NO); GNUNET_CONTAINER_bloomfilter_add (h->filter, key); @@ -280,20 +275,16 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, { GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1, GNUNET_NO); -#if DEBUG_DATACACHE LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n", GNUNET_h2s (key)); -#endif if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) { GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests filtered by bloom filter"), 1, GNUNET_NO); -#if DEBUG_DATACACHE LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n", GNUNET_h2s (key)); -#endif return 0; /* can not be present */ } 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 @@ #include "gnunet_mysql_lib.h" #include -#define DEBUG_DATACACHE_MYSQL GNUNET_EXTRA_LOGGING /** * 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 @@ #include "gnunet_datacache_plugin.h" #include -#define DEBUG_POSTGRES GNUNET_EXTRA_LOGGING +#define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__) /** * Per-entry overhead estimate @@ -236,20 +236,16 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key, GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", (type == 0) ? "getk" : "getkt")) { -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Ending iteration (postgres error)\n"); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Ending iteration (postgres error)\n"); return 0; } if (0 == (cnt = PQntuples (res))) { /* no result */ -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Ending iteration (no more results)\n"); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Ending iteration (no more results)\n"); PQclear (res); return 0; } @@ -271,19 +267,15 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key, GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0)); type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1)); size = PQgetlength (res, i, 2); -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Found result of size %u bytes and type %u in database\n", - (unsigned int) size, (unsigned int) type); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Found result of size %u bytes and type %u in database\n", + (unsigned int) size, (unsigned int) type); if (GNUNET_SYSERR == iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2), (enum GNUNET_BLOCK_Type) type)) { -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Ending iteration (client error)\n"); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Ending iteration (client error)\n"); PQclear (res); return cnt; } @@ -313,19 +305,15 @@ postgres_plugin_del (void *cls) if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm")) { -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Ending iteration (postgres error)\n"); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Ending iteration (postgres error)\n"); return 0; } if (0 == PQntuples (res)) { /* no result */ -#if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", - "Ending iteration (no more results)\n"); -#endif + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Ending iteration (no more results)\n"); PQclear (res); return GNUNET_SYSERR; } @@ -375,8 +363,8 @@ libgnunet_plugin_datacache_postgres_init (void *cls) api->get = &postgres_plugin_get; api->put = &postgres_plugin_put; api->del = &postgres_plugin_del; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datacache-postgres", - _("Postgres datacache running\n")); + LOG (GNUNET_ERROR_TYPE_INFO, + _("Postgres datacache running\n")); return api; } 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 @@ #include "gnunet_datacache_plugin.h" #include -#define DEBUG_DATACACHE_SQLITE GNUNET_EXTRA_LOGGING - #define LOG(kind,...) GNUNET_log_from (kind, "datacache-sqlite", __VA_ARGS__) #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, sqlite3_stmt *stmt; int64_t dval; -#if DEBUG_DATACACHE_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n", "PUT", (unsigned int) size, GNUNET_h2s (key), (unsigned long long) GNUNET_TIME_absolute_get_remaining (discard_time).rel_value); -#endif dval = (int64_t) discard_time.abs_value; if (dval < 0) dval = INT64_MAX; @@ -182,10 +178,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, int64_t ntime; now = GNUNET_TIME_absolute_get (); -#if DEBUG_DATACACHE_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET", GNUNET_h2s (key)); -#endif if (sq_prepare (plugin->dbh, "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", @@ -214,23 +208,19 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_step"); sqlite3_finalize (stmt); -#if DEBUG_DATACACHE_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "No content found when processing `%s' for key `%4s'\n", "GET", GNUNET_h2s (key)); -#endif return 0; } total = sqlite3_column_int (stmt, 0); sqlite3_finalize (stmt); if ((total == 0) || (iter == NULL)) { -#if DEBUG_DATACACHE_SQLITE if (0 == total) LOG (GNUNET_ERROR_TYPE_DEBUG, "No content found when processing `%s' for key `%4s'\n", "GET", GNUNET_h2s (key)); -#endif return total; } @@ -268,11 +258,9 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, if (ntime == INT64_MAX) exp = GNUNET_TIME_UNIT_FOREVER_ABS; cnt++; -#if DEBUG_DATACACHE_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "Found %u-byte result when processing `%s' for key `%4s'\n", (unsigned int) size, "GET", GNUNET_h2s (key)); -#endif if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type)) { sqlite3_finalize (stmt); @@ -301,9 +289,7 @@ sqlite_plugin_del (void *cls) sqlite3_stmt *dstmt; GNUNET_HashCode hc; -#if DEBUG_DATACACHE_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL"); -#endif stmt = NULL; dstmt = NULL; if (sq_prepare @@ -458,15 +444,11 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) stmt = sqlite3_next_stmt (plugin->dbh, NULL); while (stmt != NULL) { -#if DEBUG_SQLITE LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing statement %p\n", stmt); -#endif result = sqlite3_finalize (stmt); -#if DEBUG_SQLITE if (result != SQLITE_OK) - LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to close statement %p: %d\n", + LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to close statement %p: %d\n"), stmt, result); -#endif stmt = sqlite3_next_stmt (plugin->dbh, NULL); } result = sqlite3_close (plugin->dbh); -- cgit v1.2.3