#include "platform.h"
#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
-#include "gnunet_regex_lib.h"
+#include "regex_internal_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_dht_service.h"
#include "gnunet_testbed_service.h"
/**
* Handle to a running regex search.
*/
- struct GNUNET_REGEX_search_handle *search_handle;
+ struct REGEX_INTERNAL_Search *search_handle;
/**
* Testbed operation handle for DHT.
peer_cnt++;
peer = &peers[peer_cnt];
+ fprintf (stderr, "s");
if (peer_cnt == num_peers)
{
struct GNUNET_TIME_Relative delay = { 100 };
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\nCollecting stats finished. Shutting down.\n");
shutdown_task = GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL);
+ result = GNUNET_OK;
}
else
{
* Method called when we've found a peer that announced a regex
* that matches our search string. Now get the statistics.
*
- * @param cls Closure provided in GNUNET_REGEX_search.
+ * @param cls Closure provided in REGEX_INTERNAL_search.
* @param id Peer providing a regex that matches the string.
* @param get_path Path of the get request.
* @param get_path_length Lenght of get_path.
if (GNUNET_YES == peer->search_str_matched)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"String %s on peer %u already matched!\n",
peer->search_str, peer->id);
return;
GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
+ {
GNUNET_SCHEDULER_cancel (search_timeout_task);
+ search_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats and shutting down.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n");
GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Search timed out after %s."
- "Collecting stats and shutting down.\n",
+ "Collecting stats and shutting down.\n",
GNUNET_STRINGS_relative_time_to_string (search_timeout_time,
GNUNET_NO));
"Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
GNUNET_abort ();
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Deamon %u started successfully\n", peer->id);
+ }
/* Find a peer to look for a string matching the regex announced */
search_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
{
struct RegexPeer *peer;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) ||
- next_search >= num_peers)
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
+ if (next_search >= num_peers)
+ {
+ if (strings_found != num_peers)
+ {
+ struct GNUNET_TIME_Relative new_delay;
+ if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
+ GNUNET_SCHEDULER_cancel (search_timeout_task);
+ new_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
+ search_timeout_task = GNUNET_SCHEDULER_add_delayed (new_delay,
+ &search_timed_out,
+ NULL);
+ }
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search);
peer = &peers[next_search];
- peer->daemon_op =
+ peer->daemon_op =
GNUNET_TESTBED_peer_manage_service (NULL,
peer->peer_handle,
"regexprofiler",
GNUNET_assert (peer->dht_handle == ca_result);
peer->search_str_matched = GNUNET_NO;
- peer->search_handle = GNUNET_REGEX_search (peer->dht_handle,
+ peer->search_handle = REGEX_INTERNAL_search (peer->dht_handle,
peer->search_str,
®ex_found_handler, peer,
NULL);
if (NULL != peer->search_handle)
{
- GNUNET_REGEX_search_cancel (peer->search_handle);
+ REGEX_INTERNAL_search_cancel (peer->search_handle);
peer->search_handle = NULL;
}
* Signature of a main function for a testcase.
*
* @param cls NULL
+ * @param h the run handle
* @param num_peers_ number of peers in 'peers'
- * @param peers handle to peers run in the testbed. NULL upon timeout (see
+ * @param testbed_peers handle to peers run in the testbed. NULL upon timeout (see
* GNUNET_TESTBED_test_run()).
* @param links_succeeded the number of overlay link connection attempts that
* succeeded
* @param links_failed the number of overlay link connection attempts that
* failed
*/
-static void
+static void
test_master (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
unsigned int num_peers_,
struct GNUNET_TESTBED_Peer **testbed_peers,
unsigned int links_succeeded,
settle_time =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
10 * num_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Waiting for DHT for %s to settle new connections.\n\n",
GNUNET_STRINGS_relative_time_to_string(settle_time, GNUNET_NO));
GNUNET_SCHEDULER_add_delayed (settle_time, &do_announce, NULL);
* @param event information on what is happening
*/
static void
-master_controller_cb (void *cls,
+master_controller_cb (void *cls,
const struct GNUNET_TESTBED_EventInformation *event)
{
switch (event->type)
"REANNOUNCE_PERIOD_MAX",
&reannounce_period_max))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"reannounce_period_max not given. Using 10 minutes.\n");
reannounce_period_max =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
- if (-1 == (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL)))
+ if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("No files found in `%s'\n"),
if (num_peers != nsearchstrs)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Error loading search strings."
- "Given file does not contain enough strings. Exiting.\n"));
+ "Error loading search strings.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "File (%s) does not contain enough strings (%u/%u).\n",
+ strings_file, nsearchstrs, num_peers);
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
- if (0 >= num_peers || NULL == search_strings)
+ if ( (0 == num_peers) || (NULL == search_strings))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Error loading search strings. Exiting.\n"));
/* Initialize peers */
peers = GNUNET_malloc (sizeof (struct RegexPeer) * num_peers);
for (i = 0; i < num_peers; i++)
- {
peers[i].id = i;
- }
GNUNET_CONFIGURATION_set_value_number (cfg,
"TESTBED", "OVERLAY_RANDOM_LINKS",
- num_peers * 10);
+ num_peers * 20);
GNUNET_CONFIGURATION_set_value_number (cfg,
"DHT", "FORCE_NSE",
- (long long unsigned) log2 (num_peers));
+ (long long unsigned)
+ (log (num_peers) / log (2.0)));
event_mask = 0LL;
/* For feedback about the start process activate these and pass master_cb */
event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
"SETUP_TIMEOUT",
&abort_time))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "SETUP_TIMEOUT not given. Using 15 minutes.\n");
abort_time =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
}
GNUNET_SCHEDULER_add_delayed (abort_time,
&do_abort,
(void*) __LINE__);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "setup_timeout: %s\n",
+ GNUNET_STRINGS_relative_time_to_string (abort_time, GNUNET_YES));
}