diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-01 18:20:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-01 18:20:44 +0000 |
commit | 3a3219bcc1d219bf012d20bcc87c03041f59044d (patch) | |
tree | aff9063ede978dad957d19ecd84f7b09c3de4768 /src/datastore/plugin_datastore_sqlite.c | |
parent | a8de20af8037dc7fc0bdad2ebe235942b91f4f28 (diff) | |
download | gnunet-3a3219bcc1d219bf012d20bcc87c03041f59044d.tar.gz gnunet-3a3219bcc1d219bf012d20bcc87c03041f59044d.zip |
-removing legacy #ifdefs
Diffstat (limited to 'src/datastore/plugin_datastore_sqlite.c')
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index cd5ae394f..00195fb13 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -28,10 +28,6 @@ | |||
28 | #include "gnunet_datastore_plugin.h" | 28 | #include "gnunet_datastore_plugin.h" |
29 | #include <sqlite3.h> | 29 | #include <sqlite3.h> |
30 | 30 | ||
31 | /** | ||
32 | * Enable or disable logging debug messages. | ||
33 | */ | ||
34 | #define DEBUG_SQLITE GNUNET_EXTRA_LOGGING | ||
35 | 31 | ||
36 | /** | 32 | /** |
37 | * We allocate items on the stack at times. To prevent a stack | 33 | * We allocate items on the stack at times. To prevent a stack |
@@ -147,10 +143,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, sqlite3_stmt ** ppStmt) | |||
147 | result = | 143 | result = |
148 | sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt, | 144 | sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt, |
149 | (const char **) &dummy); | 145 | (const char **) &dummy); |
150 | #if DEBUG_SQLITE && 0 | ||
151 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 146 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
152 | "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result); | 147 | "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result); |
153 | #endif | ||
154 | return result; | 148 | return result; |
155 | } | 149 | } |
156 | 150 | ||
@@ -415,10 +409,8 @@ database_shutdown (struct Plugin *plugin) | |||
415 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); | 409 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); |
416 | while (stmt != NULL) | 410 | while (stmt != NULL) |
417 | { | 411 | { |
418 | #if DEBUG_SQLITE | ||
419 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 412 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
420 | "Closing statement %p\n", stmt); | 413 | "Closing statement %p\n", stmt); |
421 | #endif | ||
422 | result = sqlite3_finalize (stmt); | 414 | result = sqlite3_finalize (stmt); |
423 | if (result != SQLITE_OK) | 415 | if (result != SQLITE_OK) |
424 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", | 416 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", |
@@ -502,14 +494,12 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, | |||
502 | 494 | ||
503 | if (size > MAX_ITEM_SIZE) | 495 | if (size > MAX_ITEM_SIZE) |
504 | return GNUNET_SYSERR; | 496 | return GNUNET_SYSERR; |
505 | #if DEBUG_SQLITE | ||
506 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 497 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
507 | "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n", | 498 | "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n", |
508 | type, GNUNET_h2s (key), priority, | 499 | type, GNUNET_h2s (key), priority, |
509 | (unsigned long long) | 500 | (unsigned long long) |
510 | GNUNET_TIME_absolute_get_remaining (expiration).rel_value, | 501 | GNUNET_TIME_absolute_get_remaining (expiration).rel_value, |
511 | (long long) expiration.abs_value); | 502 | (long long) expiration.abs_value); |
512 | #endif | ||
513 | GNUNET_CRYPTO_hash (data, size, &vhash); | 503 | GNUNET_CRYPTO_hash (data, size, &vhash); |
514 | stmt = plugin->insertContent; | 504 | stmt = plugin->insertContent; |
515 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | 505 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); |
@@ -540,11 +530,9 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, | |||
540 | { | 530 | { |
541 | case SQLITE_DONE: | 531 | case SQLITE_DONE: |
542 | plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD); | 532 | plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD); |
543 | #if DEBUG_SQLITE | ||
544 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 533 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
545 | "Stored new entry (%u bytes)\n", | 534 | "Stored new entry (%u bytes)\n", |
546 | size + GNUNET_DATASTORE_ENTRY_OVERHEAD); | 535 | size + GNUNET_DATASTORE_ENTRY_OVERHEAD); |
547 | #endif | ||
548 | ret = GNUNET_OK; | 536 | ret = GNUNET_OK; |
549 | break; | 537 | break; |
550 | case SQLITE_BUSY: | 538 | case SQLITE_BUSY: |
@@ -621,9 +609,7 @@ sqlite_plugin_update (void *cls, uint64_t uid, int delta, | |||
621 | switch (n) | 609 | switch (n) |
622 | { | 610 | { |
623 | case SQLITE_DONE: | 611 | case SQLITE_DONE: |
624 | #if DEBUG_SQLITE | ||
625 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Block updated\n"); | 612 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Block updated\n"); |
626 | #endif | ||
627 | return GNUNET_OK; | 613 | return GNUNET_OK; |
628 | case SQLITE_BUSY: | 614 | case SQLITE_BUSY: |
629 | LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 615 | LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
@@ -677,11 +663,9 @@ execute_get (struct Plugin *plugin, sqlite3_stmt * stmt, | |||
677 | break; | 663 | break; |
678 | } | 664 | } |
679 | expiration.abs_value = sqlite3_column_int64 (stmt, 3); | 665 | expiration.abs_value = sqlite3_column_int64 (stmt, 3); |
680 | #if DEBUG_SQLITE | ||
681 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 666 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
682 | "Found reply in database with expiration %llu\n", | 667 | "Found reply in database with expiration %llu\n", |
683 | (unsigned long long) expiration.abs_value); | 668 | (unsigned long long) expiration.abs_value); |
684 | #endif | ||
685 | ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ , | 669 | ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ , |
686 | size, sqlite3_column_blob (stmt, 5) /* data */ , | 670 | size, sqlite3_column_blob (stmt, 5) /* data */ , |
687 | sqlite3_column_int (stmt, 0) /* type */ , | 671 | sqlite3_column_int (stmt, 0) /* type */ , |
@@ -972,10 +956,8 @@ sqlite_plugin_get_replication (void *cls, PluginDatumProcessor proc, | |||
972 | uint32_t repl; | 956 | uint32_t repl; |
973 | sqlite3_stmt *stmt; | 957 | sqlite3_stmt *stmt; |
974 | 958 | ||
975 | #if DEBUG_SQLITE | ||
976 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 959 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
977 | "Getting random block based on replication order.\n"); | 960 | "Getting random block based on replication order.\n"); |
978 | #endif | ||
979 | rc.have_uid = GNUNET_NO; | 961 | rc.have_uid = GNUNET_NO; |
980 | rc.proc = proc; | 962 | rc.proc = proc; |
981 | rc.proc_cls = proc_cls; | 963 | rc.proc_cls = proc_cls; |
@@ -1061,10 +1043,8 @@ sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc, | |||
1061 | sqlite3_stmt *stmt; | 1043 | sqlite3_stmt *stmt; |
1062 | struct GNUNET_TIME_Absolute now; | 1044 | struct GNUNET_TIME_Absolute now; |
1063 | 1045 | ||
1064 | #if DEBUG_SQLITE | ||
1065 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 1046 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
1066 | "Getting random block based on expiration and priority order.\n"); | 1047 | "Getting random block based on expiration and priority order.\n"); |
1067 | #endif | ||
1068 | now = GNUNET_TIME_absolute_get (); | 1048 | now = GNUNET_TIME_absolute_get (); |
1069 | stmt = plugin->selExpi; | 1049 | stmt = plugin->selExpi; |
1070 | if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value)) | 1050 | if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value)) |
@@ -1233,18 +1213,13 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) | |||
1233 | struct GNUNET_DATASTORE_PluginFunctions *api = cls; | 1213 | struct GNUNET_DATASTORE_PluginFunctions *api = cls; |
1234 | struct Plugin *plugin = api->cls; | 1214 | struct Plugin *plugin = api->cls; |
1235 | 1215 | ||
1236 | #if DEBUG_SQLITE | ||
1237 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 1216 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
1238 | "sqlite plugin is done\n"); | 1217 | "sqlite plugin is done\n"); |
1239 | #endif | ||
1240 | |||
1241 | fn = NULL; | 1218 | fn = NULL; |
1242 | if (plugin->drop_on_shutdown) | 1219 | if (plugin->drop_on_shutdown) |
1243 | fn = GNUNET_strdup (plugin->fn); | 1220 | fn = GNUNET_strdup (plugin->fn); |
1244 | #if DEBUG_SQLITE | ||
1245 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 1221 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
1246 | "Shutting down database\n"); | 1222 | "Shutting down database\n"); |
1247 | #endif | ||
1248 | database_shutdown (plugin); | 1223 | database_shutdown (plugin); |
1249 | plugin->env = NULL; | 1224 | plugin->env = NULL; |
1250 | GNUNET_free (api); | 1225 | GNUNET_free (api); |
@@ -1254,10 +1229,8 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) | |||
1254 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); | 1229 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
1255 | GNUNET_free (fn); | 1230 | GNUNET_free (fn); |
1256 | } | 1231 | } |
1257 | #if DEBUG_SQLITE | ||
1258 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", | 1232 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
1259 | "sqlite plugin is finished\n"); | 1233 | "sqlite plugin is finished\n"); |
1260 | #endif | ||
1261 | return NULL; | 1234 | return NULL; |
1262 | } | 1235 | } |
1263 | 1236 | ||