diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-05 12:45:58 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-05 12:45:58 +0000 |
commit | 5de4e9f66d2b9cd4158041cd5236dbfa3d4c2965 (patch) | |
tree | d60c2b1e13ea600b84895f23ec2a76a0e905a6cd /src | |
parent | c4dec31821271d83e8895de9df11beaeb7154266 (diff) | |
download | gnunet-5de4e9f66d2b9cd4158041cd5236dbfa3d4c2965.tar.gz gnunet-5de4e9f66d2b9cd4158041cd5236dbfa3d4c2965.zip |
clean up
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 52 |
1 files changed, 5 insertions, 47 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 1128c7d94..0b7524bbc 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -973,7 +973,7 @@ static void disconnect_neighbour (struct NeighbourList *n, int check); | |||
973 | static void try_transmission_to_peer (struct NeighbourList *n); | 973 | static void try_transmission_to_peer (struct NeighbourList *n); |
974 | 974 | ||
975 | 975 | ||
976 | struct ATS_info * ats_init (); | 976 | void ats_init (); |
977 | 977 | ||
978 | void ats_shutdown ( ); | 978 | void ats_shutdown ( ); |
979 | 979 | ||
@@ -5657,7 +5657,7 @@ static int available_ressources = 7; | |||
5657 | 5657 | ||
5658 | struct ATS_info | 5658 | struct ATS_info |
5659 | { | 5659 | { |
5660 | struct GNUNET_CONTAINER_MultiHashMap * peers; | 5660 | |
5661 | /** | 5661 | /** |
5662 | * Time of last execution | 5662 | * Time of last execution |
5663 | */ | 5663 | */ |
@@ -6336,33 +6336,9 @@ ats_schedule_calculation (void *cls, | |||
6336 | &ats_schedule_calculation, ats); | 6336 | &ats_schedule_calculation, ats); |
6337 | } | 6337 | } |
6338 | 6338 | ||
6339 | 6339 | void ats_init () | |
6340 | int ats_map_remove_peer (void *cls, | ||
6341 | const GNUNET_HashCode * key, | ||
6342 | void *value) | ||
6343 | { | ||
6344 | |||
6345 | struct ATS_peer * p = (struct ATS_peer *) value; | ||
6346 | #if DEBUG_ATS | ||
6347 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "map_remove_peer_it: `%s'\n", GNUNET_i2s(&p->peer)); | ||
6348 | #endif | ||
6349 | /* cleanup peer */ | ||
6350 | GNUNET_free(p); | ||
6351 | |||
6352 | return GNUNET_YES; | ||
6353 | } | ||
6354 | |||
6355 | |||
6356 | |||
6357 | struct ATS_info * ats_init () | ||
6358 | { | 6340 | { |
6359 | struct ATS_info * ats; | ||
6360 | #if DEBUG_ATS | ||
6361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_init\n"); | ||
6362 | #endif | ||
6363 | ats = GNUNET_malloc(sizeof (struct ATS_info)); | 6341 | ats = GNUNET_malloc(sizeof (struct ATS_info)); |
6364 | ats->peers = GNUNET_CONTAINER_multihashmap_create(10); | ||
6365 | GNUNET_assert(ats->peers!=NULL); | ||
6366 | 6342 | ||
6367 | ats->min_delta = ATS_MIN_INTERVAL; | 6343 | ats->min_delta = ATS_MIN_INTERVAL; |
6368 | ats->exec_intervall = ATS_EXEC_INTERVAL; | 6344 | ats->exec_intervall = ATS_EXEC_INTERVAL; |
@@ -6378,6 +6354,7 @@ struct ATS_info * ats_init () | |||
6378 | unsigned long long value; | 6354 | unsigned long long value; |
6379 | int c = 0; | 6355 | int c = 0; |
6380 | 6356 | ||
6357 | |||
6381 | while (cur != NULL) | 6358 | while (cur != NULL) |
6382 | { | 6359 | { |
6383 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Loading resource cost for plugin `%s'\n", cur->short_name); | 6360 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Loading resource cost for plugin `%s'\n", cur->short_name); |
@@ -6411,8 +6388,6 @@ struct ATS_info * ats_init () | |||
6411 | } | 6388 | } |
6412 | 6389 | ||
6413 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); | 6390 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); |
6414 | |||
6415 | return ats; | ||
6416 | } | 6391 | } |
6417 | 6392 | ||
6418 | 6393 | ||
@@ -6443,8 +6418,6 @@ void ats_shutdown () | |||
6443 | p = ats->head; | 6418 | p = ats->head; |
6444 | } | 6419 | } |
6445 | 6420 | ||
6446 | GNUNET_CONTAINER_multihashmap_iterate (ats->peers,ats_map_remove_peer,NULL); | ||
6447 | GNUNET_CONTAINER_multihashmap_destroy (ats->peers); | ||
6448 | GNUNET_free (ats); | 6421 | GNUNET_free (ats); |
6449 | } | 6422 | } |
6450 | 6423 | ||
@@ -6465,14 +6438,6 @@ void ats_notify_peer_connect ( | |||
6465 | #endif | 6438 | #endif |
6466 | c++; | 6439 | c++; |
6467 | } | 6440 | } |
6468 | /* check if peer is already known */ | ||
6469 | if (!GNUNET_CONTAINER_multihashmap_contains (ats->peers,&peer->hashPubKey)) | ||
6470 | { | ||
6471 | struct ATS_peer * p = GNUNET_malloc (sizeof (struct ATS_peer)); | ||
6472 | memcpy(&p->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | ||
6473 | GNUNET_CONTAINER_multihashmap_put(ats->peers, &p->peer.hashPubKey, p, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
6474 | } | ||
6475 | |||
6476 | ats_calculate_bandwidth_distribution(ats); | 6441 | ats_calculate_bandwidth_distribution(ats); |
6477 | } | 6442 | } |
6478 | 6443 | ||
@@ -6482,13 +6447,6 @@ void ats_notify_peer_disconnect ( | |||
6482 | #if DEBUG_ATS | 6447 | #if DEBUG_ATS |
6483 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_disconnect: %s\n",GNUNET_i2s(peer)); | 6448 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_disconnect: %s\n",GNUNET_i2s(peer)); |
6484 | #endif | 6449 | #endif |
6485 | /* remove peer */ | ||
6486 | if (GNUNET_CONTAINER_multihashmap_contains (ats->peers, &peer->hashPubKey)) | ||
6487 | { | ||
6488 | ats_map_remove_peer(NULL, &peer->hashPubKey, GNUNET_CONTAINER_multihashmap_get (ats->peers, &peer->hashPubKey)); | ||
6489 | GNUNET_CONTAINER_multihashmap_remove_all (ats->peers, &peer->hashPubKey); | ||
6490 | } | ||
6491 | |||
6492 | ats_calculate_bandwidth_distribution (ats); | 6450 | ats_calculate_bandwidth_distribution (ats); |
6493 | } | 6451 | } |
6494 | 6452 | ||
@@ -6648,7 +6606,7 @@ run (void *cls, | |||
6648 | if (no_transports) | 6606 | if (no_transports) |
6649 | refresh_hello (); | 6607 | refresh_hello (); |
6650 | 6608 | ||
6651 | ats = ats_init(); | 6609 | ats_init(); |
6652 | 6610 | ||
6653 | #if DEBUG_TRANSPORT | 6611 | #if DEBUG_TRANSPORT |
6654 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); | 6612 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); |