diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-27 19:04:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-27 19:04:31 +0000 |
commit | bf5093d63a384e216fc765a8a800ecb17840d56b (patch) | |
tree | 95f5a88c6b1bab9a2721e98df0f96d3dc7d249b8 /src | |
parent | ea01f6b6a8d3f59bf03cf128dc8a8fdfb35a75f5 (diff) | |
download | gnunet-bf5093d63a384e216fc765a8a800ecb17840d56b.tar.gz gnunet-bf5093d63a384e216fc765a8a800ecb17840d56b.zip |
pass repl
Diffstat (limited to 'src')
-rw-r--r-- | src/datastore/datastore.h | 10 | ||||
-rw-r--r-- | src/datastore/datastore_api.c | 7 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 19 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 12 |
4 files changed, 40 insertions, 8 deletions
diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h index d66ec0e95..70acffc99 100644 --- a/src/datastore/datastore.h +++ b/src/datastore/datastore.h | |||
@@ -220,6 +220,16 @@ struct DataMessage | |||
220 | uint32_t anonymity GNUNET_PACKED; | 220 | uint32_t anonymity GNUNET_PACKED; |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * Desired replication level. 0 from service to API. | ||
224 | */ | ||
225 | uint32_t replication GNUNET_PACKED; | ||
226 | |||
227 | /** | ||
228 | * For alignment. | ||
229 | */ | ||
230 | uint32_t reserved GNUNET_PACKED; | ||
231 | |||
232 | /** | ||
223 | * Unique ID for the content (can be used for UPDATE); | 233 | * Unique ID for the content (can be used for UPDATE); |
224 | * can be zero for remove (which indicates that | 234 | * can be zero for remove (which indicates that |
225 | * the datastore should use whatever UID matches | 235 | * the datastore should use whatever UID matches |
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 99060bd60..7818ed05c 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -854,9 +854,10 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
854 | 854 | ||
855 | #if DEBUG_DATASTORE | 855 | #if DEBUG_DATASTORE |
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
857 | "Asked to put %u bytes of data under key `%s'\n", | 857 | "Asked to put %u bytes of data under key `%s' for %llu ms\n", |
858 | size, | 858 | size, |
859 | GNUNET_h2s (key)); | 859 | GNUNET_h2s (key), |
860 | GNUNET_TIME_absolute_get_remaining (expiration).rel_value); | ||
860 | #endif | 861 | #endif |
861 | msize = sizeof(struct DataMessage) + size; | 862 | msize = sizeof(struct DataMessage) + size; |
862 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 863 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
@@ -885,6 +886,8 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
885 | dm->type = htonl(type); | 886 | dm->type = htonl(type); |
886 | dm->priority = htonl(priority); | 887 | dm->priority = htonl(priority); |
887 | dm->anonymity = htonl(anonymity); | 888 | dm->anonymity = htonl(anonymity); |
889 | dm->replication = htonl (replication); | ||
890 | dm->reserved = htonl (0); | ||
888 | dm->uid = GNUNET_htonll(0); | 891 | dm->uid = GNUNET_htonll(0); |
889 | dm->expiration = GNUNET_TIME_absolute_hton(expiration); | 892 | dm->expiration = GNUNET_TIME_absolute_hton(expiration); |
890 | dm->key = *key; | 893 | dm->key = *key; |
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index deab62dd0..a0d5f7bab 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -646,16 +646,20 @@ transmit_item (void *cls, | |||
646 | dm->type = htonl(type); | 646 | dm->type = htonl(type); |
647 | dm->priority = htonl(priority); | 647 | dm->priority = htonl(priority); |
648 | dm->anonymity = htonl(anonymity); | 648 | dm->anonymity = htonl(anonymity); |
649 | dm->replication = htonl (0); | ||
650 | dm->reserved = htonl (0); | ||
649 | dm->expiration = GNUNET_TIME_absolute_hton(expiration); | 651 | dm->expiration = GNUNET_TIME_absolute_hton(expiration); |
650 | dm->uid = GNUNET_htonll(uid); | 652 | dm->uid = GNUNET_htonll(uid); |
651 | dm->key = *key; | 653 | dm->key = *key; |
652 | memcpy (&dm[1], data, size); | 654 | memcpy (&dm[1], data, size); |
653 | #if DEBUG_DATASTORE | 655 | #if DEBUG_DATASTORE |
654 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
655 | "Transmitting `%s' message for `%s' of type %u\n", | 657 | "Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n", |
656 | "DATA", | 658 | "DATA", |
657 | GNUNET_h2s (key), | 659 | GNUNET_h2s (key), |
658 | type); | 660 | type, |
661 | (unsigned long long) expiration.abs_value, | ||
662 | (unsigned long long) GNUNET_TIME_absolute_get ().abs_value); | ||
659 | #endif | 663 | #endif |
660 | GNUNET_STATISTICS_update (stats, | 664 | GNUNET_STATISTICS_update (stats, |
661 | gettext_noop ("# results found"), | 665 | gettext_noop ("# results found"), |
@@ -870,7 +874,7 @@ execute_put (struct GNUNET_SERVER_Client *client, | |||
870 | ntohl(dm->type), | 874 | ntohl(dm->type), |
871 | ntohl(dm->priority), | 875 | ntohl(dm->priority), |
872 | ntohl(dm->anonymity), | 876 | ntohl(dm->anonymity), |
873 | 0 /* FIXME: replication */, | 877 | ntohl(dm->replication), |
874 | GNUNET_TIME_absolute_ntoh(dm->expiration), | 878 | GNUNET_TIME_absolute_ntoh(dm->expiration), |
875 | &msg); | 879 | &msg); |
876 | if (GNUNET_OK == ret) | 880 | if (GNUNET_OK == ret) |
@@ -956,6 +960,15 @@ check_present (void *cls, | |||
956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 960 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
957 | "Result already present in datastore\n"); | 961 | "Result already present in datastore\n"); |
958 | #endif | 962 | #endif |
963 | /* FIXME: change API to allow increasing 'replication' counter */ | ||
964 | if ( (ntohl (dm->priority) > 0) || | ||
965 | (GNUNET_TIME_absolute_ntoh(dm->expiration).abs_value > | ||
966 | expiration.abs_value) ) | ||
967 | plugin->api->update (plugin->api->cls, | ||
968 | uid, | ||
969 | (int32_t) ntohl(dm->priority), | ||
970 | GNUNET_TIME_absolute_ntoh(dm->expiration), | ||
971 | NULL); | ||
959 | transmit_status (pc->client, GNUNET_NO, NULL); | 972 | transmit_status (pc->client, GNUNET_NO, NULL); |
960 | GNUNET_SERVER_client_drop (pc->client); | 973 | GNUNET_SERVER_client_drop (pc->client); |
961 | GNUNET_free (pc); | 974 | GNUNET_free (pc); |
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 3710b7eb7..f58c5bd28 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -31,7 +31,7 @@ | |||
31 | /** | 31 | /** |
32 | * Enable or disable logging debug messages. | 32 | * Enable or disable logging debug messages. |
33 | */ | 33 | */ |
34 | #define DEBUG_SQLITE GNUNET_NO | 34 | #define DEBUG_SQLITE GNUNET_YES |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * We allocate items on the stack at times. To prevent a stack | 37 | * We allocate items on the stack at times. To prevent a stack |
@@ -475,7 +475,7 @@ sqlite_plugin_put (void *cls, | |||
475 | #if DEBUG_SQLITE | 475 | #if DEBUG_SQLITE |
476 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 476 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
477 | "sqlite", | 477 | "sqlite", |
478 | "Storing in database block with type %u/key `%s'/priority %u/expiration %llu (%lld).\n", | 478 | "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n", |
479 | type, | 479 | type, |
480 | GNUNET_h2s(key), | 480 | GNUNET_h2s(key), |
481 | priority, | 481 | priority, |
@@ -650,6 +650,12 @@ execute_get (struct Plugin *plugin, | |||
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | expiration.abs_value = sqlite3_column_int64 (stmt, 3); | 652 | expiration.abs_value = sqlite3_column_int64 (stmt, 3); |
653 | #if DEBUG_SQLITE | ||
654 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | ||
655 | "sqlite", | ||
656 | "Found reply in database with expiration %llu\n", | ||
657 | (unsigned long long) expiration.abs_value); | ||
658 | #endif | ||
653 | ret = proc (proc_cls, | 659 | ret = proc (proc_cls, |
654 | sqlite3_column_blob (stmt, 4) /* key */, | 660 | sqlite3_column_blob (stmt, 4) /* key */, |
655 | size, | 661 | size, |
@@ -1175,7 +1181,7 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) | |||
1175 | #if DEBUG_SQLITE | 1181 | #if DEBUG_SQLITE |
1176 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1182 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
1177 | "sqlite", | 1183 | "sqlite", |
1178 | "sqlite plugin is finished doneing\n"); | 1184 | "sqlite plugin is finished\n"); |
1179 | #endif | 1185 | #endif |
1180 | return NULL; | 1186 | return NULL; |
1181 | } | 1187 | } |