aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-19 09:10:43 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-19 09:10:43 +0000
commitc6689c4e233c663f79cf00449e70ce3c56653f1c (patch)
treed5f3218032ef23010d28b8f4c67bc104f0239956 /src/datastore
parent8f73677b530811bf3e2e4c66802958b38abfccb9 (diff)
downloadgnunet-c6689c4e233c663f79cf00449e70ce3c56653f1c.tar.gz
gnunet-c6689c4e233c663f79cf00449e70ce3c56653f1c.zip
debug messages
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c40
-rw-r--r--src/datastore/gnunet-service-datastore.c100
-rw-r--r--src/datastore/test_datastore_api.c46
3 files changed, 173 insertions, 13 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index c67b7556a..4fc719629 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -215,6 +215,12 @@ with_status_response_handler (void *cls,
215 } 215 }
216 } 216 }
217 h->response_proc = NULL; 217 h->response_proc = NULL;
218#if VERBOSE
219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
220 "Received status %d/%s\n",
221 status,
222 emsg);
223#endif
218 cont (h->response_proc_cls, 224 cont (h->response_proc_cls,
219 status, 225 status,
220 emsg); 226 emsg);
@@ -251,6 +257,11 @@ transmit_get_status (void *cls,
251 } 257 }
252 GNUNET_assert (h->message_size <= size); 258 GNUNET_assert (h->message_size <= size);
253 memcpy (buf, &h[1], h->message_size); 259 memcpy (buf, &h[1], h->message_size);
260#if VERBOSE
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "Transmitted %u byte message to datastore service, now waiting for status.\n",
263 h->message_size);
264#endif
254 h->message_size = 0; 265 h->message_size = 0;
255 GNUNET_CLIENT_receive (h->client, 266 GNUNET_CLIENT_receive (h->client,
256 &with_status_response_handler, 267 &with_status_response_handler,
@@ -284,6 +295,12 @@ transmit_for_status (struct GNUNET_DATASTORE_Handle *h,
284 295
285 hdr = (const struct GNUNET_MessageHeader*) &h[1]; 296 hdr = (const struct GNUNET_MessageHeader*) &h[1];
286 msize = ntohs(hdr->size); 297 msize = ntohs(hdr->size);
298#if VERBOSE
299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
300 "Transmitting %u byte message of type %u to datastore service\n",
301 msize,
302 ntohs(hdr->type));
303#endif
287 GNUNET_assert (h->response_proc == NULL); 304 GNUNET_assert (h->response_proc == NULL);
288 h->response_proc = cont; 305 h->response_proc = cont;
289 h->response_proc_cls = cont_cls; 306 h->response_proc_cls = cont_cls;
@@ -485,6 +502,10 @@ with_result_response_handler (void *cls,
485 { 502 {
486 GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader)); 503 GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
487 h->response_proc = NULL; 504 h->response_proc = NULL;
505#if VERBOSE
506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
507 "Received end of result set\n");
508#endif
488 cont (h->response_proc_cls, 509 cont (h->response_proc_cls,
489 NULL, 0, NULL, 0, 0, 0, zero, 0); 510 NULL, 0, NULL, 0, 0, 0, zero, 0);
490 return; 511 return;
@@ -512,6 +533,14 @@ with_result_response_handler (void *cls,
512 NULL, 0, NULL, 0, 0, 0, zero, 0); 533 NULL, 0, NULL, 0, 0, 0, zero, 0);
513 return; 534 return;
514 } 535 }
536#if VERBOSE
537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
538 "Received result %llu with type %u and size %u with key %s\n",
539 (unsigned long long) GNUNET_ntohll(dm->uid),
540 ntohl(dm->type),
541 msize,
542 GNUNET_h2s(&dm->key));
543#endif
515 cont (h->response_proc_cls, 544 cont (h->response_proc_cls,
516 &dm->key, 545 &dm->key,
517 msize, 546 msize,
@@ -558,6 +587,11 @@ transmit_get_result (void *cls,
558 } 587 }
559 GNUNET_assert (h->message_size <= size); 588 GNUNET_assert (h->message_size <= size);
560 memcpy (buf, &h[1], h->message_size); 589 memcpy (buf, &h[1], h->message_size);
590#if VERBOSE
591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592 "Transmitted %u byte message to datastore service, now waiting for result.\n",
593 h->message_size);
594#endif
561 h->message_size = 0; 595 h->message_size = 0;
562 GNUNET_CLIENT_receive (h->client, 596 GNUNET_CLIENT_receive (h->client,
563 &with_result_response_handler, 597 &with_result_response_handler,
@@ -592,6 +626,12 @@ transmit_for_result (struct GNUNET_DATASTORE_Handle *h,
592 626
593 hdr = (const struct GNUNET_MessageHeader*) &h[1]; 627 hdr = (const struct GNUNET_MessageHeader*) &h[1];
594 msize = ntohs(hdr->size); 628 msize = ntohs(hdr->size);
629#if VERBOSE
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
631 "Transmitting %u byte message of type %u to datastore service\n",
632 msize,
633 ntohs(hdr->type));
634#endif
595 GNUNET_assert (h->response_proc == NULL); 635 GNUNET_assert (h->response_proc == NULL);
596 h->response_proc = cont; 636 h->response_proc = cont;
597 h->response_proc_cls = cont_cls; 637 h->response_proc_cls = cont_cls;
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}
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index afc36b708..e9545bbf1 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -33,11 +33,15 @@
33#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
34#include "gnunet_datastore_service.h" 34#include "gnunet_datastore_service.h"
35 35
36#define VERBOSE GNUNET_YES
37
36/** 38/**
37 * How long until we give up on transmitting the message? 39 * How long until we give up on transmitting the message?
38 */ 40 */
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 41#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
40 42
43#define ITERATIONS 256
44
41static struct GNUNET_DATASTORE_Handle *datastore; 45static struct GNUNET_DATASTORE_Handle *datastore;
42 46
43static struct GNUNET_TIME_Absolute now; 47static struct GNUNET_TIME_Absolute now;
@@ -250,7 +254,13 @@ run_continuation (void *cls,
250 switch (crc->phase) 254 switch (crc->phase)
251 { 255 {
252 case RP_PUT: 256 case RP_PUT:
253 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 257#if VERBOSE
258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
259 "Executing `%s' number %u\n",
260 "PUT",
261 crc->i);
262#endif
263 memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
254 GNUNET_DATASTORE_put (datastore, 264 GNUNET_DATASTORE_put (datastore,
255 0, 265 0,
256 &crc->key, 266 &crc->key,
@@ -264,12 +274,18 @@ run_continuation (void *cls,
264 &check_success, 274 &check_success,
265 crc); 275 crc);
266 crc->i++; 276 crc->i++;
267 if (crc->i == 256) 277 if (crc->i == ITERATIONS)
268 crc->phase = RP_GET; 278 crc->phase = RP_GET;
269 break; 279 break;
270 case RP_GET: 280 case RP_GET:
271 crc->i--; 281 crc->i--;
272 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 282#if VERBOSE
283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
284 "Executing `%s' number %u\n",
285 "GET",
286 crc->i);
287#endif
288 memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
273 GNUNET_DATASTORE_get (datastore, 289 GNUNET_DATASTORE_get (datastore,
274 &crc->key, 290 &crc->key,
275 get_type (crc->i), 291 get_type (crc->i),
@@ -279,12 +295,18 @@ run_continuation (void *cls,
279 if (crc->i == 0) 295 if (crc->i == 0)
280 { 296 {
281 crc->phase = RP_DEL; 297 crc->phase = RP_DEL;
282 crc->i = 256; 298 crc->i = ITERATIONS;
283 } 299 }
284 break; 300 break;
285 case RP_DEL: 301 case RP_DEL:
286 crc->i--; 302 crc->i--;
287 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 303#if VERBOSE
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
305 "Executing `%s' number %u\n",
306 "DEL",
307 crc->i);
308#endif
309 memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
288 GNUNET_DATASTORE_get (datastore, 310 GNUNET_DATASTORE_get (datastore,
289 &crc->key, 311 &crc->key,
290 get_type (crc->i), 312 get_type (crc->i),
@@ -294,12 +316,18 @@ run_continuation (void *cls,
294 if (crc->i == 0) 316 if (crc->i == 0)
295 { 317 {
296 crc->phase = RP_DELVALIDATE; 318 crc->phase = RP_DELVALIDATE;
297 crc->i = 256; 319 crc->i = ITERATIONS;
298 } 320 }
299 break; 321 break;
300 case RP_DELVALIDATE: 322 case RP_DELVALIDATE:
301 crc->i--; 323 crc->i--;
302 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 324#if VERBOSE
325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
326 "Executing `%s' number %u\n",
327 "DEL-VALIDATE",
328 crc->i);
329#endif
330 memset (&crc->key, ITERATIONS - crc->i, sizeof (GNUNET_HashCode));
303 GNUNET_DATASTORE_get (datastore, 331 GNUNET_DATASTORE_get (datastore,
304 &crc->key, 332 &crc->key,
305 get_type (crc->i), 333 get_type (crc->i),
@@ -315,6 +343,10 @@ run_continuation (void *cls,
315 /* check update */ 343 /* check update */
316 /* test multiple results */ 344 /* test multiple results */
317 case RP_DONE: 345 case RP_DONE:
346#if VERBOSE
347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
348 "Finished, disconnecting\n");
349#endif
318 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); 350 GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES);
319 ok = 0; 351 ok = 0;
320 } 352 }