From 5746309cb4be2073d550ad7a6885e918631dbc38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 15 Aug 2011 21:54:06 +0000 Subject: indentation --- src/nse/gnunet-nse-profiler.c | 208 ++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 110 deletions(-) (limited to 'src/nse/gnunet-nse-profiler.c') diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index b88dbc3fc..df26280c4 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c @@ -213,13 +213,12 @@ handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, if (output_file != NULL) { - size = GNUNET_asprintf (&output_buffer, - "%s %llu %llu %f %f %f\n", - GNUNET_i2s (&peer->daemon->id), - peers_running, - timestamp.abs_value, - GNUNET_NSE_log_estimate_to_n (estimate), - estimate, std_dev); + size = + GNUNET_asprintf (&output_buffer, "%s %llu %llu %f %f %f\n", + GNUNET_i2s (&peer->daemon->id), peers_running, + timestamp.abs_value, + GNUNET_NSE_log_estimate_to_n (estimate), estimate, + std_dev); if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); GNUNET_free (output_buffer); @@ -254,9 +253,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (GNUNET_YES == GNUNET_TESTING_daemon_running (GNUNET_TESTING_daemon_get (pg, i))) { - current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, - &handle_estimate, - current_peer); + current_peer->nse_handle = + GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, + current_peer); GNUNET_assert (current_peer->nse_handle != NULL); } GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); @@ -264,8 +263,8 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -static void -churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void churn_peers (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -286,9 +285,9 @@ stats_finished_callback (void *cls, int success) { /* Stats lookup successful, write out data */ buf = NULL; - buf_len = GNUNET_asprintf (&buf, - "TOTAL_NSE_BYTES: %u\n", - stats_context->total_nse_bytes); + buf_len = + GNUNET_asprintf (&buf, "TOTAL_NSE_BYTES: %u\n", + stats_context->total_nse_bytes); if (buf_len > 0) { GNUNET_DISK_file_write (data_file, buf, buf_len); @@ -314,10 +313,9 @@ stats_finished_callback (void *cls, int success) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -statistics_iterator (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, + const char *subsystem, const char *name, uint64_t value, + int is_persistent) { struct StatsContext *stats_context = cls; @@ -350,10 +348,9 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_asprintf (&buf, "round%llu", current_round); - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - buf, - &peers_next_round)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", buf, + &peers_next_round)) { current_round++; GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); @@ -364,8 +361,7 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) stats_context = GNUNET_malloc (sizeof (struct StatsContext)); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_NO_TASK; - GNUNET_TESTING_get_statistics (pg, - &stats_finished_callback, + GNUNET_TESTING_get_statistics (pg, &stats_finished_callback, &statistics_iterator, stats_context); } GNUNET_free (buf); @@ -381,8 +377,8 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void topology_output_callback (void *cls, const char *emsg) { - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_nse_peers, NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); } @@ -404,19 +400,18 @@ churn_callback (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn finished successfully.\n", current_round); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - GNUNET_asprintf (&temp_output_file, - "%s_%llu.dot", topology_file, current_round); - GNUNET_TESTING_peergroup_topology_to_file (pg, - temp_output_file, + GNUNET_asprintf (&temp_output_file, "%s_%llu.dot", topology_file, + current_round); + GNUNET_TESTING_peergroup_topology_to_file (pg, temp_output_file, &topology_output_callback, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Writing topology to file %s\n", temp_output_file); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", + temp_output_file); GNUNET_free (temp_output_file); } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Round %llu, churn FAILED!!\n", current_round); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn FAILED!!\n", + current_round); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } @@ -433,9 +428,8 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Nothing to do... */ GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_nse_peers, - NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", current_round); } @@ -451,18 +445,18 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, turning off %llu peers, turning on %llu peers!\n", current_round, - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running : 0); + (peers_running > + peers_next_round) ? peers_running - peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - peers_running : 0); GNUNET_TESTING_daemons_churn (pg, "nse", - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running - : 0, wait_time, &churn_callback, NULL); + (peers_running > + peers_next_round) ? peers_running - + peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - + peers_running : 0, wait_time, &churn_callback, + NULL); } } @@ -495,8 +489,8 @@ my_cb (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully, connecting to NSE service for each peer!\n"); #endif - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have %u connections\n", total_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", + total_connections); if (data_file != NULL) { buf = NULL; @@ -506,9 +500,8 @@ my_cb (void *cls, const char *emsg) GNUNET_free (buf); } peers_running = GNUNET_TESTING_daemons_running (pg); - GNUNET_TESTING_daemons_start_service (pg, - "nse", - wait_time, &nse_started_cb, NULL); + GNUNET_TESTING_daemons_start_service (pg, "nse", wait_time, &nse_started_cb, + NULL); } @@ -528,10 +521,8 @@ my_cb (void *cls, const char *emsg) * @param emsg error message (NULL on success) */ static void -connect_cb (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -543,9 +534,8 @@ connect_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *temp_str; unsigned long long temp_wait; @@ -555,100 +545,99 @@ run (void *cls, testing_cfg = GNUNET_CONFIGURATION_create (); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); - GNUNET_CONFIGURATION_set_value_string (testing_cfg, - "testing", "use_progressbars", "YES"); + GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", + "use_progressbars", "YES"); #endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "testing", - "num_peers", - &num_peers)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", + "num_peers", &num_peers)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - "wait_time", - &temp_wait)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", + "wait_time", &temp_wait)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:wait_time is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - "connection_limit", - &connection_limit)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", + "connection_limit", + &connection_limit)) { connection_limit = 0; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "nse-profiler", - "topology_output_file", - &topology_file)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", + "topology_output_file", + &topology_file)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:topology_output_file is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "nse-profiler", - "data_output_file", - &data_filename)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", + "data_output_file", + &data_filename)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:data_output_file is required!\n"); return; } - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, - "nse-profiler", - "skew_clock")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, "nse-profiler", + "skew_clock")) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Setting our clock as skewed...\n"); - clock_skew = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - GNUNET_TIME_UNIT_MINUTES.rel_value); + clock_skew = + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + GNUNET_TIME_UNIT_MINUTES.rel_value); } - data_file = GNUNET_DISK_file_open (data_filename, - GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + data_file = + GNUNET_DISK_file_open (data_filename, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (data_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", data_filename); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + data_filename); GNUNET_free (data_filename); wait_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, - "nse-profiler", - "output_file", - &temp_str)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "nse-profiler", "output_file", + &temp_str)) { - output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + output_file = + GNUNET_DISK_file_open (temp_str, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (output_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", temp_str); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + temp_str); } GNUNET_free_non_null (temp_str); hosts = GNUNET_TESTING_hosts_load (testing_cfg); - pg = GNUNET_TESTING_peergroup_start (testing_cfg, - num_peers, - TIMEOUT, + pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT, &connect_cb, &my_cb, NULL, hosts); GNUNET_assert (pg != NULL); shutdown_handle = @@ -679,8 +668,7 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run (argc, - argv, "nse-profiler", + GNUNET_PROGRAM_run (argc, argv, "nse-profiler", gettext_noop ("Measure quality and performance of the NSE service."), options, &run, NULL); -- cgit v1.2.3