diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-06 01:12:57 +0000 |
commit | 9fac6b6eefdc9144053f736fd388cb2199a97046 (patch) | |
tree | 82740a981b7f6ae973d915aa77797acd9db668b2 /src/datacache/plugin_datacache_sqlite.c | |
parent | 23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff) | |
download | gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip |
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/datacache/plugin_datacache_sqlite.c')
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 20 |
1 files changed, 1 insertions, 19 deletions
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); |