diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-22 13:26:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-22 13:26:36 +0000 |
commit | bad29fd9a1cc3b1c7df7b992212568918c961b52 (patch) | |
tree | 692be9fda2a949f844690e360ce9d6d5f50f8916 /src/regex/regex_internal_dht.c | |
parent | 7b636c9e74039f14b25e70d1050432d9782efef9 (diff) | |
download | gnunet-bad29fd9a1cc3b1c7df7b992212568918c961b52.tar.gz gnunet-bad29fd9a1cc3b1c7df7b992212568918c961b52.zip |
add logging and in particular checks to make sure no '.' wildcards are during initial transitions of the DFA
Diffstat (limited to 'src/regex/regex_internal_dht.c')
-rw-r--r-- | src/regex/regex_internal_dht.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index 7fa15ba45..f11a39589 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2012 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2012, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -34,8 +34,19 @@ | |||
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__) | 35 | #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__) |
36 | 36 | ||
37 | /** | ||
38 | * DHT replication level to use. | ||
39 | */ | ||
37 | #define DHT_REPLICATION 5 | 40 | #define DHT_REPLICATION 5 |
41 | |||
42 | /** | ||
43 | * DHT record lifetime to use. | ||
44 | */ | ||
38 | #define DHT_TTL GNUNET_TIME_UNIT_HOURS | 45 | #define DHT_TTL GNUNET_TIME_UNIT_HOURS |
46 | |||
47 | /** | ||
48 | * DHT options to set. | ||
49 | */ | ||
39 | #define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE | 50 | #define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE |
40 | 51 | ||
41 | 52 | ||
@@ -57,7 +68,7 @@ struct REGEX_INTERNAL_Announcement | |||
57 | /** | 68 | /** |
58 | * Automaton representation of the regex (expensive to build). | 69 | * Automaton representation of the regex (expensive to build). |
59 | */ | 70 | */ |
60 | struct REGEX_INTERNAL_Automaton* dfa; | 71 | struct REGEX_INTERNAL_Automaton *dfa; |
61 | 72 | ||
62 | /** | 73 | /** |
63 | * Our private key. | 74 | * Our private key. |
@@ -77,7 +88,7 @@ struct REGEX_INTERNAL_Announcement | |||
77 | * @param cls closure. | 88 | * @param cls closure. |
78 | * @param key hash for current state. | 89 | * @param key hash for current state. |
79 | * @param proof proof for current state. | 90 | * @param proof proof for current state. |
80 | * @param accepting GNUNET_YES if this is an accepting state, GNUNET_NO if not. | 91 | * @param accepting #GNUNET_YES if this is an accepting state, #GNUNET_NO if not. |
81 | * @param num_edges number of edges leaving current state. | 92 | * @param num_edges number of edges leaving current state. |
82 | * @param edges edges leaving current state. | 93 | * @param edges edges leaving current state. |
83 | */ | 94 | */ |
@@ -95,17 +106,17 @@ regex_iterator (void *cls, | |||
95 | unsigned int i; | 106 | unsigned int i; |
96 | 107 | ||
97 | LOG (GNUNET_ERROR_TYPE_INFO, | 108 | LOG (GNUNET_ERROR_TYPE_INFO, |
98 | "DHT PUT for state %s with proof `%s' and %u edges\n", | 109 | "DHT PUT for state %s with proof `%s' and %u edges:\n", |
99 | GNUNET_h2s (key), | 110 | GNUNET_h2s (key), |
100 | proof, | 111 | proof, |
101 | num_edges); | 112 | num_edges); |
102 | for (i = 0; i < num_edges; i++) | 113 | for (i = 0; i < num_edges; i++) |
103 | { | 114 | { |
104 | LOG (GNUNET_ERROR_TYPE_INFO, | 115 | LOG (GNUNET_ERROR_TYPE_INFO, |
105 | " edge %s towards %s (%s)\n", | 116 | "Edge %u `%s' towards %s\n", |
117 | i, | ||
106 | edges[i].label, | 118 | edges[i].label, |
107 | GNUNET_h2s (&edges[i].destination), | 119 | GNUNET_h2s (&edges[i].destination)); |
108 | proof); | ||
109 | } | 120 | } |
110 | if (GNUNET_YES == accepting) | 121 | if (GNUNET_YES == accepting) |
111 | { | 122 | { |
@@ -156,9 +167,11 @@ regex_iterator (void *cls, | |||
156 | GNUNET_TIME_relative_to_absolute (DHT_TTL), | 167 | GNUNET_TIME_relative_to_absolute (DHT_TTL), |
157 | DHT_TTL, | 168 | DHT_TTL, |
158 | NULL, NULL); | 169 | NULL, NULL); |
159 | GNUNET_STATISTICS_update (h->stats, "# regex blocks stored", | 170 | GNUNET_STATISTICS_update (h->stats, |
171 | "# regex blocks stored", | ||
160 | 1, GNUNET_NO); | 172 | 1, GNUNET_NO); |
161 | GNUNET_STATISTICS_update (h->stats, "# regex block bytes stored", | 173 | GNUNET_STATISTICS_update (h->stats, |
174 | "# regex block bytes stored", | ||
162 | size, GNUNET_NO); | 175 | size, GNUNET_NO); |
163 | GNUNET_free (block); | 176 | GNUNET_free (block); |
164 | } | 177 | } |
@@ -166,16 +179,15 @@ regex_iterator (void *cls, | |||
166 | 179 | ||
167 | /** | 180 | /** |
168 | * Announce a regular expression: put all states of the automaton in the DHT. | 181 | * Announce a regular expression: put all states of the automaton in the DHT. |
169 | * Does not free resources, must call REGEX_INTERNAL_announce_cancel for that. | 182 | * Does not free resources, must call #REGEX_INTERNAL_announce_cancel() for that. |
170 | * | 183 | * |
171 | * @param dht An existing and valid DHT service handle. CANNOT be NULL. | 184 | * @param dht An existing and valid DHT service handle. CANNOT be NULL. |
172 | * @param priv our private key, must remain valid until the announcement is cancelled | 185 | * @param priv our private key, must remain valid until the announcement is cancelled |
173 | * @param regex Regular expression to announce. | 186 | * @param regex Regular expression to announce. |
174 | * @param compression How many characters per edge can we squeeze? | 187 | * @param compression How many characters per edge can we squeeze? |
175 | * @param stats Optional statistics handle to report usage. Can be NULL. | 188 | * @param stats Optional statistics handle to report usage. Can be NULL. |
176 | * | ||
177 | * @return Handle to reuse o free cached resources. | 189 | * @return Handle to reuse o free cached resources. |
178 | * Must be freed by calling REGEX_INTERNAL_announce_cancel. | 190 | * Must be freed by calling #REGEX_INTERNAL_announce_cancel(). |
179 | */ | 191 | */ |
180 | struct REGEX_INTERNAL_Announcement * | 192 | struct REGEX_INTERNAL_Announcement * |
181 | REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | 193 | REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, |
@@ -202,7 +214,7 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | |||
202 | * Announce again a regular expression previously announced. | 214 | * Announce again a regular expression previously announced. |
203 | * Does use caching to speed up process. | 215 | * Does use caching to speed up process. |
204 | * | 216 | * |
205 | * @param h Handle returned by a previous REGEX_INTERNAL_announce call. | 217 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce call(). |
206 | */ | 218 | */ |
207 | void | 219 | void |
208 | REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | 220 | REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) |
@@ -211,7 +223,9 @@ REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | |||
211 | LOG (GNUNET_ERROR_TYPE_INFO, | 223 | LOG (GNUNET_ERROR_TYPE_INFO, |
212 | "REGEX_INTERNAL_reannounce: %s\n", | 224 | "REGEX_INTERNAL_reannounce: %s\n", |
213 | h->regex); | 225 | h->regex); |
214 | REGEX_INTERNAL_iterate_reachable_edges (h->dfa, ®ex_iterator, h); | 226 | REGEX_INTERNAL_iterate_reachable_edges (h->dfa, |
227 | ®ex_iterator, | ||
228 | h); | ||
215 | } | 229 | } |
216 | 230 | ||
217 | 231 | ||
@@ -219,7 +233,7 @@ REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | |||
219 | * Clear all cached data used by a regex announce. | 233 | * Clear all cached data used by a regex announce. |
220 | * Does not close DHT connection. | 234 | * Does not close DHT connection. |
221 | * | 235 | * |
222 | * @param h Handle returned by a previous REGEX_INTERNAL_announce call. | 236 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call. |
223 | */ | 237 | */ |
224 | void | 238 | void |
225 | REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h) | 239 | REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h) |