aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/regex_profiler_infiniband.conf18
-rw-r--r--src/mesh/gnunet-daemon-regexprofiler.c173
-rw-r--r--src/mesh/gnunet-regex-profiler.c125
-rw-r--r--src/mesh/gnunet-service-mesh.c21
4 files changed, 231 insertions, 106 deletions
diff --git a/contrib/regex_profiler_infiniband.conf b/contrib/regex_profiler_infiniband.conf
index ad0ae4090..556aeccfb 100644
--- a/contrib/regex_profiler_infiniband.conf
+++ b/contrib/regex_profiler_infiniband.conf
@@ -3,20 +3,21 @@ AUTOSTART = NO
3PORT = 11999 3PORT = 11999
4ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 4ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
5HOSTNAME = localhost 5HOSTNAME = localhost
6MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10 6MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 20
7MAX_PARALLEL_OPERATIONS = 1000 7MAX_PARALLEL_OPERATIONS = 1000
8MAX_PARALLEL_SERVICE_CONNECTIONS = 1000 8MAX_PARALLEL_SERVICE_CONNECTIONS = 1000
9MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 50 9MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 50
10 10
11[regexprofiler] 11[regexprofiler]
12BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-service-regexprofiler 12BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-daemon-regexprofiler
13REGEX_PREFIX = "GNVPN-0001-PAD" 13REGEX_PREFIX = "GNVPN-0001-PAD"
14ANNOUNCE_DELAY = 500 ms
14 15
15[mesh] 16[mesh]
16AUTOSTART = YES 17AUTOSTART = YES
17ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 18ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
18APP_ANNOUNCE_TIME = 30 s 19APP_ANNOUNCE_TIME = 60 s
19ID_ANNOUNCE_TIME = 30 s 20ID_ANNOUNCE_TIME = 60 s
20CONNECT_TIMEOUT = 30 s 21CONNECT_TIMEOUT = 30 s
21PORT = 12001 22PORT = 12001
22DHT_REPLICATION_LEVEL = 10 23DHT_REPLICATION_LEVEL = 10
@@ -26,11 +27,11 @@ AUTOSTART = YES
26ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 27ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
27#PORT = 12002 28#PORT = 12002
28HOSTNAME = localhost 29HOSTNAME = localhost
29DISABLE_TRY_CONNECT = YES 30DISABLE_TRY_CONNECT = NO
30 31
31[dhtcache] 32[dhtcache]
32DATABASE = sqlite 33DATABASE = sqlite
33QUOTA = 10 MB 34QUOTA = 1000 MB
34 35
35[arm] 36[arm]
36DEFAULTSERVICES = core mesh dht statistics regexprofiler 37DEFAULTSERVICES = core mesh dht statistics regexprofiler
@@ -42,8 +43,8 @@ AUTOSTART = NO
42[resolver] 43[resolver]
43AUTOSTART = NO 44AUTOSTART = NO
44 45
45[block] 46#[block]
46plugins = dht mesh 47#plugins = dht mesh
47 48
48[transport] 49[transport]
49AUTOSTART = YES 50AUTOSTART = YES
@@ -102,3 +103,4 @@ AUTOSTART = NO
102 103
103[nat] 104[nat]
104RETURN_LOCAL_ADDRESSES = YES 105RETURN_LOCAL_ADDRESSES = YES
106DISABLEV6 = YES
diff --git a/src/mesh/gnunet-daemon-regexprofiler.c b/src/mesh/gnunet-daemon-regexprofiler.c
index 2503382c0..4075dd032 100644
--- a/src/mesh/gnunet-daemon-regexprofiler.c
+++ b/src/mesh/gnunet-daemon-regexprofiler.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file mesh/gnunet-daemon-regexprofiler.c 22 * @file mesh/gnunet-daemon-regexprofiler.c
23 * @brief service that uses mesh to announce a regular expression. Used in 23 * @brief daemon that uses mesh to announce a regular expression. Used in
24 * conjunction with gnunet-regex-profiler to announce regexes on serveral peers 24 * conjunction with gnunet-regex-profiler to announce regexes on serveral peers
25 * without the need to explicitly connect to the mesh service running on the 25 * without the need to explicitly connect to the mesh service running on the
26 * peer from within the profiler. 26 * peer from within the profiler.
@@ -71,6 +71,21 @@ static char * policy_filename;
71 */ 71 */
72static char * regex_prefix; 72static char * regex_prefix;
73 73
74/**
75 * Time to wait between announcing regexes.
76 */
77static struct GNUNET_TIME_Relative announce_delay = { 500 };
78
79/**
80 * Regexes to announce read from 'policy_filename'.
81 */
82static char **regexes;
83
84/**
85 * Number of regexes read from 'policy_filename'.
86 */
87static unsigned int num_regexes;
88
74 89
75/** 90/**
76 * Task run during shutdown. 91 * Task run during shutdown.
@@ -121,6 +136,93 @@ announce_regex (const char * regex)
121 136
122 137
123/** 138/**
139 * Task run to iterate over all policies and announce them using mesh.
140 *
141 * @param cls unused
142 * @param tc unused
143 */
144static void
145do_announce_policies (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
146{
147 static unsigned int num_rx_announced;
148
149 announce_regex (regexes[num_rx_announced]);
150
151 if (++num_rx_announced < num_regexes)
152 {
153 GNUNET_SCHEDULER_add_delayed (announce_delay, &do_announce_policies, NULL);
154 return;
155 }
156
157 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All regexes announced.\n");
158}
159
160/**
161 * Load regular expressions from filename into 'rxes' array. Array needs to be freed.
162 *
163 * @param filename filename of the file containing the regexes, one per line.
164 * @param rxes array with all regexes, needs to be freed.
165 */
166static unsigned int
167load_regexes (const char *filename, char ***rxes)
168{
169 char *data;
170 char *buf;
171 uint64_t filesize;
172 unsigned int offset;
173 unsigned int rx_cnt;
174 unsigned int i;
175
176 if (GNUNET_YES != GNUNET_DISK_file_test (policy_filename))
177 {
178 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
179 "Could not find policy file %s\n", policy_filename);
180 return 0;
181 }
182 if (GNUNET_OK != GNUNET_DISK_file_size (policy_filename, &filesize, GNUNET_YES, GNUNET_YES))
183 filesize = 0;
184 if (0 == filesize)
185 {
186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Policy file %s is empty.\n", policy_filename);
187 return 0;
188 }
189 data = GNUNET_malloc (filesize);
190 if (filesize != GNUNET_DISK_fn_read (policy_filename, data, filesize))
191 {
192 GNUNET_free (data);
193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read policy file %s.\n",
194 policy_filename);
195 return 0;
196 }
197 buf = data;
198 offset = 0;
199 rx_cnt = 0;
200 while (offset < (filesize - 1))
201 {
202 offset++;
203 if (((data[offset] == '\n')) && (buf != &data[offset]))
204 {
205 data[offset] = '\0';
206 rx_cnt++;
207 buf = &data[offset + 1];
208 }
209 else if ((data[offset] == '\n') || (data[offset] == '\0'))
210 buf = &data[offset + 1];
211 }
212 *rxes = GNUNET_malloc (sizeof (char *) * rx_cnt);
213 offset = 0;
214 for (i = 0; i < rx_cnt; i++)
215 {
216 GNUNET_asprintf (&(*rxes)[i], "%s%s", regex_prefix, &data[offset]);
217 offset += strlen (&data[offset]) + 1;
218 }
219 GNUNET_free (data);
220
221 return rx_cnt;
222}
223
224
225/**
124 * @brief Main function that will be run by the scheduler. 226 * @brief Main function that will be run by the scheduler.
125 * 227 *
126 * @param cls closure 228 * @param cls closure
@@ -133,13 +235,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
133 const char *cfgfile GNUNET_UNUSED, 235 const char *cfgfile GNUNET_UNUSED,
134 const struct GNUNET_CONFIGURATION_Handle *cfg_) 236 const struct GNUNET_CONFIGURATION_Handle *cfg_)
135{ 237{
136 char *regex; 238 const GNUNET_MESH_ApplicationType app = (GNUNET_MESH_ApplicationType)0;
137 char *data;
138 char *buf;
139 uint64_t filesize;
140 unsigned int offset;
141 GNUNET_MESH_ApplicationType app;
142
143 static struct GNUNET_MESH_MessageHandler handlers[] = { 239 static struct GNUNET_MESH_MessageHandler handlers[] = {
144 {NULL, 0, 0} 240 {NULL, 0, 0}
145 }; 241 };
@@ -185,9 +281,18 @@ run (void *cls, char *const *args GNUNET_UNUSED,
185 return; 281 return;
186 } 282 }
187 283
188 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); 284 if (GNUNET_OK !=
285 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER", "ANNOUNCE_DELAY",
286 &announce_delay))
287 {
288 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
289 _
290 ("%s service is lacking key configuration settings (%s). Using default value: %s.\n"),
291 "regexprofiler", "announce_delay",
292 GNUNET_STRINGS_relative_time_to_string (announce_delay, GNUNET_NO));
293 }
189 294
190 app = (GNUNET_MESH_ApplicationType)0; 295 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg);
191 296
192 mesh_handle = 297 mesh_handle =
193 GNUNET_MESH_connect (cfg, NULL, NULL, NULL, handlers, &app); 298 GNUNET_MESH_connect (cfg, NULL, NULL, NULL, handlers, &app);
@@ -200,47 +305,19 @@ run (void *cls, char *const *args GNUNET_UNUSED,
200 return; 305 return;
201 } 306 }
202 307
203 /* Announcing regexes from policy_filename */ 308 /* Read regexes from policy files */
204 if (GNUNET_YES != GNUNET_DISK_file_test (policy_filename)) 309 if ((num_regexes = load_regexes (policy_filename, &regexes)) == 0)
205 {
206 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
207 "Could not find policy file %s\n", policy_filename);
208 return;
209 }
210 if (GNUNET_OK != GNUNET_DISK_file_size (policy_filename, &filesize, GNUNET_YES, GNUNET_YES))
211 filesize = 0;
212 if (0 == filesize)
213 { 310 {
214 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Policy file %s is empty.\n", policy_filename); 311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
215 return; 312 "Policy file %s contains no policies. Exiting.\n",
216 } 313 policy_filename);
217 data = GNUNET_malloc (filesize); 314 global_ret = GNUNET_SYSERR;
218 if (filesize != GNUNET_DISK_fn_read (policy_filename, data, filesize)) 315 GNUNET_SCHEDULER_shutdown ();
219 {
220 GNUNET_free (data);
221 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read policy file %s.\n",
222 policy_filename);
223 return; 316 return;
224 } 317 }
225 buf = data; 318
226 offset = 0; 319 /* Announcing regexes from policy_filename */
227 regex = NULL; 320 GNUNET_SCHEDULER_add_delayed (announce_delay, &do_announce_policies, NULL);
228 while (offset < (filesize - 1))
229 {
230 offset++;
231 if (((data[offset] == '\n')) && (buf != &data[offset]))
232 {
233 data[offset] = '\0';
234 GNUNET_assert (NULL != buf);
235 GNUNET_asprintf (&regex, "%s%s", regex_prefix, buf);
236 announce_regex (regex);
237 GNUNET_free (regex);
238 buf = &data[offset + 1];
239 }
240 else if ((data[offset] == '\n') || (data[offset] == '\0'))
241 buf = &data[offset + 1];
242 }
243 GNUNET_free (data);
244 321
245 /* Scheduled the task to clean up when shutdown is called */ 322 /* Scheduled the task to clean up when shutdown is called */
246 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 323 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 9e4f1b2f8..02d552407 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -444,6 +444,33 @@ static void
444mesh_da (void *cls, void *op_result); 444mesh_da (void *cls, void *op_result);
445 445
446 446
447/**
448 * Function called by testbed once we are connected to stats
449 * service. Get the statistics for the services of interest.
450 *
451 * @param cls the 'struct RegexPeer' for which we connected to stats
452 * @param op connect operation handle
453 * @param ca_result handle to stats service
454 * @param emsg error message on failure
455 */
456static void
457stats_connect_cb (void *cls,
458 struct GNUNET_TESTBED_Operation *op,
459 void *ca_result,
460 const char *emsg);
461
462
463/**
464 * Task to collect all statistics from all peers, will shutdown the
465 * profiler, when done.
466 *
467 * @param cls NULL
468 * @param tc the task context
469 */
470static void
471do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
472
473
447/******************************************************************************/ 474/******************************************************************************/
448/******************************** SHUTDOWN **********************************/ 475/******************************** SHUTDOWN **********************************/
449/******************************************************************************/ 476/******************************************************************************/
@@ -482,12 +509,16 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
482 size = 509 size =
483 GNUNET_snprintf (output_buffer, 510 GNUNET_snprintf (output_buffer,
484 sizeof (output_buffer), 511 sizeof (output_buffer),
485 "Search string not found: %s (%d)\nOn peer: %u (%p)\nWith policy file: %s\nAfter: %s\n", 512 "%p Search string not found: %s (%d)\n%p On peer: %u (%p)\n%p With policy file: %s\n%p After: %s\n",
513 peer,
486 peer->search_str, 514 peer->search_str,
487 peer->search_str_matched, 515 peer->search_str_matched,
516 peer,
488 peer->id, 517 peer->id,
489 peer, 518 peer,
519 peer,
490 peer->policy_file, 520 peer->policy_file,
521 peer,
491 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); 522 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
492 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) 523 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
493 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); 524 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
@@ -660,11 +691,26 @@ stats_cb (void *cls,
660 GNUNET_TESTBED_operation_done (peer->stats_op_handle); 691 GNUNET_TESTBED_operation_done (peer->stats_op_handle);
661 peer->stats_op_handle = NULL; 692 peer->stats_op_handle = NULL;
662 693
663 if (++peer_cnt == num_search_strings) 694 peer_cnt++;
695 peer = &peers[peer_cnt];
696
697 if (peer_cnt == num_peers)
664 { 698 {
665 struct GNUNET_TIME_Relative delay = { 100 }; 699 struct GNUNET_TIME_Relative delay = { 100 };
666 shutdown_task = GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL); 700 shutdown_task = GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL);
667 } 701 }
702 else
703 {
704 peer->stats_op_handle =
705 GNUNET_TESTBED_service_connect (NULL,
706 peer->peer_handle,
707 "statistics",
708 &stats_connect_cb,
709 peer,
710 &stats_ca,
711 &stats_da,
712 peer);
713 }
668} 714}
669 715
670 716
@@ -697,41 +743,43 @@ stats_connect_cb (void *cls,
697 743
698 peer->stats_handle = ca_result; 744 peer->stats_handle = ca_result;
699 745
700 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "mesh", NULL, 746 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL,
701 GNUNET_TIME_UNIT_FOREVER_REL,
702 NULL,
703 &stats_iterator, peer))
704 {
705 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
706 "Could not get mesh statistics of peer %u!\n", peer->id);
707 }
708 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "regexprofiler", NULL,
709 GNUNET_TIME_UNIT_FOREVER_REL,
710 NULL,
711 &stats_iterator, peer))
712 {
713 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
714 "Could not get regexprofiler statistics of peer %u!\n", peer->id);
715 }
716 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "transport", NULL,
717 GNUNET_TIME_UNIT_FOREVER_REL,
718 NULL,
719 &stats_iterator, peer))
720 {
721 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
722 "Could not get transport statistics of peer %u!\n", peer->id);
723 }
724 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, "dht", NULL,
725 GNUNET_TIME_UNIT_FOREVER_REL, 747 GNUNET_TIME_UNIT_FOREVER_REL,
726 &stats_cb, 748 &stats_cb,
727 &stats_iterator, peer)) 749 &stats_iterator, peer))
728 { 750 {
729 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 751 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
730 "Could not get dht statistics of peer %u!\n", peer->id); 752 "Could not get statistics of peer %u!\n", peer->id);
731 } 753 }
732} 754}
733 755
734 756
757/**
758 * Task to collect all statistics from all peers, will shutdown the
759 * profiler, when done.
760 *
761 * @param cls NULL
762 * @param tc the task context
763 */
764static void
765do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
766{
767 struct RegexPeer *peer = &peers[0];
768
769 GNUNET_assert (NULL != peer->peer_handle);
770
771 peer->stats_op_handle =
772 GNUNET_TESTBED_service_connect (NULL,
773 peer->peer_handle,
774 "statistics",
775 &stats_connect_cb,
776 peer,
777 &stats_ca,
778 &stats_da,
779 peer);
780}
781
782
735/******************************************************************************/ 783/******************************************************************************/
736/************************ MESH SERVICE CONNECTIONS **************************/ 784/************************ MESH SERVICE CONNECTIONS **************************/
737/******************************************************************************/ 785/******************************************************************************/
@@ -831,16 +879,6 @@ mesh_peer_connect_handler (void *cls,
831 } 879 }
832 } 880 }
833 881
834 peer->stats_op_handle =
835 GNUNET_TESTBED_service_connect (NULL,
836 peer->peer_handle,
837 "statistics",
838 &stats_connect_cb,
839 peer,
840 &stats_ca,
841 &stats_da,
842 peer);
843
844 GNUNET_TESTBED_operation_done (peer->mesh_op_handle); 882 GNUNET_TESTBED_operation_done (peer->mesh_op_handle);
845 peer->mesh_op_handle = NULL; 883 peer->mesh_op_handle = NULL;
846 884
@@ -850,11 +888,14 @@ mesh_peer_connect_handler (void *cls,
850 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 888 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
851 "All strings successfully matched in %s\n", 889 "All strings successfully matched in %s\n",
852 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); 890 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
853 printf ("All strings successfully matched. Shutting down.\n"); 891 printf ("All strings successfully matched.\n");
854 fflush (stdout); 892 fflush (stdout);
855 893
856 if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) 894 if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
857 GNUNET_SCHEDULER_cancel (search_timeout_task); 895 GNUNET_SCHEDULER_cancel (search_timeout_task);
896
897 printf ("Collecting stats and shutting down.\n");
898 GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
858 } 899 }
859} 900}
860 901
@@ -876,11 +917,11 @@ do_connect_by_string_timeout (void *cls,
876 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 917 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
877 "Found %i of %i strings\n", peers_found, num_search_strings); 918 "Found %i of %i strings\n", peers_found, num_search_strings);
878 919
879 printf ("Search timed out after %s. Shutting down.\n", 920 printf ("Search timed out after %s. Collecting stats and shutting down.\n",
880 GNUNET_STRINGS_relative_time_to_string (search_timeout, GNUNET_NO)); 921 GNUNET_STRINGS_relative_time_to_string (search_timeout, GNUNET_NO));
881 fflush (stdout); 922 fflush (stdout);
882 923
883 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 924 GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
884} 925}
885 926
886 927
@@ -1633,7 +1674,7 @@ load_search_strings (const char *filename, char ***strings, unsigned int limit)
1633 GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]); 1674 GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]);
1634 offset += strlen (&data[offset]) + 1; 1675 offset += strlen (&data[offset]) + 1;
1635 } 1676 }
1636 free (data); 1677 GNUNET_free (data);
1637 return str_cnt; 1678 return str_cnt;
1638} 1679}
1639 1680
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index f1eded3e6..3783ec3b8 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -182,6 +182,8 @@ struct MeshRegexDescriptor
182 */ 182 */
183 char *regex; 183 char *regex;
184 184
185 struct GNUNET_REGEX_Automaton *dfa;
186
185 /** 187 /**
186 * How many characters per edge can we squeeze? 188 * How many characters per edge can we squeeze?
187 */ 189 */
@@ -1651,18 +1653,18 @@ regex_iterator (void *cls,
1651 * @param regex The regular expresion. 1653 * @param regex The regular expresion.
1652 */ 1654 */
1653static void 1655static void
1654regex_put (const struct MeshRegexDescriptor *regex) 1656regex_put (struct MeshRegexDescriptor *regex)
1655{ 1657{
1656 struct GNUNET_REGEX_Automaton *dfa; 1658 if (NULL == regex->dfa)
1659 {
1660 regex->dfa = GNUNET_REGEX_construct_dfa (regex->regex,
1661 strlen (regex->regex),
1662 regex->compression);
1663 }
1657 1664
1658 DEBUG_DHT (" regex_put (%s) start\n", regex->regex); 1665 DEBUG_DHT (" regex_put (%s) start\n", regex->regex);
1659 dfa = GNUNET_REGEX_construct_dfa (regex->regex, 1666 GNUNET_REGEX_iterate_all_edges (regex->dfa, &regex_iterator, NULL);
1660 strlen(regex->regex),
1661 regex->compression);
1662 GNUNET_REGEX_iterate_all_edges (dfa, &regex_iterator, NULL);
1663 GNUNET_REGEX_automaton_destroy (dfa);
1664 DEBUG_DHT (" regex_put (%s) end\n", regex); 1667 DEBUG_DHT (" regex_put (%s) end\n", regex);
1665
1666} 1668}
1667 1669
1668/** 1670/**
@@ -6662,6 +6664,8 @@ handle_local_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
6662 for (i = 0; i < c->n_regex; i++) 6664 for (i = 0; i < c->n_regex; i++)
6663 { 6665 {
6664 GNUNET_free (c->regexes[i].regex); 6666 GNUNET_free (c->regexes[i].regex);
6667 if (NULL != c->regexes[i].dfa)
6668 GNUNET_REGEX_automaton_destroy (c->regexes[i].dfa);
6665 } 6669 }
6666 GNUNET_free_non_null (c->regexes); 6670 GNUNET_free_non_null (c->regexes);
6667 if (GNUNET_SCHEDULER_NO_TASK != c->regex_announce_task) 6671 if (GNUNET_SCHEDULER_NO_TASK != c->regex_announce_task)
@@ -6813,6 +6817,7 @@ handle_local_announce_regex (void *cls, struct GNUNET_SERVER_Client *client,
6813 regex[len] = '\0'; 6817 regex[len] = '\0';
6814 rd.regex = regex; 6818 rd.regex = regex;
6815 rd.compression = ntohs (msg->compression_characters); 6819 rd.compression = ntohs (msg->compression_characters);
6820 rd.dfa = NULL;
6816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " length %u\n", len); 6821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " length %u\n", len);
6817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " regex %s\n", regex); 6822 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " regex %s\n", regex);
6818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " cm %u\n", ntohs(rd.compression)); 6823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " cm %u\n", ntohs(rd.compression));