aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-03-01 11:34:22 +0000
committerBart Polot <bart@net.in.tum.de>2013-03-01 11:34:22 +0000
commit7c511b098a143fad5c3f7c733cda139ea3ae285a (patch)
tree09bce9bcd943e2b0c0df00132babffdab414f360 /src/regex
parent35b6a4449bba6b62831736278a4d6af718bbf424 (diff)
downloadgnunet-7c511b098a143fad5c3f7c733cda139ea3ae285a.tar.gz
gnunet-7c511b098a143fad5c3f7c733cda139ea3ae285a.zip
- fixes, debug
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/regex_dht.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/regex/regex_dht.c b/src/regex/regex_dht.c
index 41991d75e..27fa82a7c 100644
--- a/src/regex/regex_dht.c
+++ b/src/regex/regex_dht.c
@@ -34,7 +34,13 @@
34/* FIXME: OPTION (API, CONFIG) */ 34/* FIXME: OPTION (API, CONFIG) */
35#define DHT_REPLICATION 5 35#define DHT_REPLICATION 5
36#define DHT_TTL GNUNET_TIME_UNIT_HOURS 36#define DHT_TTL GNUNET_TIME_UNIT_HOURS
37#define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE /* | GNUNET_DHT_RO_RECORD_ROUTE*/ 37#define DEBUG_DHT GNUNET_YES
38
39#if DEBUG_DHT
40#define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE | GNUNET_DHT_RO_RECORD_ROUTE
41#else
42#define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
43#endif
38 44
39struct GNUNET_REGEX_announce_handle 45struct GNUNET_REGEX_announce_handle
40{ 46{
@@ -115,7 +121,7 @@ regex_iterator (void *cls,
115 (void) 121 (void)
116 GNUNET_DHT_put (h->dht, key, 122 GNUNET_DHT_put (h->dht, key,
117 DHT_REPLICATION, 123 DHT_REPLICATION,
118 DHT_OPT, 124 DHT_OPT | GNUNET_DHT_RO_RECORD_ROUTE,
119 GNUNET_BLOCK_TYPE_REGEX_ACCEPT, 125 GNUNET_BLOCK_TYPE_REGEX_ACCEPT,
120 size, 126 size,
121 (char *) &block, 127 (char *) &block,
@@ -160,14 +166,14 @@ regex_iterator (void *cls,
160 aux = &aux[len]; 166 aux = &aux[len];
161 } 167 }
162 (void) 168 (void)
163 GNUNET_DHT_put(h->dht, key, 169 GNUNET_DHT_put (h->dht, key,
164 DHT_REPLICATION, 170 DHT_REPLICATION,
165 DHT_OPT, 171 DHT_OPT,
166 GNUNET_BLOCK_TYPE_REGEX, size, 172 GNUNET_BLOCK_TYPE_REGEX, size,
167 (char *) block, 173 (char *) block,
168 GNUNET_TIME_relative_to_absolute (DHT_TTL), 174 GNUNET_TIME_relative_to_absolute (DHT_TTL),
169 DHT_TTL, 175 DHT_TTL,
170 NULL, NULL); 176 NULL, NULL);
171 GNUNET_STATISTICS_update (h->stats, "# regex blocks stored", 177 GNUNET_STATISTICS_update (h->stats, "# regex blocks stored",
172 1, GNUNET_NO); 178 1, GNUNET_NO);
173 GNUNET_STATISTICS_update (h->stats, "# regex block bytes stored", 179 GNUNET_STATISTICS_update (h->stats, "# regex block bytes stored",
@@ -425,10 +431,24 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
425 struct GNUNET_REGEX_search_handle *info = ctx->info; 431 struct GNUNET_REGEX_search_handle *info = ctx->info;
426 void *copy; 432 void *copy;
427 size_t len; 433 size_t len;
434 char *datastore;
435
436#if DEBUG_DHT
437 if (NULL != put_path && 0 != put_path_length)
438 {
439 datastore = GNUNET_strdup (GNUNET_i2s (&put_path[put_path_length - 1]));
440 }
441 else
442 {
443 GNUNET_asprintf (&datastore, "?? %u/%u", put_path_length, get_path_length);
444 }
445#else
446 datastore = GNUNET_strdup ("N/A");
447#endif
428 448
429 LOG (GNUNET_ERROR_TYPE_DEBUG, "DHT GET STRING RETURNED RESULTS\n"); 449 LOG (GNUNET_ERROR_TYPE_INFO, " DHT GET result for %s (%s) at %s\n",
430 LOG (GNUNET_ERROR_TYPE_INFO, " for: %s\n", ctx->info->description); 450 GNUNET_h2s (key), ctx->info->description, datastore);
431 LOG (GNUNET_ERROR_TYPE_INFO, " key: %s\n", GNUNET_h2s (key)); 451 GNUNET_free (datastore);
432 452
433 copy = GNUNET_malloc (size); 453 copy = GNUNET_malloc (size);
434 memcpy (copy, data, size); 454 memcpy (copy, data, size);