diff options
-rw-r--r-- | src/transport/gnunet-transport-profiler.c | 71 |
1 files changed, 16 insertions, 55 deletions
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index e33a71d17..e1e8d0f08 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -122,7 +122,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
122 | /** | 122 | /** |
123 | * Try_connect handle | 123 | * Try_connect handle |
124 | */ | 124 | */ |
125 | static struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle; | 125 | static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; |
126 | 126 | ||
127 | static struct Iteration *ihead; | 127 | static struct Iteration *ihead; |
128 | 128 | ||
@@ -177,17 +177,16 @@ shutdown_task (void *cls, | |||
177 | float stddev_rate; | 177 | float stddev_rate; |
178 | float stddev_duration; | 178 | float stddev_duration; |
179 | 179 | ||
180 | if (NULL != tc_handle) | 180 | if (NULL != ats_sh) |
181 | { | 181 | { |
182 | GNUNET_TRANSPORT_try_connect_cancel (tc_handle); | 182 | GNUNET_ATS_connectivity_suggest_cancel (ats_sh); |
183 | tc_handle = NULL; | 183 | ats_sh = NULL; |
184 | } | 184 | } |
185 | if (NULL != th) | 185 | if (NULL != th) |
186 | { | 186 | { |
187 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 187 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
188 | th = NULL; | 188 | th = NULL; |
189 | } | 189 | } |
190 | |||
191 | if (NULL != bl_handle ) | 190 | if (NULL != bl_handle ) |
192 | { | 191 | { |
193 | GNUNET_TRANSPORT_blacklist_cancel (bl_handle); | 192 | GNUNET_TRANSPORT_blacklist_cancel (bl_handle); |
@@ -406,10 +405,13 @@ static void | |||
406 | notify_connect (void *cls, | 405 | notify_connect (void *cls, |
407 | const struct GNUNET_PeerIdentity *peer) | 406 | const struct GNUNET_PeerIdentity *peer) |
408 | { | 407 | { |
409 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 408 | if (0 != memcmp (&pid, |
409 | peer, | ||
410 | sizeof(struct GNUNET_PeerIdentity))) | ||
410 | { | 411 | { |
411 | FPRINTF (stdout, | 412 | FPRINTF (stdout, |
412 | _("Connected to different peer `%s'\n"), GNUNET_i2s (&pid)); | 413 | _("Connected to different peer `%s'\n"), |
414 | GNUNET_i2s (&pid)); | ||
413 | return; | 415 | return; |
414 | } | 416 | } |
415 | 417 | ||
@@ -417,13 +419,6 @@ notify_connect (void *cls, | |||
417 | FPRINTF (stdout, | 419 | FPRINTF (stdout, |
418 | _("Successfully connected to `%s'\n"), | 420 | _("Successfully connected to `%s'\n"), |
419 | GNUNET_i2s (&pid)); | 421 | GNUNET_i2s (&pid)); |
420 | |||
421 | if (NULL != tc_handle) | ||
422 | { | ||
423 | GNUNET_TRANSPORT_try_connect_cancel (tc_handle); | ||
424 | tc_handle = NULL; | ||
425 | } | ||
426 | |||
427 | iteration_start (); | 422 | iteration_start (); |
428 | } | 423 | } |
429 | 424 | ||
@@ -476,49 +471,16 @@ notify_receive (void *cls, | |||
476 | } | 471 | } |
477 | 472 | ||
478 | 473 | ||
479 | static void | ||
480 | try_connect_cb (void *cls, | ||
481 | const int result) | ||
482 | { | ||
483 | static int retries = 0; | ||
484 | |||
485 | if (GNUNET_OK == result) | ||
486 | { | ||
487 | tc_handle = NULL; | ||
488 | return; | ||
489 | } | ||
490 | |||
491 | retries++; | ||
492 | if (retries < 10) | ||
493 | { | ||
494 | if (verbosity > 0) | ||
495 | FPRINTF (stdout, _("Retrying to connect to `%s'\n"), GNUNET_i2s (&pid)); | ||
496 | |||
497 | tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, | ||
498 | NULL); | ||
499 | } | ||
500 | else | ||
501 | { | ||
502 | FPRINTF (stderr, | ||
503 | "%s", | ||
504 | _("Failed to send connect request to transport service\n")); | ||
505 | if (NULL != end) | ||
506 | GNUNET_SCHEDULER_cancel (end); | ||
507 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
508 | ret = 1; | ||
509 | return; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | |||
514 | static int | 474 | static int |
515 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer) | 475 | blacklist_cb (void *cls, |
476 | const struct GNUNET_PeerIdentity *peer) | ||
516 | { | 477 | { |
517 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) | 478 | if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) |
518 | { | 479 | { |
519 | if (verbosity > 0) | 480 | if (verbosity > 0) |
520 | FPRINTF (stdout, | 481 | FPRINTF (stdout, |
521 | _("Denying connection to `%s'\n"), GNUNET_i2s (peer)); | 482 | _("Denying connection to `%s'\n"), |
483 | GNUNET_i2s (peer)); | ||
522 | return GNUNET_SYSERR; | 484 | return GNUNET_SYSERR; |
523 | } | 485 | } |
524 | 486 | ||
@@ -607,10 +569,9 @@ testservice_task (void *cls, int result) | |||
607 | bl_handle = GNUNET_TRANSPORT_blacklist (cfg, | 569 | bl_handle = GNUNET_TRANSPORT_blacklist (cfg, |
608 | &blacklist_cb, | 570 | &blacklist_cb, |
609 | NULL); | 571 | NULL); |
610 | tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, | 572 | ats_sh = GNUNET_ATS_connectivity_suggest (ats, |
611 | &try_connect_cb, | 573 | &pid, |
612 | NULL); | 574 | 1); |
613 | |||
614 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 575 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
615 | &shutdown_task, | 576 | &shutdown_task, |
616 | NULL); | 577 | NULL); |