X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fdatastore%2Fgnunet-service-datastore.c;h=f80abef0653c54319135d371220cc06a14ebbde8;hb=e9b2b4007f75dee7837e50edf385cd965a8a4a64;hp=77047dc8a14a7867bff45a381e20bbe04334d985;hpb=a8871b8ff983bdb8adc224a9a88ba5d2960df859;p=oweals%2Fgnunet.git diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 77047dc8a..f80abef06 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -156,7 +156,7 @@ static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; /** * Our configuration. */ -struct GNUNET_CONFIGURATION_Handle *cfg; +const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our scheduler. @@ -281,6 +281,8 @@ expired_processor (void *cls, "Deleting content that expired %llu ms ago\n", (unsigned long long) (now.value - expiration.value)); #endif + GNUNET_CONTAINER_bloomfilter_remove (filter, + key); return GNUNET_NO; /* delete */ } @@ -356,6 +358,8 @@ manage (void *cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD, *need); #endif + GNUNET_CONTAINER_bloomfilter_remove (filter, + key); return GNUNET_NO; } @@ -452,6 +456,8 @@ transmit_callback (void *cls, * * @param client target of the message * @param msg message to transmit, will be freed! + * @param tc function to call afterwards + * @param tc_cls closure for tc * @param end is this the last response (and we should * signal the server completion accodingly after * transmitting this message)? @@ -513,7 +519,7 @@ transmit_status (struct GNUNET_SERVER_Client *client, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' message with value %d and message %s\n", + "Transmitting `%s' message with value %d and message `%s'\n", "STATUS", code, msg != NULL ? msg : "(none)"); @@ -523,7 +529,8 @@ transmit_status (struct GNUNET_SERVER_Client *client, sm->header.size = htons(sizeof(struct StatusMessage) + slen); sm->header.type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_STATUS); sm->status = htonl(code); - memcpy (&sm[1], msg, slen); + if (slen > 0) + memcpy (&sm[1], msg, slen); transmit (client, &sm->header, NULL, NULL, GNUNET_YES); } @@ -532,7 +539,7 @@ transmit_status (struct GNUNET_SERVER_Client *client, * Function called once the transmit operation has * either failed or succeeded. * - * @param cls closure + * @param next_cls closure for calling "next_request" callback * @param status GNUNET_OK on success, GNUNET_SYSERR on error */ static void @@ -639,15 +646,15 @@ handle_reserve (void *cls, unsigned long long used; unsigned long long req; uint64_t amount; - uint64_t entries; + uint32_t entries; #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", "RESERVE"); #endif - amount = ntohl(msg->amount); - entries = GNUNET_ntohll(msg->entries); + amount = GNUNET_ntohll(msg->amount); + entries = ntohl(msg->entries); used = plugin->api->get_size (plugin->api->cls) + reserved; req = amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries; if (used + req > quota) @@ -743,7 +750,6 @@ handle_release_reserve (void *cls, return; } prev = pos; - pos = next; } GNUNET_break (0); transmit_status (client, GNUNET_SYSERR, gettext_noop ("Could not find matching reservation")); @@ -866,7 +872,6 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { - static struct GNUNET_TIME_Absolute zero; const struct GetMessage *msg; uint16_t size; @@ -894,8 +899,10 @@ handle_get (void *cls, "Empty result set for `%s' request.\n", "GET"); #endif + GNUNET_SERVER_client_keep (client); transmit_item (client, - NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); + NULL, NULL, 0, NULL, 0, 0, 0, + GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } GNUNET_SERVER_client_keep (client); @@ -1011,7 +1018,7 @@ remove_callback (void *cls, if (GNUNET_YES == rc->found) transmit_status (rc->client, GNUNET_OK, NULL); else - transmit_status (rc->client, GNUNET_SYSERR, _("Content not found")); + transmit_status (rc->client, GNUNET_NO, _("Content not found")); GNUNET_SERVER_client_drop (rc->client); GNUNET_free (rc); return GNUNET_OK; /* last item */ @@ -1063,7 +1070,6 @@ handle_remove (void *cls, GNUNET_CRYPTO_hash (&dm[1], ntohl(dm->size), &vhash); - GNUNET_SERVER_client_keep (client); plugin->api->get (plugin->api->cls, &dm->key, &vhash, @@ -1189,6 +1195,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { unload_plugin (plugin); plugin = NULL; + if (filter != NULL) + { + GNUNET_CONTAINER_bloomfilter_free (filter); + filter = NULL; + } } @@ -1244,7 +1255,7 @@ static void run (void *cls, struct GNUNET_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *c) + const struct GNUNET_CONFIGURATION_Handle *c) { char *fn; unsigned int bf_size; @@ -1290,6 +1301,7 @@ run (void *cls, if (NULL == plugin) { GNUNET_CONTAINER_bloomfilter_free (filter); + filter = NULL; return; } GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL);