diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-01-21 13:38:03 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-01-21 13:38:03 +0000 |
commit | 174726a0e83bc67150379b81e4e201afbde412e6 (patch) | |
tree | 537c9763bde29087c2e3f2a8f8f47a2b8a628590 /src | |
parent | 302bbf76242ccdbafe2877602a54fce5d05b0f55 (diff) | |
download | gnunet-174726a0e83bc67150379b81e4e201afbde412e6.tar.gz gnunet-174726a0e83bc67150379b81e4e201afbde412e6.zip |
- debug messages, fixed assertions
Diffstat (limited to 'src')
-rw-r--r-- | src/regex/regex_dht.c | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/src/regex/regex_dht.c b/src/regex/regex_dht.c index ce9d4e2a1..12681f503 100644 --- a/src/regex/regex_dht.c +++ b/src/regex/regex_dht.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #include "gnunet_dht_service.h" | 29 | #include "gnunet_dht_service.h" |
30 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
31 | 31 | ||
32 | #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__) | ||
33 | |||
32 | #define DHT_REPLICATION 5 | 34 | #define DHT_REPLICATION 5 |
33 | #define DHT_TTL GNUNET_TIME_UNIT_HOURS | 35 | #define DHT_TTL GNUNET_TIME_UNIT_HOURS |
34 | 36 | ||
@@ -89,24 +91,20 @@ regex_iterator (void *cls, | |||
89 | unsigned int offset; | 91 | unsigned int offset; |
90 | char *aux; | 92 | char *aux; |
91 | 93 | ||
92 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 94 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
93 | " regex dht put for state %s\n", | 95 | " regex dht put for state %s\n", |
94 | GNUNET_h2s (key)); | 96 | GNUNET_h2s (key)); |
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 97 | LOG (GNUNET_ERROR_TYPE_DEBUG, " proof: %s\n", proof); |
96 | " proof: %s\n", | 98 | LOG (GNUNET_ERROR_TYPE_DEBUG, " num edges: %u\n", num_edges); |
97 | proof); | ||
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
99 | " num edges: %u\n", | ||
100 | num_edges); | ||
101 | 99 | ||
102 | opt = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; | 100 | opt = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; |
103 | if (GNUNET_YES == accepting) | 101 | if (GNUNET_YES == accepting) |
104 | { | 102 | { |
105 | struct RegexAccept block; | 103 | struct RegexAccept block; |
106 | 104 | ||
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 105 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
108 | " state %s is accepting, putting own id\n", | 106 | " state %s is accepting, putting own id\n", |
109 | GNUNET_h2s(key)); | 107 | GNUNET_h2s(key)); |
110 | size = sizeof (block); | 108 | size = sizeof (block); |
111 | block.key = *key; | 109 | block.key = *key; |
112 | block.id = *(h->id); | 110 | block.id = *(h->id); |
@@ -144,10 +142,8 @@ regex_iterator (void *cls, | |||
144 | */ | 142 | */ |
145 | for (i = 0; i < num_edges; i++) | 143 | for (i = 0; i < num_edges; i++) |
146 | { | 144 | { |
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 145 | LOG (GNUNET_ERROR_TYPE_DEBUG, " edge %s towards %s\n", |
148 | " edge %s towards %s\n", | 146 | edges[i].label, GNUNET_h2s(&edges[i].destination)); |
149 | edges[i].label, | ||
150 | GNUNET_h2s(&edges[i].destination)); | ||
151 | 147 | ||
152 | /* aux points at the end of the last block */ | 148 | /* aux points at the end of the last block */ |
153 | len = strlen (edges[i].label); | 149 | len = strlen (edges[i].label); |
@@ -190,7 +186,7 @@ GNUNET_REGEX_announce (struct GNUNET_DHT_Handle *dht, | |||
190 | { | 186 | { |
191 | struct GNUNET_REGEX_announce_handle *h; | 187 | struct GNUNET_REGEX_announce_handle *h; |
192 | 188 | ||
193 | GNUNET_assert (NULL == dht); | 189 | GNUNET_assert (NULL != dht); |
194 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_announce_handle)); | 190 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_announce_handle)); |
195 | h->regex = regex; | 191 | h->regex = regex; |
196 | h->dht = dht; | 192 | h->dht = dht; |
@@ -348,8 +344,8 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
348 | struct RegexSearchContext *ctx = cls; | 344 | struct RegexSearchContext *ctx = cls; |
349 | struct GNUNET_REGEX_search_handle *info = ctx->info; | 345 | struct GNUNET_REGEX_search_handle *info = ctx->info; |
350 | 346 | ||
351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got regex results from DHT!\n"); | 347 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Got regex results from DHT!\n"); |
352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " for %s\n", info->description); | 348 | LOG (GNUNET_ERROR_TYPE_DEBUG, " for %s\n", info->description); |
353 | 349 | ||
354 | GNUNET_STATISTICS_update (info->stats, "# regex accepting blocks found", | 350 | GNUNET_STATISTICS_update (info->stats, "# regex accepting blocks found", |
355 | 1, GNUNET_NO); | 351 | 1, GNUNET_NO); |
@@ -377,7 +373,7 @@ regex_find_path (const struct GNUNET_HashCode *key, | |||
377 | { | 373 | { |
378 | struct GNUNET_DHT_GetHandle *get_h; | 374 | struct GNUNET_DHT_GetHandle *get_h; |
379 | 375 | ||
380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found peer by service\n"); | 376 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found peer by service\n"); |
381 | get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */ | 377 | get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */ |
382 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */ | 378 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */ |
383 | key, /* key to search */ | 379 | key, /* key to search */ |
@@ -428,10 +424,8 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
428 | void *copy; | 424 | void *copy; |
429 | size_t len; | 425 | size_t len; |
430 | 426 | ||
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | LOG (GNUNET_ERROR_TYPE_DEBUG, "DHT GET STRING RETURNED RESULTS\n"); |
432 | "DHT GET STRING RETURNED RESULTS\n"); | 428 | LOG (GNUNET_ERROR_TYPE_DEBUG, " key: %s\n", GNUNET_h2s (key)); |
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
434 | " key: %s\n", GNUNET_h2s (key)); | ||
435 | 429 | ||
436 | copy = GNUNET_malloc (size); | 430 | copy = GNUNET_malloc (size); |
437 | memcpy (copy, data, size); | 431 | memcpy (copy, data, size); |
@@ -459,7 +453,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
459 | } | 453 | } |
460 | else | 454 | else |
461 | { | 455 | { |
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " block not accepting!\n"); | 456 | LOG (GNUNET_ERROR_TYPE_DEBUG, " block not accepting!\n"); |
463 | // FIXME REGEX this block not successful, wait for more? start timeout? | 457 | // FIXME REGEX this block not successful, wait for more? start timeout? |
464 | } | 458 | } |
465 | return; | 459 | return; |
@@ -491,15 +485,15 @@ regex_result_iterator (void *cls, | |||
491 | if (GNUNET_YES == ntohl(block->accepting) && | 485 | if (GNUNET_YES == ntohl(block->accepting) && |
492 | ctx->position == strlen (ctx->info->description)) | 486 | ctx->position == strlen (ctx->info->description)) |
493 | { | 487 | { |
494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Found accepting known block\n"); | 488 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Found accepting known block\n"); |
495 | regex_find_path (key, ctx); | 489 | regex_find_path (key, ctx); |
496 | return GNUNET_YES; // We found an accept state! | 490 | return GNUNET_YES; // We found an accept state! |
497 | } | 491 | } |
498 | else | 492 | else |
499 | { | 493 | { |
500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* %u, %u, [%u]\n", | 494 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* %u, %u, [%u]\n", |
501 | ctx->position, strlen(ctx->info->description), | 495 | ctx->position, strlen(ctx->info->description), |
502 | ntohl(block->accepting)); | 496 | ntohl(block->accepting)); |
503 | 497 | ||
504 | } | 498 | } |
505 | regex_next_edge(block, SIZE_MAX, ctx); | 499 | regex_next_edge(block, SIZE_MAX, ctx); |
@@ -535,39 +529,39 @@ regex_edge_iterator (void *cls, | |||
535 | GNUNET_STATISTICS_update (info->stats, "# regex edges iterated", | 529 | GNUNET_STATISTICS_update (info->stats, "# regex edges iterated", |
536 | 1, GNUNET_NO); | 530 | 1, GNUNET_NO); |
537 | 531 | ||
538 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Start of regex edge iterator\n"); | 532 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Start of regex edge iterator\n"); |
539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* descr : %s\n", info->description); | 533 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* descr : %s\n", info->description); |
540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* posit : %u\n", ctx->position); | 534 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* posit : %u\n", ctx->position); |
541 | current = &info->description[ctx->position]; | 535 | current = &info->description[ctx->position]; |
542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* currt : %s\n", current); | 536 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* currt : %s\n", current); |
543 | current_len = strlen (info->description) - ctx->position; | 537 | current_len = strlen (info->description) - ctx->position; |
544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* ctlen : %u\n", current_len); | 538 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* ctlen : %u\n", current_len); |
545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* tklen : %u\n", len); | 539 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* tklen : %u\n", len); |
546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* token : %.*s\n", len, token); | 540 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* token : %.*s\n", len, token); |
547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* nextk : %s\n", GNUNET_h2s(key)); | 541 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* nextk : %s\n", GNUNET_h2s(key)); |
548 | if (len > current_len) | 542 | if (len > current_len) |
549 | { | 543 | { |
550 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token too long, END\n"); | 544 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Token too long, END\n"); |
551 | return GNUNET_YES; // Token too long, wont match | 545 | return GNUNET_YES; // Token too long, wont match |
552 | } | 546 | } |
553 | if (0 != strncmp (current, token, len)) | 547 | if (0 != strncmp (current, token, len)) |
554 | { | 548 | { |
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token doesn't match, END\n"); | 549 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Token doesn't match, END\n"); |
556 | return GNUNET_YES; // Token doesn't match | 550 | return GNUNET_YES; // Token doesn't match |
557 | } | 551 | } |
558 | 552 | ||
559 | if (len > ctx->longest_match) | 553 | if (len > ctx->longest_match) |
560 | { | 554 | { |
561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token is longer, KEEP\n"); | 555 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Token is longer, KEEP\n"); |
562 | ctx->longest_match = len; | 556 | ctx->longest_match = len; |
563 | ctx->hash = *key; | 557 | ctx->hash = *key; |
564 | } | 558 | } |
565 | else | 559 | else |
566 | { | 560 | { |
567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token is not longer, IGNORE\n"); | 561 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Token is not longer, IGNORE\n"); |
568 | } | 562 | } |
569 | 563 | ||
570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n"); | 564 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n"); |
571 | return GNUNET_YES; | 565 | return GNUNET_YES; |
572 | } | 566 | } |
573 | 567 | ||
@@ -612,7 +606,7 @@ regex_next_edge (const struct RegexBlock *block, | |||
612 | if (GNUNET_YES == | 606 | if (GNUNET_YES == |
613 | GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, &ctx->hash)) | 607 | GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, &ctx->hash)) |
614 | { | 608 | { |
615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* GET running, END\n"); | 609 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* GET running, END\n"); |
616 | GNUNET_CONTAINER_multihashmap_get_multiple (info->dht_get_results, | 610 | GNUNET_CONTAINER_multihashmap_get_multiple (info->dht_get_results, |
617 | &ctx->hash, | 611 | &ctx->hash, |
618 | ®ex_result_iterator, | 612 | ®ex_result_iterator, |
@@ -658,7 +652,9 @@ GNUNET_REGEX_search (struct GNUNET_DHT_Handle *dht, | |||
658 | { | 652 | { |
659 | struct GNUNET_REGEX_search_handle *h; | 653 | struct GNUNET_REGEX_search_handle *h; |
660 | 654 | ||
661 | GNUNET_assert (NULL == dht); | 655 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_REGEX_search: %s\n", string); |
656 | GNUNET_assert (NULL != dht); | ||
657 | GNUNET_assert (NULL != callback); | ||
662 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_search_handle)); | 658 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_search_handle)); |
663 | h->dht = dht; | 659 | h->dht = dht; |
664 | h->description = GNUNET_strdup (string); | 660 | h->description = GNUNET_strdup (string); |