diff options
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index d965ad8e0..53ba858e4 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -880,7 +880,6 @@ handle_get (void *cls, | |||
880 | GNUNET_ntohll (msg->next_uid), | 880 | GNUNET_ntohll (msg->next_uid), |
881 | msg->random, | 881 | msg->random, |
882 | NULL, | 882 | NULL, |
883 | NULL, | ||
884 | ntohl (msg->type), | 883 | ntohl (msg->type), |
885 | &transmit_item, | 884 | &transmit_item, |
886 | client); | 885 | client); |
@@ -932,7 +931,6 @@ handle_get_key (void *cls, | |||
932 | GNUNET_ntohll (msg->next_uid), | 931 | GNUNET_ntohll (msg->next_uid), |
933 | msg->random, | 932 | msg->random, |
934 | &msg->key, | 933 | &msg->key, |
935 | NULL, | ||
936 | ntohl (msg->type), | 934 | ntohl (msg->type), |
937 | &transmit_item, | 935 | &transmit_item, |
938 | client); | 936 | client); |
@@ -1001,50 +999,46 @@ handle_get_zero_anonymity (void *cls, | |||
1001 | 999 | ||
1002 | 1000 | ||
1003 | /** | 1001 | /** |
1004 | * Callback function that will cause the item that is passed | 1002 | * Remove continuation. |
1005 | * in to be deleted (by returning #GNUNET_NO). | ||
1006 | * | 1003 | * |
1007 | * @param cls closure | 1004 | * @param cls closure |
1008 | * @param key key for the content | 1005 | * @param key key for the content |
1009 | * @param size number of bytes in data | 1006 | * @param size number of bytes in data |
1010 | * @param data content stored | 1007 | * @param status #GNUNET_OK if removed, #GNUNET_NO if not found, |
1011 | * @param type type of the content | 1008 | * or #GNUNET_SYSERROR if error |
1012 | * @param priority priority of the content | 1009 | * @param msg error message on error |
1013 | * @param anonymity anonymity-level for the content | ||
1014 | * @param replication replication-level for the content | ||
1015 | * @param expiration expiration time for the content | ||
1016 | * @param uid unique identifier for the datum | ||
1017 | * @return #GNUNET_OK to keep the item | ||
1018 | * #GNUNET_NO to delete the item | ||
1019 | */ | 1010 | */ |
1020 | static int | 1011 | static void |
1021 | remove_callback (void *cls, | 1012 | remove_continuation (void *cls, |
1022 | const struct GNUNET_HashCode *key, | 1013 | const struct GNUNET_HashCode *key, |
1023 | uint32_t size, | 1014 | uint32_t size, |
1024 | const void *data, | 1015 | int status, |
1025 | enum GNUNET_BLOCK_Type type, | 1016 | const char *msg) |
1026 | uint32_t priority, | ||
1027 | uint32_t anonymity, | ||
1028 | uint32_t replication, | ||
1029 | struct GNUNET_TIME_Absolute expiration, | ||
1030 | uint64_t uid) | ||
1031 | { | 1017 | { |
1032 | struct GNUNET_SERVICE_Client *client = cls; | 1018 | struct GNUNET_SERVICE_Client *client = cls; |
1033 | 1019 | ||
1034 | if (NULL == key) | 1020 | if (GNUNET_SYSERR == status) |
1021 | { | ||
1022 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1023 | "REMOVE request failed: %s.\n", | ||
1024 | msg); | ||
1025 | transmit_status (client, | ||
1026 | GNUNET_NO, | ||
1027 | msg); | ||
1028 | return; | ||
1029 | } | ||
1030 | if (GNUNET_NO == status) | ||
1035 | { | 1031 | { |
1036 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1032 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1037 | "No further matches for REMOVE request.\n"); | 1033 | "Content not found for REMOVE request.\n"); |
1038 | transmit_status (client, | 1034 | transmit_status (client, |
1039 | GNUNET_NO, | 1035 | GNUNET_NO, |
1040 | _("Content not found")); | 1036 | _("Content not found")); |
1041 | return GNUNET_OK; /* last item */ | 1037 | return; |
1042 | } | 1038 | } |
1043 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1039 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1044 | "Item %llu matches REMOVE request for key `%s' and type %u.\n", | 1040 | "Item matches REMOVE request for key `%s'.\n", |
1045 | (unsigned long long) uid, | 1041 | GNUNET_h2s (key)); |
1046 | GNUNET_h2s (key), | ||
1047 | type); | ||
1048 | GNUNET_STATISTICS_update (stats, | 1042 | GNUNET_STATISTICS_update (stats, |
1049 | gettext_noop ("# bytes removed (explicit request)"), | 1043 | gettext_noop ("# bytes removed (explicit request)"), |
1050 | size, | 1044 | size, |
@@ -1054,7 +1048,6 @@ remove_callback (void *cls, | |||
1054 | transmit_status (client, | 1048 | transmit_status (client, |
1055 | GNUNET_OK, | 1049 | GNUNET_OK, |
1056 | NULL); | 1050 | NULL); |
1057 | return GNUNET_NO; | ||
1058 | } | 1051 | } |
1059 | 1052 | ||
1060 | 1053 | ||
@@ -1090,26 +1083,19 @@ handle_remove (void *cls, | |||
1090 | const struct DataMessage *dm) | 1083 | const struct DataMessage *dm) |
1091 | { | 1084 | { |
1092 | struct GNUNET_SERVICE_Client *client = cls; | 1085 | struct GNUNET_SERVICE_Client *client = cls; |
1093 | struct GNUNET_HashCode vhash; | ||
1094 | 1086 | ||
1095 | GNUNET_STATISTICS_update (stats, | 1087 | GNUNET_STATISTICS_update (stats, |
1096 | gettext_noop ("# REMOVE requests received"), | 1088 | gettext_noop ("# REMOVE requests received"), |
1097 | 1, GNUNET_NO); | 1089 | 1, GNUNET_NO); |
1098 | GNUNET_CRYPTO_hash (&dm[1], | ||
1099 | ntohl (dm->size), | ||
1100 | &vhash); | ||
1101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1090 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1102 | "Processing REMOVE request for `%s' of type %u\n", | 1091 | "Processing REMOVE request for `%s'\n", |
1103 | GNUNET_h2s (&dm->key), | 1092 | GNUNET_h2s (&dm->key)); |
1104 | (uint32_t) ntohl (dm->type)); | 1093 | plugin->api->remove_key (plugin->api->cls, |
1105 | plugin->api->get_key (plugin->api->cls, | 1094 | &dm->key, |
1106 | 0, | 1095 | ntohl (dm->size), |
1107 | false, | 1096 | &dm[1], |
1108 | &dm->key, | 1097 | &remove_continuation, |
1109 | &vhash, | 1098 | client); |
1110 | (enum GNUNET_BLOCK_Type) ntohl (dm->type), | ||
1111 | &remove_callback, | ||
1112 | client); | ||
1113 | GNUNET_SERVICE_client_continue (client); | 1099 | GNUNET_SERVICE_client_continue (client); |
1114 | } | 1100 | } |
1115 | 1101 | ||