aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-01-31 12:46:07 +0000
committerBart Polot <bart@net.in.tum.de>2013-01-31 12:46:07 +0000
commitf8358e6f83f34dc5dc69b30bc34f7546c575b74f (patch)
tree34226d1e079e45be3e68be987dc88f278a4feb25 /src
parentb19d787fc3b840821157471bb07f287a68e37709 (diff)
downloadgnunet-f8358e6f83f34dc5dc69b30bc34f7546c575b74f.tar.gz
gnunet-f8358e6f83f34dc5dc69b30bc34f7546c575b74f.zip
- slow down the searching of strings to avoid collapsing the testbed
Diffstat (limited to 'src')
-rw-r--r--src/regex/gnunet-regex-profiler.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index e91a21787..26c052387 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -946,6 +946,38 @@ do_connect_by_string (void *cls,
946 &do_connect_by_string_timeout, NULL); 946 &do_connect_by_string_timeout, NULL);
947} 947}
948 948
949/**
950 * Start searching for the next string in the DHT.
951 *
952 * @param cls Index of the next peer in the peers array.
953 * @param tc TaskContext.
954 */
955void
956find_next_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
957{
958 long next_p = (long) cls;
959
960 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
961 return;
962
963 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
964 "Searching for string \"%s\" on peer %d with file %s\n",
965 peers[next_p].search_str, next_p, peers[next_p].policy_file);
966
967 /* FIXME
968 * dont connect to a new dht for each peer, we might want to seach for n
969 * strings on m peers where n > m
970 */
971 peers[next_p].dht_op_handle =
972 GNUNET_TESTBED_service_connect (NULL,
973 peers[next_p].peer_handle,
974 "dht",
975 &dht_connect_cb,
976 &peers[next_p],
977 &dht_ca,
978 &dht_da,
979 &peers[next_p]);
980}
949 981
950/** 982/**
951 * DHT connect callback. Called when we are connected to the dht service for 983 * DHT connect callback. Called when we are connected to the dht service for
@@ -992,23 +1024,11 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
992 peers[next_p].search_str = search_strings[next_p]; 1024 peers[next_p].search_str = search_strings[next_p];
993 peers[next_p].search_str_matched = GNUNET_NO; 1025 peers[next_p].search_str_matched = GNUNET_NO;
994 1026
995 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1027 /* Don't start all searches at once */
996 "Searching for string \"%s\" on peer %d with file %s\n", 1028 /* TODO add some intelligence to the timeout */
997 peers[next_p].search_str, next_p, peers[next_p].policy_file); 1029 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
998 1030 &find_next_string,
999 /* FIXME 1031 (void *) (long) next_p);
1000 * dont connect to a new dht for each peer, we might want to seach for n
1001 * strings on m peers where n > m
1002 */
1003 peers[next_p].dht_op_handle =
1004 GNUNET_TESTBED_service_connect (NULL,
1005 peers[next_p].peer_handle,
1006 "dht",
1007 &dht_connect_cb,
1008 &peers[next_p],
1009 &dht_ca,
1010 &dht_da,
1011 &peers[next_p]);
1012 } 1032 }
1013} 1033}
1014 1034