diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-24 11:53:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-24 11:53:40 +0000 |
commit | 592da050cb3784689750679980778108fac71fb2 (patch) | |
tree | 6cda5d2d27d6d777939b2b25f8cd53316c39965a /src/nse | |
parent | 8233a156290cf549bc9c26d097ecf07bff072fea (diff) | |
download | gnunet-592da050cb3784689750679980778108fac71fb2.tar.gz gnunet-592da050cb3784689750679980778108fac71fb2.zip |
indentation
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/nse-profiler.c | 224 |
1 files changed, 152 insertions, 72 deletions
diff --git a/src/nse/nse-profiler.c b/src/nse/nse-profiler.c index fd145b4d9..bef9d0f54 100644 --- a/src/nse/nse-profiler.c +++ b/src/nse/nse-profiler.c | |||
@@ -145,7 +145,7 @@ static uint64_t clock_skew; | |||
145 | /** | 145 | /** |
146 | * Check whether peers successfully shut down. | 146 | * Check whether peers successfully shut down. |
147 | */ | 147 | */ |
148 | void | 148 | static void |
149 | shutdown_callback (void *cls, const char *emsg) | 149 | shutdown_callback (void *cls, const char *emsg) |
150 | { | 150 | { |
151 | if (emsg != NULL) | 151 | if (emsg != NULL) |
@@ -207,16 +207,27 @@ handle_estimate (void *cls, double estimate, double std_dev) | |||
207 | { | 207 | { |
208 | struct NSEPeer *peer = cls; | 208 | struct NSEPeer *peer = cls; |
209 | char *output_buffer; | 209 | char *output_buffer; |
210 | int size; | 210 | size_t size; |
211 | //fprintf(stderr, "Received network size estimate from peer %s. Size: %f std.dev. %f\n", GNUNET_i2s(&peer->daemon->id), estimate, std_dev); | 211 | |
212 | if (output_file != NULL) | 212 | if (output_file != NULL) |
213 | { | 213 | { |
214 | size = GNUNET_asprintf(&output_buffer, "%s %u %f %f\n", GNUNET_i2s(&peer->daemon->id), peers_running, estimate, std_dev); | 214 | size = GNUNET_asprintf(&output_buffer, |
215 | "%s %u %f %f\n", | ||
216 | GNUNET_i2s(&peer->daemon->id), | ||
217 | peers_running, | ||
218 | estimate, | ||
219 | std_dev); | ||
215 | if (size != GNUNET_DISK_file_write(output_file, output_buffer, size)) | 220 | if (size != GNUNET_DISK_file_write(output_file, output_buffer, size)) |
216 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Unable to write to file!\n", "nse-profiler"); | 221 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
222 | "Unable to write to file!\n"); | ||
223 | GNUNET_free (output_buffer); | ||
217 | } | 224 | } |
218 | else | 225 | else |
219 | fprintf(stderr, "Received network size estimate from peer %s. Size: %f std.dev. %f\n", GNUNET_i2s(&peer->daemon->id), estimate, std_dev); | 226 | fprintf(stderr, |
227 | "Received network size estimate from peer %s. Size: %f std.dev. %f\n", | ||
228 | GNUNET_i2s(&peer->daemon->id), | ||
229 | estimate, | ||
230 | std_dev); | ||
220 | 231 | ||
221 | } | 232 | } |
222 | 233 | ||
@@ -226,10 +237,11 @@ connect_nse_service (void *cls, | |||
226 | { | 237 | { |
227 | struct NSEPeer *current_peer; | 238 | struct NSEPeer *current_peer; |
228 | unsigned int i; | 239 | unsigned int i; |
240 | |||
229 | #if VERBOSE | 241 | #if VERBOSE |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TEST_NSE_MULTIPEER: connecting to nse service of peers\n"); | 242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
243 | "Connecting to nse service of peers\n"); | ||
231 | #endif | 244 | #endif |
232 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TEST_NSE_MULTIPEER: connecting to nse service of peers\n"); | ||
233 | for (i = 0; i < num_peers; i++) | 245 | for (i = 0; i < num_peers; i++) |
234 | { | 246 | { |
235 | if ((connection_limit > 0) && (i % (num_peers / connection_limit) != 0)) | 247 | if ((connection_limit > 0) && (i % (num_peers / connection_limit) != 0)) |
@@ -238,17 +250,21 @@ connect_nse_service (void *cls, | |||
238 | current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i); | 250 | current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i); |
239 | if (GNUNET_YES == GNUNET_TESTING_daemon_running(GNUNET_TESTING_daemon_get(pg, i))) | 251 | if (GNUNET_YES == GNUNET_TESTING_daemon_running(GNUNET_TESTING_daemon_get(pg, i))) |
240 | { | 252 | { |
241 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, current_peer); | 253 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, |
254 | &handle_estimate, | ||
255 | current_peer); | ||
242 | GNUNET_assert(current_peer->nse_handle != NULL); | 256 | GNUNET_assert(current_peer->nse_handle != NULL); |
243 | } | 257 | } |
244 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 258 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
245 | } | 259 | } |
246 | } | 260 | } |
247 | 261 | ||
262 | |||
248 | static void | 263 | static void |
249 | churn_peers (void *cls, | 264 | churn_peers (void *cls, |
250 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 265 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
251 | 266 | ||
267 | |||
252 | /** | 268 | /** |
253 | * Continuation called by the "get_all" and "get" functions. | 269 | * Continuation called by the "get_all" and "get" functions. |
254 | * | 270 | * |
@@ -256,7 +272,8 @@ churn_peers (void *cls, | |||
256 | * @param success GNUNET_OK if statistics were | 272 | * @param success GNUNET_OK if statistics were |
257 | * successfully obtained, GNUNET_SYSERR if not. | 273 | * successfully obtained, GNUNET_SYSERR if not. |
258 | */ | 274 | */ |
259 | static void stats_finished_callback (void *cls, int success) | 275 | static void |
276 | stats_finished_callback (void *cls, int success) | ||
260 | { | 277 | { |
261 | struct StatsContext *stats_context = (struct StatsContext *)cls; | 278 | struct StatsContext *stats_context = (struct StatsContext *)cls; |
262 | char *buf; | 279 | char *buf; |
@@ -265,7 +282,9 @@ static void stats_finished_callback (void *cls, int success) | |||
265 | if ((GNUNET_OK == success) && (data_file != NULL)) /* Stats lookup successful, write out data */ | 282 | if ((GNUNET_OK == success) && (data_file != NULL)) /* Stats lookup successful, write out data */ |
266 | { | 283 | { |
267 | buf = NULL; | 284 | buf = NULL; |
268 | buf_len = GNUNET_asprintf(&buf, "TOTAL_NSE_BYTES: %u\n", stats_context->total_nse_bytes); | 285 | buf_len = GNUNET_asprintf(&buf, |
286 | "TOTAL_NSE_BYTES: %u\n", | ||
287 | stats_context->total_nse_bytes); | ||
269 | if (buf_len > 0) | 288 | if (buf_len > 0) |
270 | { | 289 | { |
271 | GNUNET_DISK_file_write(data_file, buf, buf_len); | 290 | GNUNET_DISK_file_write(data_file, buf, buf_len); |
@@ -274,11 +293,12 @@ static void stats_finished_callback (void *cls, int success) | |||
274 | } | 293 | } |
275 | 294 | ||
276 | if (stats_context->task != NULL) | 295 | if (stats_context->task != NULL) |
277 | (*stats_context->task_id) = GNUNET_SCHEDULER_add_now(stats_context->task, stats_context->task_cls); | 296 | *stats_context->task_id = GNUNET_SCHEDULER_add_now(stats_context->task, |
278 | 297 | stats_context->task_cls); | |
279 | GNUNET_free(stats_context); | 298 | GNUNET_free(stats_context); |
280 | } | 299 | } |
281 | 300 | ||
301 | |||
282 | /** | 302 | /** |
283 | * Callback function to process statistic values. | 303 | * Callback function to process statistic values. |
284 | * | 304 | * |
@@ -290,17 +310,20 @@ static void stats_finished_callback (void *cls, int success) | |||
290 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | 310 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not |
291 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 311 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
292 | */ | 312 | */ |
293 | static int statistics_iterator (void *cls, | 313 | static int |
294 | const struct GNUNET_PeerIdentity *peer, | 314 | statistics_iterator (void *cls, |
295 | const char *subsystem, | 315 | const struct GNUNET_PeerIdentity *peer, |
296 | const char *name, | 316 | const char *subsystem, |
297 | uint64_t value, | 317 | const char *name, |
298 | int is_persistent) | 318 | uint64_t value, |
319 | int is_persistent) | ||
299 | { | 320 | { |
300 | struct StatsContext *stats_context = (struct StatsContext *)cls; | 321 | struct StatsContext *stats_context = cls; |
301 | char *buf; | 322 | char *buf; |
302 | 323 | ||
303 | GNUNET_assert(0 < GNUNET_asprintf(&buf, "bytes of messages of type %d received", GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD)); | 324 | GNUNET_assert(0 < GNUNET_asprintf(&buf, |
325 | "bytes of messages of type %d received", | ||
326 | GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD)); | ||
304 | if ((0 == strstr(subsystem, "core")) && (0 == strstr(name, buf))) | 327 | if ((0 == strstr(subsystem, "core")) && (0 == strstr(name, buf))) |
305 | { | 328 | { |
306 | stats_context->total_nse_bytes += value; | 329 | stats_context->total_nse_bytes += value; |
@@ -309,6 +332,7 @@ static int statistics_iterator (void *cls, | |||
309 | return GNUNET_OK; | 332 | return GNUNET_OK; |
310 | } | 333 | } |
311 | 334 | ||
335 | |||
312 | /** | 336 | /** |
313 | * @param cls struct StatsContext | 337 | * @param cls struct StatsContext |
314 | * @param tc task context | 338 | * @param tc task context |
@@ -317,10 +341,15 @@ static void | |||
317 | get_statistics (void *cls, | 341 | get_statistics (void *cls, |
318 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 342 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
319 | { | 343 | { |
320 | struct StatsContext *stats_context = (struct StatsContext *)cls; | 344 | struct StatsContext *stats_context = cls; |
321 | GNUNET_TESTING_get_statistics(pg, &stats_finished_callback, &statistics_iterator, stats_context); | 345 | |
346 | GNUNET_TESTING_get_statistics(pg, | ||
347 | &stats_finished_callback, | ||
348 | &statistics_iterator, | ||
349 | stats_context); | ||
322 | } | 350 | } |
323 | 351 | ||
352 | |||
324 | static void | 353 | static void |
325 | disconnect_nse_peers (void *cls, | 354 | disconnect_nse_peers (void *cls, |
326 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 355 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -331,7 +360,8 @@ disconnect_nse_peers (void *cls, | |||
331 | disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 360 | disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
332 | pos = peer_head; | 361 | pos = peer_head; |
333 | 362 | ||
334 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TEST_NSE_MULTIPEER: disconnecting nse service of peers\n"); | 363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
364 | "disconnecting nse service of peers\n"); | ||
335 | while (NULL != (pos = peer_head)) | 365 | while (NULL != (pos = peer_head)) |
336 | { | 366 | { |
337 | if (pos->nse_handle != NULL) | 367 | if (pos->nse_handle != NULL) |
@@ -343,8 +373,13 @@ disconnect_nse_peers (void *cls, | |||
343 | GNUNET_free(pos); | 373 | GNUNET_free(pos); |
344 | } | 374 | } |
345 | 375 | ||
346 | GNUNET_asprintf(&buf, "round%llu", current_round); | 376 | GNUNET_asprintf(&buf, |
347 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", buf, &peers_next_round)) | 377 | "round%llu", |
378 | current_round); | ||
379 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, | ||
380 | "nse-profiler", | ||
381 | buf, | ||
382 | &peers_next_round)) | ||
348 | { | 383 | { |
349 | current_round++; | 384 | current_round++; |
350 | GNUNET_assert(churn_task == GNUNET_SCHEDULER_NO_TASK); | 385 | GNUNET_assert(churn_task == GNUNET_SCHEDULER_NO_TASK); |
@@ -364,6 +399,7 @@ disconnect_nse_peers (void *cls, | |||
364 | GNUNET_free(buf); | 399 | GNUNET_free(buf); |
365 | } | 400 | } |
366 | 401 | ||
402 | |||
367 | /** | 403 | /** |
368 | * Prototype of a function that will be called when a | 404 | * Prototype of a function that will be called when a |
369 | * particular operation was completed the testing library. | 405 | * particular operation was completed the testing library. |
@@ -371,7 +407,8 @@ disconnect_nse_peers (void *cls, | |||
371 | * @param cls unused | 407 | * @param cls unused |
372 | * @param emsg NULL on success | 408 | * @param emsg NULL on success |
373 | */ | 409 | */ |
374 | void topology_output_callback (void *cls, const char *emsg) | 410 | static void |
411 | topology_output_callback (void *cls, const char *emsg) | ||
375 | { | 412 | { |
376 | struct StatsContext *stats_context; | 413 | struct StatsContext *stats_context; |
377 | stats_context = GNUNET_malloc(sizeof(struct StatsContext)); | 414 | stats_context = GNUNET_malloc(sizeof(struct StatsContext)); |
@@ -397,28 +434,36 @@ churn_callback (void *cls, const char *emsg) | |||
397 | { | 434 | { |
398 | peers_running = GNUNET_TESTING_daemons_running(pg); | 435 | peers_running = GNUNET_TESTING_daemons_running(pg); |
399 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 436 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
400 | "Round %lu, churn finished successfully.\n", current_round); | 437 | "Round %lu, churn finished successfully.\n", |
438 | current_round); | ||
401 | GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 439 | GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
402 | GNUNET_asprintf(&temp_output_file, "%s%lu.dot", topology_file, current_round); | 440 | GNUNET_asprintf(&temp_output_file, |
441 | "%s%lu.dot", | ||
442 | topology_file, | ||
443 | current_round); | ||
403 | GNUNET_TESTING_peergroup_topology_to_file(pg, | 444 | GNUNET_TESTING_peergroup_topology_to_file(pg, |
404 | temp_output_file, | 445 | temp_output_file, |
405 | &topology_output_callback, | 446 | &topology_output_callback, |
406 | NULL); | 447 | NULL); |
407 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", temp_output_file); | 448 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
449 | "Writing topology to file %s\n", | ||
450 | temp_output_file); | ||
408 | GNUNET_free(temp_output_file); | 451 | GNUNET_free(temp_output_file); |
409 | } | 452 | } |
410 | else | 453 | else |
411 | { | 454 | { |
412 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 455 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
413 | "Round %lu, churn FAILED!!\n", current_round); | 456 | "Round %lu, churn FAILED!!\n", |
457 | current_round); | ||
414 | GNUNET_SCHEDULER_cancel(shutdown_handle); | 458 | GNUNET_SCHEDULER_cancel(shutdown_handle); |
415 | GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); | 459 | GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); |
416 | } | 460 | } |
417 | } | 461 | } |
418 | 462 | ||
463 | |||
419 | static void | 464 | static void |
420 | churn_peers (void *cls, | 465 | churn_peers (void *cls, |
421 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 466 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
422 | { | 467 | { |
423 | peers_running = GNUNET_TESTING_daemons_running(pg); | 468 | peers_running = GNUNET_TESTING_daemons_running(pg); |
424 | churn_task = GNUNET_SCHEDULER_NO_TASK; | 469 | churn_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -427,14 +472,18 @@ churn_peers (void *cls, | |||
427 | /* Nothing to do... */ | 472 | /* Nothing to do... */ |
428 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); | 473 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); |
429 | GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 474 | GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
430 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); | 475 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, |
431 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", current_round); | 476 | &disconnect_nse_peers, NULL); |
477 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
478 | "Round %lu, doing nothing!\n", | ||
479 | current_round); | ||
432 | } | 480 | } |
433 | else | 481 | else |
434 | { | 482 | { |
435 | if (peers_next_round > num_peers) | 483 | if (peers_next_round > num_peers) |
436 | { | 484 | { |
437 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Asked to turn on more peers than have!!\n"); | 485 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
486 | "Asked to turn on more peers than have!!\n"); | ||
438 | GNUNET_SCHEDULER_cancel(shutdown_handle); | 487 | GNUNET_SCHEDULER_cancel(shutdown_handle); |
439 | GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); | 488 | GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); |
440 | } | 489 | } |
@@ -476,23 +525,27 @@ my_cb (void *cls, | |||
476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
477 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); | 526 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); |
478 | #endif | 527 | #endif |
479 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", total_connections); | 528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
529 | "Have %u connections\n", total_connections); | ||
480 | if (data_file != NULL) | 530 | if (data_file != NULL) |
481 | { | 531 | { |
482 | buf = NULL; | 532 | buf = NULL; |
483 | buf_len = GNUNET_asprintf(&buf, "CONNECTIONS_0: %u\n", total_connections); | 533 | buf_len = GNUNET_asprintf(&buf, |
534 | "CONNECTIONS_0: %u\n", | ||
535 | total_connections); | ||
484 | if (buf_len > 0) | 536 | if (buf_len > 0) |
485 | GNUNET_DISK_file_write(data_file, buf, buf_len); | 537 | GNUNET_DISK_file_write(data_file, buf, buf_len); |
486 | GNUNET_free_non_null(buf); | 538 | GNUNET_free (buf); |
487 | } | 539 | } |
488 | peers_running = GNUNET_TESTING_daemons_running(pg); | 540 | peers_running = GNUNET_TESTING_daemons_running(pg); |
489 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); | 541 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); |
490 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); | 542 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); |
491 | } | 543 | } |
492 | 544 | ||
545 | |||
493 | /** | 546 | /** |
494 | * Prototype of a function that will be called whenever | 547 | * Function that will be called whenever two daemons are connected by |
495 | * two daemons are connected by the testing library. | 548 | * the testing library. |
496 | * | 549 | * |
497 | * @param cls closure | 550 | * @param cls closure |
498 | * @param first peer id for first daemon | 551 | * @param first peer id for first daemon |
@@ -504,19 +557,17 @@ my_cb (void *cls, | |||
504 | * @param second_daemon handle for the second daemon | 557 | * @param second_daemon handle for the second daemon |
505 | * @param emsg error message (NULL on success) | 558 | * @param emsg error message (NULL on success) |
506 | */ | 559 | */ |
507 | void connect_cb (void *cls, | 560 | static void |
508 | const struct GNUNET_PeerIdentity *first, | 561 | connect_cb (void *cls, |
509 | const struct GNUNET_PeerIdentity *second, | 562 | const struct GNUNET_PeerIdentity *first, |
510 | uint32_t distance, | 563 | const struct GNUNET_PeerIdentity *second, |
511 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 564 | uint32_t distance, |
512 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 565 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
513 | struct GNUNET_TESTING_Daemon *first_daemon, | 566 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
514 | struct GNUNET_TESTING_Daemon *second_daemon, | 567 | struct GNUNET_TESTING_Daemon *first_daemon, |
515 | const char *emsg) | 568 | struct GNUNET_TESTING_Daemon *second_daemon, |
569 | const char *emsg) | ||
516 | { | 570 | { |
517 | char *second_id; | ||
518 | |||
519 | second_id = GNUNET_strdup(GNUNET_i2s(second)); | ||
520 | if (emsg == NULL) | 571 | if (emsg == NULL) |
521 | total_connections++; | 572 | total_connections++; |
522 | } | 573 | } |
@@ -529,6 +580,7 @@ run (void *cls, | |||
529 | { | 580 | { |
530 | char *temp_str; | 581 | char *temp_str; |
531 | unsigned long long temp_wait; | 582 | unsigned long long temp_wait; |
583 | |||
532 | ok = 1; | 584 | ok = 1; |
533 | testing_cfg = GNUNET_CONFIGURATION_create(); | 585 | testing_cfg = GNUNET_CONFIGURATION_create(); |
534 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_load(testing_cfg, cfgfile)); | 586 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_load(testing_cfg, cfgfile)); |
@@ -538,60 +590,86 @@ run (void *cls, | |||
538 | "use_progressbars", | 590 | "use_progressbars", |
539 | "YES"); | 591 | "YES"); |
540 | #endif | 592 | #endif |
541 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", "num_peers", &num_peers)) | 593 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, |
594 | "testing", | ||
595 | "num_peers", &num_peers)) | ||
542 | { | 596 | { |
543 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); | 597 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); |
544 | return; | 598 | return; |
545 | } | 599 | } |
546 | 600 | ||
547 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", "wait_time", &temp_wait)) | 601 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, |
602 | "nse-profiler", | ||
603 | "wait_time", | ||
604 | &temp_wait)) | ||
548 | { | 605 | { |
549 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:wait_time is required!\n"); | 606 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
607 | "Option nse-profiler:wait_time is required!\n"); | ||
550 | return; | 608 | return; |
551 | } | 609 | } |
552 | 610 | ||
553 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", "connection_limit", &connection_limit)) | 611 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, |
612 | "nse-profiler", "connection_limit", | ||
613 | &connection_limit)) | ||
554 | { | 614 | { |
555 | connection_limit = 0; | 615 | connection_limit = 0; |
556 | } | 616 | } |
557 | 617 | ||
558 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", "topology_output_file", &topology_file)) | 618 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, |
619 | "nse-profiler", "topology_output_file", | ||
620 | &topology_file)) | ||
559 | { | 621 | { |
560 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:topology_output_file is required!\n"); | 622 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
623 | "Option nse-profiler:topology_output_file is required!\n"); | ||
561 | return; | 624 | return; |
562 | } | 625 | } |
563 | 626 | ||
564 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", "data_output_file", &data_filename)) | 627 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, |
628 | "nse-profiler", "data_output_file", | ||
629 | &data_filename)) | ||
565 | { | 630 | { |
566 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:data_output_file is required!\n"); | 631 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
632 | "Option nse-profiler:data_output_file is required!\n"); | ||
567 | return; | 633 | return; |
568 | } | 634 | } |
569 | 635 | ||
570 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, "nse-profiler", "skew_clock")) | 636 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, |
637 | "nse-profiler", | ||
638 | "skew_clock")) | ||
571 | { | 639 | { |
572 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Setting our clock as skewed...\n"); | 640 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
573 | clock_skew = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_TIME_UNIT_MINUTES.rel_value); | 641 | "Setting our clock as skewed...\n"); |
642 | clock_skew = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, | ||
643 | GNUNET_TIME_UNIT_MINUTES.rel_value); | ||
574 | } | 644 | } |
575 | 645 | ||
576 | 646 | ||
577 | data_file = GNUNET_DISK_file_open (data_filename, GNUNET_DISK_OPEN_READWRITE | 647 | data_file = GNUNET_DISK_file_open (data_filename, |
578 | | GNUNET_DISK_OPEN_CREATE, | 648 | GNUNET_DISK_OPEN_READWRITE |
579 | GNUNET_DISK_PERM_USER_READ | | 649 | | GNUNET_DISK_OPEN_CREATE, |
580 | GNUNET_DISK_PERM_USER_WRITE); | 650 | GNUNET_DISK_PERM_USER_READ | |
651 | GNUNET_DISK_PERM_USER_WRITE); | ||
581 | if (data_file == NULL) | 652 | if (data_file == NULL) |
582 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", data_filename); | 653 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
654 | "Failed to open %s for output!\n", | ||
655 | data_filename); | ||
583 | GNUNET_free(data_filename); | 656 | GNUNET_free(data_filename); |
584 | 657 | ||
585 | wait_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_wait); | 658 | wait_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_wait); |
586 | 659 | ||
587 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, "nse-profiler", "output_file", &temp_str)) | 660 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, |
661 | "nse-profiler", | ||
662 | "output_file", | ||
663 | &temp_str)) | ||
588 | { | 664 | { |
589 | output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE | 665 | output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE |
590 | | GNUNET_DISK_OPEN_CREATE, | 666 | | GNUNET_DISK_OPEN_CREATE, |
591 | GNUNET_DISK_PERM_USER_READ | | 667 | GNUNET_DISK_PERM_USER_READ | |
592 | GNUNET_DISK_PERM_USER_WRITE); | 668 | GNUNET_DISK_PERM_USER_WRITE); |
593 | if (output_file == NULL) | 669 | if (output_file == NULL) |
594 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", temp_str); | 670 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
671 | "Failed to open %s for output!\n", | ||
672 | temp_str); | ||
595 | } | 673 | } |
596 | GNUNET_free_non_null(temp_str); | 674 | GNUNET_free_non_null(temp_str); |
597 | 675 | ||
@@ -602,7 +680,9 @@ run (void *cls, | |||
602 | &my_cb, NULL, | 680 | &my_cb, NULL, |
603 | NULL); | 681 | NULL); |
604 | GNUNET_assert (pg != NULL); | 682 | GNUNET_assert (pg != NULL); |
605 | shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever(), &shutdown_task, NULL); | 683 | shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever(), |
684 | &shutdown_task, | ||
685 | NULL); | ||
606 | } | 686 | } |
607 | 687 | ||
608 | 688 | ||
@@ -617,6 +697,7 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
617 | GNUNET_GETOPT_OPTION_END | 697 | GNUNET_GETOPT_OPTION_END |
618 | }; | 698 | }; |
619 | 699 | ||
700 | |||
620 | int | 701 | int |
621 | main (int argc, char *argv[]) | 702 | main (int argc, char *argv[]) |
622 | { | 703 | { |
@@ -634,7 +715,6 @@ main (int argc, char *argv[]) | |||
634 | argv, "nse-profiler", gettext_noop | 715 | argv, "nse-profiler", gettext_noop |
635 | ("Run a test of the NSE service."), | 716 | ("Run a test of the NSE service."), |
636 | options, &run, &ok); | 717 | options, &run, &ok); |
637 | |||
638 | GNUNET_DISK_directory_remove ("/tmp/nse-profiler"); | 718 | GNUNET_DISK_directory_remove ("/tmp/nse-profiler"); |
639 | return ret; | 719 | return ret; |
640 | } | 720 | } |