aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/gnunet-service-datastore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r--src/datastore/gnunet-service-datastore.c100
1 files changed, 94 insertions, 6 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 9d13db05e..70d349693 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -38,6 +38,8 @@
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
41/** 43/**
42 * How many messages do we queue at most per client? 44 * How many messages do we queue at most per client?
43 */ 45 */
@@ -197,10 +199,20 @@ transmit_callback (void *cls,
197 msize = ntohs(tcc->msg->size); 199 msize = ntohs(tcc->msg->size);
198 if (size == 0) 200 if (size == 0)
199 { 201 {
202#if DEBUG_DATASTORE
203 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
204 "Transmission failed.\n");
205#endif
200 if (tcc->tc != NULL) 206 if (tcc->tc != NULL)
201 tcc->tc (tcc->tc_cls, GNUNET_SYSERR); 207 tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
202 if (GNUNET_YES == tcc->end) 208 if (GNUNET_YES == tcc->end)
203 GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR); 209 {
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);
215 }
204 GNUNET_free (tcc->msg); 216 GNUNET_free (tcc->msg);
205 GNUNET_free (tcc); 217 GNUNET_free (tcc);
206 return 0; 218 return 0;
@@ -210,7 +222,20 @@ transmit_callback (void *cls,
210 if (tcc->tc != NULL) 222 if (tcc->tc != NULL)
211 tcc->tc (tcc->tc_cls, GNUNET_OK); 223 tcc->tc (tcc->tc_cls, GNUNET_OK);
212 if (GNUNET_YES == tcc->end) 224 if (GNUNET_YES == tcc->end)
213 GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK); 225 {
226#if DEBUG_DATASTORE
227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
228 "Request completed, ready for the next request!\n");
229#endif
230 GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK);
231 }
232 else
233 {
234#if DEBUG_DATASTORE
235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
236 "Response transmitted, more pending!\n");
237#endif
238 }
214 GNUNET_free (tcc->msg); 239 GNUNET_free (tcc->msg);
215 GNUNET_free (tcc); 240 GNUNET_free (tcc);
216 return msize; 241 return msize;
@@ -251,7 +276,13 @@ transmit (struct GNUNET_SERVER_Client *client,
251 { 276 {
252 GNUNET_break (0); 277 GNUNET_break (0);
253 if (GNUNET_YES == end) 278 if (GNUNET_YES == end)
254 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 279 {
280#if DEBUG_DATASTORE
281 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
282 "Disconnecting client.\n");
283#endif
284 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
285 }
255 if (NULL != tc) 286 if (NULL != tc)
256 tc (tc_cls, GNUNET_SYSERR); 287 tc (tc_cls, GNUNET_SYSERR);
257 GNUNET_free (msg); 288 GNUNET_free (msg);
@@ -275,6 +306,13 @@ transmit_status (struct GNUNET_SERVER_Client *client,
275 struct StatusMessage *sm; 306 struct StatusMessage *sm;
276 size_t slen; 307 size_t slen;
277 308
309#if DEBUG_DATASTORE
310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
311 "Transmitting `s' message with value %d and message %s\n",
312 "STATUS",
313 code,
314 msg);
315#endif
278 slen = (msg == NULL) ? 0 : strlen(msg) + 1; 316 slen = (msg == NULL) ? 0 : strlen(msg) + 1;
279 sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen); 317 sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen);
280 sm->header.size = htons(sizeof(struct StatusMessage) + slen); 318 sm->header.size = htons(sizeof(struct StatusMessage) + slen);
@@ -345,6 +383,11 @@ transmit_item (void *cls,
345 if (key == NULL) 383 if (key == NULL)
346 { 384 {
347 /* transmit 'DATA_END' */ 385 /* transmit 'DATA_END' */
386#if DEBUG_DATASTORE
387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
388 "Transmitting `%s' message\n",
389 "DATA_END");
390#endif
348 end = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); 391 end = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
349 end->size = htons(sizeof(struct GNUNET_MessageHeader)); 392 end->size = htons(sizeof(struct GNUNET_MessageHeader));
350 end->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END); 393 end->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END);
@@ -364,6 +407,11 @@ transmit_item (void *cls,
364 dm->uid = GNUNET_htonll(uid); 407 dm->uid = GNUNET_htonll(uid);
365 dm->key = *key; 408 dm->key = *key;
366 memcpy (&dm[1], data, size); 409 memcpy (&dm[1], data, size);
410#if DEBUG_DATASTORE
411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
412 "Transmitting `%s' message\n",
413 "DATA");
414#endif
367 transmit (client, &dm->header, &get_next, next_cls, GNUNET_NO); 415 transmit (client, &dm->header, &get_next, next_cls, GNUNET_NO);
368 return GNUNET_OK; 416 return GNUNET_OK;
369} 417}
@@ -384,7 +432,12 @@ handle_reserve (void *cls,
384 const struct ReserveMessage *msg = (const struct ReserveMessage*) message; 432 const struct ReserveMessage *msg = (const struct ReserveMessage*) message;
385 struct ReservationList *e; 433 struct ReservationList *e;
386 434
387 /* FIXME: check if we have that much space... */ 435#if DEBUG_DATASTORE
436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
437 "Processing `%s' request\n",
438 "RESERVE");
439#endif
440 /* FIXME: check if we have that much space... */
388 e = GNUNET_malloc (sizeof(struct ReservationList)); 441 e = GNUNET_malloc (sizeof(struct ReservationList));
389 e->next = reservations; 442 e->next = reservations;
390 reservations = e; 443 reservations = e;
@@ -414,8 +467,13 @@ handle_release_reserve (void *cls,
414 struct ReservationList *pos; 467 struct ReservationList *pos;
415 struct ReservationList *prev; 468 struct ReservationList *prev;
416 struct ReservationList *next; 469 struct ReservationList *next;
417
418 int rid = ntohl(msg->rid); 470 int rid = ntohl(msg->rid);
471
472#if DEBUG_DATASTORE
473 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
474 "Processing `%s' request\n",
475 "RELEASE_RESERVE");
476#endif
419 next = reservations; 477 next = reservations;
420 prev = NULL; 478 prev = NULL;
421 while (NULL != (pos = next)) 479 while (NULL != (pos = next))
@@ -490,6 +548,11 @@ handle_put (void *cls,
490 int ret; 548 int ret;
491 int rid; 549 int rid;
492 550
551#if DEBUG_DATASTORE
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Processing `%s' request\n",
554 "PUT");
555#endif
493 if (dm == NULL) 556 if (dm == NULL)
494 { 557 {
495 GNUNET_break (0); 558 GNUNET_break (0);
@@ -537,6 +600,11 @@ handle_get (void *cls,
537 const struct GetMessage *msg; 600 const struct GetMessage *msg;
538 uint16_t size; 601 uint16_t size;
539 602
603#if DEBUG_DATASTORE
604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
605 "Processing `%s' request\n",
606 "GET");
607#endif
540 size = ntohs(message->size); 608 size = ntohs(message->size);
541 if ( (size != sizeof(struct GetMessage)) && 609 if ( (size != sizeof(struct GetMessage)) &&
542 (size != sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)) ) 610 (size != sizeof(struct GetMessage) - sizeof(GNUNET_HashCode)) )
@@ -581,6 +649,11 @@ handle_update (void *cls,
581 int ret; 649 int ret;
582 char *emsg; 650 char *emsg;
583 651
652#if DEBUG_DATASTORE
653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
654 "Processing `%s' request\n",
655 "UPDATE");
656#endif
584 msg = (const struct UpdateMessage*) message; 657 msg = (const struct UpdateMessage*) message;
585 emsg = NULL; 658 emsg = NULL;
586 ret = plugin->api->update (plugin->api->cls, 659 ret = plugin->api->update (plugin->api->cls,
@@ -605,7 +678,12 @@ handle_get_random (void *cls,
605 struct GNUNET_SERVER_Client *client, 678 struct GNUNET_SERVER_Client *client,
606 const struct GNUNET_MessageHeader *message) 679 const struct GNUNET_MessageHeader *message)
607{ 680{
608 GNUNET_SERVER_client_drop (client); 681#if DEBUG_DATASTORE
682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
683 "Processing `%s' request\n",
684 "GET_RANDOM");
685#endif
686 GNUNET_SERVER_client_drop (client); // FIXME: WTF?
609 plugin->api->iter_migration_order (plugin->api->cls, 687 plugin->api->iter_migration_order (plugin->api->cls,
610 0, 688 0,
611 &transmit_item, 689 &transmit_item,
@@ -681,6 +759,11 @@ handle_remove (void *cls,
681 GNUNET_HashCode vhash; 759 GNUNET_HashCode vhash;
682 struct RemoveContext *rc; 760 struct RemoveContext *rc;
683 761
762#if DEBUG_DATASTORE
763 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
764 "Processing `%s' request\n",
765 "REMOVE");
766#endif
684 if (dm == NULL) 767 if (dm == NULL)
685 { 768 {
686 GNUNET_break (0); 769 GNUNET_break (0);
@@ -714,6 +797,11 @@ handle_drop (void *cls,
714 struct GNUNET_SERVER_Client *client, 797 struct GNUNET_SERVER_Client *client,
715 const struct GNUNET_MessageHeader *message) 798 const struct GNUNET_MessageHeader *message)
716{ 799{
800#if DEBUG_DATASTORE
801 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
802 "Processing `%s' request\n",
803 "DROP");
804#endif
717 plugin->api->drop (plugin->api->cls); 805 plugin->api->drop (plugin->api->cls);
718 GNUNET_SERVER_receive_done (client, GNUNET_OK); 806 GNUNET_SERVER_receive_done (client, GNUNET_OK);
719} 807}