aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/gnunet-service-datastore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-19 11:31:54 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-19 11:31:54 +0000
commit1e879063d6c677c3cb0f57bbc61b8d908aeb2a05 (patch)
treefb8bf3cbf850a4741137fb4f0615fa1162f14d10 /src/datastore/gnunet-service-datastore.c
parentc6689c4e233c663f79cf00449e70ce3c56653f1c (diff)
downloadgnunet-1e879063d6c677c3cb0f57bbc61b8d908aeb2a05.tar.gz
gnunet-1e879063d6c677c3cb0f57bbc61b8d908aeb2a05.zip
bugfixes
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r--src/datastore/gnunet-service-datastore.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 70d349693..74196dd1e 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -38,8 +38,6 @@
38#include "plugin_datastore.h" 38#include "plugin_datastore.h"
39#include "datastore.h" 39#include "datastore.h"
40 40
41#define DEBUG_DATASTORE GNUNET_YES
42
43/** 41/**
44 * How many messages do we queue at most per client? 42 * How many messages do we queue at most per client?
45 */ 43 */
@@ -207,10 +205,6 @@ transmit_callback (void *cls,
207 tcc->tc (tcc->tc_cls, GNUNET_SYSERR); 205 tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
208 if (GNUNET_YES == tcc->end) 206 if (GNUNET_YES == tcc->end)
209 { 207 {
210#if DEBUG_DATASTORE
211 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
212 "Disconnecting client.\n");
213#endif
214 GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR); 208 GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
215 } 209 }
216 GNUNET_free (tcc->msg); 210 GNUNET_free (tcc->msg);
@@ -308,10 +302,10 @@ transmit_status (struct GNUNET_SERVER_Client *client,
308 302
309#if DEBUG_DATASTORE 303#if DEBUG_DATASTORE
310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
311 "Transmitting `s' message with value %d and message %s\n", 305 "Transmitting `%s' message with value %d and message %s\n",
312 "STATUS", 306 "STATUS",
313 code, 307 code,
314 msg); 308 msg != NULL ? msg : "(none)");
315#endif 309#endif
316 slen = (msg == NULL) ? 0 : strlen(msg) + 1; 310 slen = (msg == NULL) ? 0 : strlen(msg) + 1;
317 sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen); 311 sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen);
@@ -578,7 +572,7 @@ handle_put (void *cls,
578 GNUNET_CONTAINER_bloomfilter_add (filter, 572 GNUNET_CONTAINER_bloomfilter_add (filter,
579 &dm->key); 573 &dm->key);
580 transmit_status (client, 574 transmit_status (client,
581 GNUNET_SYSERR == ret ? GNUNET_SYSERR : GNUNET_OK, 575 (GNUNET_SYSERR == ret) ? GNUNET_SYSERR : GNUNET_OK,
582 msg); 576 msg);
583 GNUNET_free_non_null (msg); 577 GNUNET_free_non_null (msg);
584} 578}
@@ -619,11 +613,16 @@ handle_get (void *cls,
619 &msg->key)) ) 613 &msg->key)) )
620 { 614 {
621 /* don't bother database... */ 615 /* don't bother database... */
616#if DEBUG_DATASTORE
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
618 "Empty result set for `%s' request.\n",
619 "GET");
620#endif
622 transmit_item (client, 621 transmit_item (client,
623 NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); 622 NULL, NULL, 0, NULL, 0, 0, 0, zero, 0);
624 return; 623 return;
625 } 624 }
626 GNUNET_SERVER_client_drop (client); 625 GNUNET_SERVER_client_keep (client);
627 plugin->api->get (plugin->api->cls, 626 plugin->api->get (plugin->api->cls,
628 ((size == sizeof(struct GetMessage)) ? &msg->key : NULL), 627 ((size == sizeof(struct GetMessage)) ? &msg->key : NULL),
629 NULL, 628 NULL,
@@ -683,7 +682,7 @@ handle_get_random (void *cls,
683 "Processing `%s' request\n", 682 "Processing `%s' request\n",
684 "GET_RANDOM"); 683 "GET_RANDOM");
685#endif 684#endif
686 GNUNET_SERVER_client_drop (client); // FIXME: WTF? 685 GNUNET_SERVER_client_keep (client);
687 plugin->api->iter_migration_order (plugin->api->cls, 686 plugin->api->iter_migration_order (plugin->api->cls,
688 0, 687 0,
689 &transmit_item, 688 &transmit_item,
@@ -725,8 +724,14 @@ remove_callback (void *cls,
725 expiration, uint64_t uid) 724 expiration, uint64_t uid)
726{ 725{
727 struct RemoveContext *rc = cls; 726 struct RemoveContext *rc = cls;
727
728 if (key == NULL) 728 if (key == NULL)
729 { 729 {
730#if DEBUG_DATASTORE
731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
732 "No further matches for `%s' request.\n",
733 "REMOVE");
734#endif
730 if (GNUNET_YES == rc->found) 735 if (GNUNET_YES == rc->found)
731 transmit_status (rc->client, GNUNET_OK, NULL); 736 transmit_status (rc->client, GNUNET_OK, NULL);
732 else 737 else
@@ -736,9 +741,15 @@ remove_callback (void *cls,
736 return GNUNET_OK; /* last item */ 741 return GNUNET_OK; /* last item */
737 } 742 }
738 rc->found = GNUNET_YES; 743 rc->found = GNUNET_YES;
739 plugin->api->next_request (next_cls, GNUNET_YES); 744#if DEBUG_DATASTORE
745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
746 "Item %llu matches `%s' request.\n",
747 (unsigned long long) uid,
748 "REMOVE");
749#endif
740 GNUNET_CONTAINER_bloomfilter_remove (filter, 750 GNUNET_CONTAINER_bloomfilter_remove (filter,
741 key); 751 key);
752 plugin->api->next_request (next_cls, GNUNET_YES);
742 return GNUNET_NO; 753 return GNUNET_NO;
743} 754}
744 755
@@ -776,6 +787,7 @@ handle_remove (void *cls,
776 GNUNET_CRYPTO_hash (&dm[1], 787 GNUNET_CRYPTO_hash (&dm[1],
777 ntohl(dm->size), 788 ntohl(dm->size),
778 &vhash); 789 &vhash);
790 GNUNET_SERVER_client_keep (client);
779 plugin->api->get (plugin->api->cls, 791 plugin->api->get (plugin->api->cls,
780 &dm->key, 792 &dm->key,
781 &vhash, 793 &vhash,
@@ -857,7 +869,7 @@ load_plugin (struct GNUNET_CONFIGURATION_Handle *cfg,
857 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 869 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
858 _("Loading `%s' datastore plugin\n"), name); 870 _("Loading `%s' datastore plugin\n"), name);
859 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); 871 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
860 ret->short_name = GNUNET_strdup (name); 872 ret->short_name = name;
861 ret->lib_name = libname; 873 ret->lib_name = libname;
862 ret->api = GNUNET_PLUGIN_load (libname, &ret->env); 874 ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
863 if (ret->api == NULL) 875 if (ret->api == NULL)