aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-07-19 13:06:04 +0000
committerNathan S. Evans <evans@in.tum.de>2011-07-19 13:06:04 +0000
commit087e8ac353ce877fef5a3d0988d1c496469c15c8 (patch)
treec0eb056d7b0b467b6dc61a55d461cf5bf09a2c62 /src
parent81e041f4ea19985a91a3b2ee5a857a26ff3a2d59 (diff)
downloadgnunet-087e8ac353ce877fef5a3d0988d1c496469c15c8.tar.gz
gnunet-087e8ac353ce877fef5a3d0988d1c496469c15c8.zip
changes
Diffstat (limited to 'src')
-rw-r--r--src/nse/nse-profiler.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/nse/nse-profiler.c b/src/nse/nse-profiler.c
index 58ce5fb49..7c3c7a5ec 100644
--- a/src/nse/nse-profiler.c
+++ b/src/nse/nse-profiler.c
@@ -118,6 +118,8 @@ static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
118 */ 118 */
119static GNUNET_SCHEDULER_TaskIdentifier churn_task; 119static GNUNET_SCHEDULER_TaskIdentifier churn_task;
120 120
121char *topology_file;
122
121/** 123/**
122 * Check whether peers successfully shut down. 124 * Check whether peers successfully shut down.
123 */ 125 */
@@ -261,20 +263,41 @@ disconnect_nse_peers (void *cls,
261 * Prototype of a function that will be called when a 263 * Prototype of a function that will be called when a
262 * particular operation was completed the testing library. 264 * particular operation was completed the testing library.
263 * 265 *
266 * @param cls unused
267 * @param emsg NULL on success
268 */
269void topology_output_callback (void *cls, const char *emsg)
270{
271 disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL);
272 GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL);
273}
274
275
276/**
277 * Prototype of a function that will be called when a
278 * particular operation was completed the testing library.
279 *
264 * @param cls closure 280 * @param cls closure
265 * @param emsg NULL on success 281 * @param emsg NULL on success
266 */ 282 */
267static void 283static void
268churn_callback (void *cls, const char *emsg) 284churn_callback (void *cls, const char *emsg)
269{ 285{
286 char *temp_output_file;
287
270 if (emsg == NULL) /* Everything is okay! */ 288 if (emsg == NULL) /* Everything is okay! */
271 { 289 {
272 peers_running = GNUNET_TESTING_daemons_running(pg); 290 peers_running = GNUNET_TESTING_daemons_running(pg);
273 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 291 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
274 "Round %lu, churn finished successfully.\n", current_round); 292 "Round %lu, churn finished successfully.\n", current_round);
275 GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); 293 GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK);
276 disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); 294 GNUNET_asprintf(&temp_output_file, "%s%lu.dot", topology_file, current_round);
277 GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); 295 GNUNET_TESTING_peergroup_topology_to_file(pg,
296 temp_output_file,
297 &topology_output_callback,
298 NULL);
299 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", temp_output_file);
300 GNUNET_free(temp_output_file);
278 } 301 }
279 else 302 else
280 { 303 {
@@ -326,7 +349,6 @@ churn_peers (void *cls,
326} 349}
327 350
328 351
329
330static void 352static void
331my_cb (void *cls, 353my_cb (void *cls,
332 const char *emsg) 354 const char *emsg)
@@ -409,14 +431,21 @@ run (void *cls,
409 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:wait_time is required!\n"); 431 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:wait_time is required!\n");
410 return; 432 return;
411 } 433 }
434
435 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", "topology_output_file", &topology_file))
436 {
437 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:topology_output_file is required!\n");
438 return;
439 }
440
412 wait_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_wait); 441 wait_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_wait);
413 442
414 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, "nse-profiler", "output_file", &temp_str)) 443 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, "nse-profiler", "output_file", &temp_str))
415 { 444 {
416 output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE 445 output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE
417 | GNUNET_DISK_OPEN_CREATE, 446 | GNUNET_DISK_OPEN_CREATE,
418 GNUNET_DISK_PERM_USER_READ | 447 GNUNET_DISK_PERM_USER_READ |
419 GNUNET_DISK_PERM_USER_WRITE); 448 GNUNET_DISK_PERM_USER_WRITE);
420 if (output_file == NULL) 449 if (output_file == NULL)
421 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", temp_str); 450 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", temp_str);
422 } 451 }