aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats2_simple.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/plugin_ats2_simple.c')
-rw-r--r--src/ats/plugin_ats2_simple.c698
1 files changed, 352 insertions, 346 deletions
diff --git a/src/ats/plugin_ats2_simple.c b/src/ats/plugin_ats2_simple.c
index 90566c561..3062b6019 100644
--- a/src/ats/plugin_ats2_simple.c
+++ b/src/ats/plugin_ats2_simple.c
@@ -31,7 +31,7 @@
31#include "gnunet_hello_lib.h" 31#include "gnunet_hello_lib.h"
32#include "gnunet_peerstore_service.h" 32#include "gnunet_peerstore_service.h"
33 33
34#define LOG(kind, ...) GNUNET_log_from(kind, "ats-simple", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "ats-simple", __VA_ARGS__)
35 35
36 36
37/** 37/**
@@ -68,7 +68,8 @@ struct Peer;
68/** 68/**
69 * Entry in list of addresses we could try per peer. 69 * Entry in list of addresses we could try per peer.
70 */ 70 */
71struct Hello { 71struct Hello
72{
72 /** 73 /**
73 * Kept in a DLL. 74 * Kept in a DLL.
74 */ 75 */
@@ -121,7 +122,8 @@ struct Hello {
121 * Internal representation of a session by the plugin. 122 * Internal representation of a session by the plugin.
122 * (If desired, plugin may just use NULL.) 123 * (If desired, plugin may just use NULL.)
123 */ 124 */
124struct GNUNET_ATS_SessionHandle { 125struct GNUNET_ATS_SessionHandle
126{
125 /** 127 /**
126 * Kept in DLL per peer. 128 * Kept in DLL per peer.
127 */ 129 */
@@ -189,7 +191,8 @@ struct GNUNET_ATS_SessionHandle {
189 * Information about preferences and sessions we track 191 * Information about preferences and sessions we track
190 * per peer. 192 * per peer.
191 */ 193 */
192struct Peer { 194struct Peer
195{
193 /** 196 /**
194 * Kept in DLL per peer. 197 * Kept in DLL per peer.
195 */ 198 */
@@ -247,7 +250,8 @@ struct Peer {
247/** 250/**
248 * Representation of a network (to be expanded...) 251 * Representation of a network (to be expanded...)
249 */ 252 */
250struct Network { 253struct Network
254{
251 /** 255 /**
252 * Total inbound quota 256 * Total inbound quota
253 */ 257 */
@@ -268,7 +272,8 @@ struct Network {
268/** 272/**
269 * A handle for the proportional solver 273 * A handle for the proportional solver
270 */ 274 */
271struct SimpleHandle { 275struct SimpleHandle
276{
272 /** 277 /**
273 * Our execution environment. 278 * Our execution environment.
274 */ 279 */
@@ -306,9 +311,9 @@ struct SimpleHandle {
306 * @return NULL for not found 311 * @return NULL for not found
307 */ 312 */
308struct Peer * 313struct Peer *
309lookup_peer(struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid) 314lookup_peer (struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid)
310{ 315{
311 return GNUNET_CONTAINER_multipeermap_get(h->peers, pid); 316 return GNUNET_CONTAINER_multipeermap_get (h->peers, pid);
312} 317}
313 318
314 319
@@ -320,7 +325,7 @@ lookup_peer(struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid)
320 * @return #GNUNET_YES if no information is left in @a p 325 * @return #GNUNET_YES if no information is left in @a p
321 */ 326 */
322static int 327static int
323peer_test_dead(struct Peer *p) 328peer_test_dead (struct Peer *p)
324{ 329{
325 for (enum GNUNET_MQ_PreferenceKind pk = 0; pk < GNUNET_MQ_PREFERENCE_COUNT; 330 for (enum GNUNET_MQ_PreferenceKind pk = 0; pk < GNUNET_MQ_PREFERENCE_COUNT;
326 pk++) 331 pk++)
@@ -340,17 +345,17 @@ peer_test_dead(struct Peer *p)
340 * @param hello[in,out] address suggestion to make 345 * @param hello[in,out] address suggestion to make
341 */ 346 */
342static void 347static void
343suggest_hello(struct Hello *hello) 348suggest_hello (struct Hello *hello)
344{ 349{
345 struct Peer *p = hello->peer; 350 struct Peer *p = hello->peer;
346 struct SimpleHandle *h = p->h; 351 struct SimpleHandle *h = p->h;
347 352
348 p->last_suggestion = hello->last_attempt = GNUNET_TIME_absolute_get(); 353 p->last_suggestion = hello->last_attempt = GNUNET_TIME_absolute_get ();
349 hello->backoff = 354 hello->backoff =
350 GNUNET_TIME_randomized_backoff(hello->backoff, 355 GNUNET_TIME_randomized_backoff (hello->backoff,
351 GNUNET_TIME_absolute_get_remaining( 356 GNUNET_TIME_absolute_get_remaining (
352 hello->expiration)); 357 hello->expiration));
353 h->env->suggest_cb(h->env->cls, &p->pid, hello->address); 358 h->env->suggest_cb (h->env->cls, &p->pid, hello->address);
354} 359}
355 360
356 361
@@ -369,7 +374,7 @@ suggest_hello(struct Hello *hello)
369 * @param cls a `struct Peer` 374 * @param cls a `struct Peer`
370 */ 375 */
371static void 376static void
372suggest_start_cb(void *cls) 377suggest_start_cb (void *cls)
373{ 378{
374 struct Peer *p = cls; 379 struct Peer *p = cls;
375 struct GNUNET_TIME_Relative delay = GNUNET_TIME_UNIT_ZERO; 380 struct GNUNET_TIME_Relative delay = GNUNET_TIME_UNIT_ZERO;
@@ -387,63 +392,63 @@ suggest_start_cb(void *cls)
387 /* calculate square of number of sessions */ 392 /* calculate square of number of sessions */
388 num_sessions++; /* start with 1, even if we have zero sessions */ 393 num_sessions++; /* start with 1, even if we have zero sessions */
389 if (num_sessions < UINT16_MAX) 394 if (num_sessions < UINT16_MAX)
390 sq = num_sessions * (uint32_t)num_sessions; 395 sq = num_sessions * (uint32_t) num_sessions;
391 else 396 else
392 sq = UINT32_MAX; 397 sq = UINT32_MAX;
393 xdelay = 398 xdelay =
394 GNUNET_TIME_randomized_backoff(GNUNET_TIME_relative_multiply(SUGGEST_FREQ, 399 GNUNET_TIME_randomized_backoff (GNUNET_TIME_relative_multiply (SUGGEST_FREQ,
395 sq), 400 sq),
396 GNUNET_TIME_UNIT_FOREVER_REL); 401 GNUNET_TIME_UNIT_FOREVER_REL);
397 xnext = GNUNET_TIME_relative_to_absolute(xdelay); 402 xnext = GNUNET_TIME_relative_to_absolute (xdelay);
398 403
399 p->task = NULL; 404 p->task = NULL;
400 while (0 == delay.rel_value_us) 405 while (0 == delay.rel_value_us)
406 {
407 struct Hello *next;
408 struct GNUNET_TIME_Absolute xmax;
409
410 if (NULL != hello)
401 { 411 {
402 struct Hello *next; 412 /* We went through the loop already once and found
403 struct GNUNET_TIME_Absolute xmax; 413 a HELLO that is due *now*, so make a suggestion! */
404 414 GNUNET_break (NULL == hello->sh);
405 if (NULL != hello) 415 suggest_hello (hello);
406 { 416 hello = NULL;
407 /* We went through the loop already once and found 417 hpt = GNUNET_TIME_UNIT_FOREVER_ABS;
408 a HELLO that is due *now*, so make a suggestion! */
409 GNUNET_break(NULL == hello->sh);
410 suggest_hello(hello);
411 hello = NULL;
412 hpt = GNUNET_TIME_UNIT_FOREVER_ABS;
413 }
414 for (struct Hello *pos = p->h_head; NULL != pos; pos = next)
415 {
416 struct GNUNET_TIME_Absolute pt;
417
418 next = pos->next;
419 if (NULL != pos->sh)
420 continue;
421 if (0 ==
422 GNUNET_TIME_absolute_get_remaining(pos->expiration).rel_value_us)
423 {
424 /* expired, remove! */
425 GNUNET_CONTAINER_DLL_remove(p->h_head, p->h_tail, pos);
426 GNUNET_free(pos);
427 continue;
428 }
429 pt = GNUNET_TIME_absolute_add(pos->last_attempt, pos->backoff);
430 if ((NULL == hello) || (pt.abs_value_us < hpt.abs_value_us))
431 {
432 hello = pos;
433 hpt = pt;
434 }
435 }
436 if (NULL == hello)
437 return; /* no HELLOs that could still be tried */
438
439 /* hpt is now the *earliest* possible time for any HELLO
440 but we might not want to go for as early as possible for
441 this peer. So the actual time is the max of the earliest
442 HELLO and the 'xnext' */
443 xmax = GNUNET_TIME_absolute_max(hpt, xnext);
444 delay = GNUNET_TIME_absolute_get_remaining(xmax);
445 } 418 }
446 p->task = GNUNET_SCHEDULER_add_delayed(delay, &suggest_start_cb, p); 419 for (struct Hello *pos = p->h_head; NULL != pos; pos = next)
420 {
421 struct GNUNET_TIME_Absolute pt;
422
423 next = pos->next;
424 if (NULL != pos->sh)
425 continue;
426 if (0 ==
427 GNUNET_TIME_absolute_get_remaining (pos->expiration).rel_value_us)
428 {
429 /* expired, remove! */
430 GNUNET_CONTAINER_DLL_remove (p->h_head, p->h_tail, pos);
431 GNUNET_free (pos);
432 continue;
433 }
434 pt = GNUNET_TIME_absolute_add (pos->last_attempt, pos->backoff);
435 if ((NULL == hello) || (pt.abs_value_us < hpt.abs_value_us))
436 {
437 hello = pos;
438 hpt = pt;
439 }
440 }
441 if (NULL == hello)
442 return; /* no HELLOs that could still be tried */
443
444 /* hpt is now the *earliest* possible time for any HELLO
445 but we might not want to go for as early as possible for
446 this peer. So the actual time is the max of the earliest
447 HELLO and the 'xnext' */
448 xmax = GNUNET_TIME_absolute_max (hpt, xnext);
449 delay = GNUNET_TIME_absolute_get_remaining (xmax);
450 }
451 p->task = GNUNET_SCHEDULER_add_delayed (delay, &suggest_start_cb, p);
447} 452}
448 453
449 454
@@ -455,9 +460,9 @@ suggest_start_cb(void *cls)
455 * @param emsg error message, or NULL if no errors 460 * @param emsg error message, or NULL if no errors
456 */ 461 */
457static void 462static void
458watch_cb(void *cls, 463watch_cb (void *cls,
459 const struct GNUNET_PEERSTORE_Record *record, 464 const struct GNUNET_PEERSTORE_Record *record,
460 const char *emsg) 465 const char *emsg)
461{ 466{
462 struct Peer *p = cls; 467 struct Peer *p = cls;
463 char *addr; 468 char *addr;
@@ -466,65 +471,65 @@ watch_cb(void *cls,
466 struct GNUNET_TIME_Absolute expiration; 471 struct GNUNET_TIME_Absolute expiration;
467 struct Hello *hello; 472 struct Hello *hello;
468 473
469 if (0 != GNUNET_memcmp(&p->pid, &record->peer)) 474 if (0 != GNUNET_memcmp (&p->pid, &record->peer))
470 { 475 {
471 GNUNET_break(0); 476 GNUNET_break (0);
472 return; 477 return;
473 } 478 }
474 if (0 != strcmp(record->key, GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY)) 479 if (0 != strcmp (record->key, GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY))
475 { 480 {
476 GNUNET_break(0); 481 GNUNET_break (0);
477 return; 482 return;
478 } 483 }
479 addr = GNUNET_HELLO_extract_address(record->value, 484 addr = GNUNET_HELLO_extract_address (record->value,
480 record->value_size, 485 record->value_size,
481 &p->pid, 486 &p->pid,
482 &nt, 487 &nt,
483 &expiration); 488 &expiration);
484 if (NULL == addr) 489 if (NULL == addr)
485 return; /* invalid hello, bad signature, other problem */ 490 return; /* invalid hello, bad signature, other problem */
486 if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us) 491 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
487 { 492 {
488 /* expired, ignore */ 493 /* expired, ignore */
489 GNUNET_free(addr); 494 GNUNET_free (addr);
490 return; 495 return;
491 } 496 }
492 /* check if addr is already known */ 497 /* check if addr is already known */
493 for (struct Hello *he = p->h_head; NULL != he; he = he->next) 498 for (struct Hello *he = p->h_head; NULL != he; he = he->next)
499 {
500 if (0 != strcmp (he->address, addr))
501 continue;
502 if (he->expiration.abs_value_us < expiration.abs_value_us)
494 { 503 {
495 if (0 != strcmp(he->address, addr)) 504 he->expiration = expiration;
496 continue; 505 he->nt = nt;
497 if (he->expiration.abs_value_us < expiration.abs_value_us)
498 {
499 he->expiration = expiration;
500 he->nt = nt;
501 }
502 GNUNET_free(addr);
503 return;
504 } 506 }
507 GNUNET_free (addr);
508 return;
509 }
505 /* create new HELLO */ 510 /* create new HELLO */
506 alen = strlen(addr) + 1; 511 alen = strlen (addr) + 1;
507 hello = GNUNET_malloc(sizeof(struct Hello) + alen); 512 hello = GNUNET_malloc (sizeof(struct Hello) + alen);
508 hello->address = (const char *)&hello[1]; 513 hello->address = (const char *) &hello[1];
509 hello->expiration = expiration; 514 hello->expiration = expiration;
510 hello->nt = nt; 515 hello->nt = nt;
511 hello->peer = p; 516 hello->peer = p;
512 memcpy(&hello[1], addr, alen); 517 memcpy (&hello[1], addr, alen);
513 GNUNET_CONTAINER_DLL_insert(p->h_head, p->h_tail, hello); 518 GNUNET_CONTAINER_DLL_insert (p->h_head, p->h_tail, hello);
514 /* check if sh for this HELLO already exists */ 519 /* check if sh for this HELLO already exists */
515 for (struct GNUNET_ATS_SessionHandle *sh = p->sh_head; NULL != sh; 520 for (struct GNUNET_ATS_SessionHandle *sh = p->sh_head; NULL != sh;
516 sh = sh->next) 521 sh = sh->next)
517 { 522 {
518 if ((NULL == sh->address) || (0 != strcmp(sh->address, addr))) 523 if ((NULL == sh->address) || (0 != strcmp (sh->address, addr)))
519 continue; 524 continue;
520 GNUNET_assert(NULL == sh->hello); 525 GNUNET_assert (NULL == sh->hello);
521 sh->hello = hello; 526 sh->hello = hello;
522 hello->sh = sh; 527 hello->sh = sh;
523 break; 528 break;
524 } 529 }
525 GNUNET_free(addr); 530 GNUNET_free (addr);
526 if (NULL == p->task) 531 if (NULL == p->task)
527 p->task = GNUNET_SCHEDULER_add_now(&suggest_start_cb, p); 532 p->task = GNUNET_SCHEDULER_add_now (&suggest_start_cb, p);
528} 533}
529 534
530 535
@@ -536,27 +541,27 @@ watch_cb(void *cls,
536 * @return a peer handle 541 * @return a peer handle
537 */ 542 */
538static struct Peer * 543static struct Peer *
539peer_add(struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid) 544peer_add (struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid)
540{ 545{
541 struct Peer *p = lookup_peer(h, pid); 546 struct Peer *p = lookup_peer (h, pid);
542 547
543 if (NULL != p) 548 if (NULL != p)
544 return p; 549 return p;
545 p = GNUNET_new(struct Peer); 550 p = GNUNET_new (struct Peer);
546 p->h = h; 551 p->h = h;
547 p->pid = *pid; 552 p->pid = *pid;
548 p->wc = GNUNET_PEERSTORE_watch(h->ps, 553 p->wc = GNUNET_PEERSTORE_watch (h->ps,
549 "transport", 554 "transport",
550 &p->pid, 555 &p->pid,
551 GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, 556 GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY,
552 &watch_cb, 557 &watch_cb,
553 p); 558 p);
554 GNUNET_assert(GNUNET_YES == 559 GNUNET_assert (GNUNET_YES ==
555 GNUNET_CONTAINER_multipeermap_put( 560 GNUNET_CONTAINER_multipeermap_put (
556 h->peers, 561 h->peers,
557 &p->pid, 562 &p->pid,
558 p, 563 p,
559 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 564 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
560 565
561 return p; 566 return p;
562} 567}
@@ -569,31 +574,31 @@ peer_add(struct SimpleHandle *h, const struct GNUNET_PeerIdentity *pid)
569 * @param p the peer to free 574 * @param p the peer to free
570 */ 575 */
571static void 576static void
572peer_free(struct Peer *p) 577peer_free (struct Peer *p)
573{ 578{
574 struct SimpleHandle *h = p->h; 579 struct SimpleHandle *h = p->h;
575 struct Hello *hello; 580 struct Hello *hello;
576 581
577 GNUNET_assert(NULL == p->sh_head); 582 GNUNET_assert (NULL == p->sh_head);
578 while (NULL != (hello = p->h_head)) 583 while (NULL != (hello = p->h_head))
579 { 584 {
580 GNUNET_CONTAINER_DLL_remove(p->h_head, p->h_tail, hello); 585 GNUNET_CONTAINER_DLL_remove (p->h_head, p->h_tail, hello);
581 GNUNET_assert(NULL == hello->sh); 586 GNUNET_assert (NULL == hello->sh);
582 GNUNET_free(hello); 587 GNUNET_free (hello);
583 } 588 }
584 if (NULL != p->task) 589 if (NULL != p->task)
585 { 590 {
586 GNUNET_SCHEDULER_cancel(p->task); 591 GNUNET_SCHEDULER_cancel (p->task);
587 p->task = NULL; 592 p->task = NULL;
588 } 593 }
589 if (NULL != p->wc) 594 if (NULL != p->wc)
590 { 595 {
591 GNUNET_PEERSTORE_watch_cancel(p->wc); 596 GNUNET_PEERSTORE_watch_cancel (p->wc);
592 p->wc = NULL; 597 p->wc = NULL;
593 } 598 }
594 GNUNET_assert(GNUNET_YES == 599 GNUNET_assert (GNUNET_YES ==
595 GNUNET_CONTAINER_multipeermap_remove(h->peers, &p->pid, p)); 600 GNUNET_CONTAINER_multipeermap_remove (h->peers, &p->pid, p));
596 GNUNET_free(p); 601 GNUNET_free (p);
597} 602}
598 603
599 604
@@ -604,7 +609,7 @@ peer_free(struct Peer *p)
604 * @param sh session handle to consider updating transport for 609 * @param sh session handle to consider updating transport for
605 */ 610 */
606static void 611static void
607consider_notify_transport(struct GNUNET_ATS_SessionHandle *sh) 612consider_notify_transport (struct GNUNET_ATS_SessionHandle *sh)
608{ 613{
609 struct Peer *peer = sh->peer; 614 struct Peer *peer = sh->peer;
610 struct SimpleHandle *h = peer->h; 615 struct SimpleHandle *h = peer->h;
@@ -615,15 +620,15 @@ consider_notify_transport(struct GNUNET_ATS_SessionHandle *sh)
615 int64_t delta_in; 620 int64_t delta_in;
616 int64_t delta_out; 621 int64_t delta_out;
617 622
618 delay = GNUNET_TIME_absolute_get_duration(sh->last_allocation); 623 delay = GNUNET_TIME_absolute_get_duration (sh->last_allocation);
619 /* A significant change is more than 10% of the quota, 624 /* A significant change is more than 10% of the quota,
620 which is given in bytes/second */ 625 which is given in bytes/second */
621 sig_in = h->networks[nt].total_quota_in * (delay.rel_value_us / 1000LL) / 626 sig_in = h->networks[nt].total_quota_in * (delay.rel_value_us / 1000LL)
622 1000LL / 10; 627 / 1000LL / 10;
623 sig_out = h->networks[nt].total_quota_out * (delay.rel_value_us / 1000LL) / 628 sig_out = h->networks[nt].total_quota_out * (delay.rel_value_us / 1000LL)
624 1000LL / 10; 629 / 1000LL / 10;
625 delta_in = ((int64_t)ntohl(sh->bw_in.value__)) - ((int64_t)sh->target_in); 630 delta_in = ((int64_t) ntohl (sh->bw_in.value__)) - ((int64_t) sh->target_in);
626 delta_out = ((int64_t)ntohl(sh->bw_in.value__)) - ((int64_t)sh->target_in); 631 delta_out = ((int64_t) ntohl (sh->bw_in.value__)) - ((int64_t) sh->target_in);
627 /* we want the absolute values */ 632 /* we want the absolute values */
628 if (delta_in < 0) 633 if (delta_in < 0)
629 delta_in = -delta_in; 634 delta_in = -delta_in;
@@ -638,23 +643,24 @@ consider_notify_transport(struct GNUNET_ATS_SessionHandle *sh)
638 /* change is significant, tell transport! */ 643 /* change is significant, tell transport! */
639 if (sh->target_in > UINT32_MAX) 644 if (sh->target_in > UINT32_MAX)
640 sh->target_in = UINT32_MAX; 645 sh->target_in = UINT32_MAX;
641 sh->bw_in.value__ = htonl((uint32_t)sh->target_in); 646 sh->bw_in.value__ = htonl ((uint32_t) sh->target_in);
642 if (sh->target_out > UINT32_MAX) 647 if (sh->target_out > UINT32_MAX)
643 sh->target_out = UINT32_MAX; 648 sh->target_out = UINT32_MAX;
644 sh->bw_out.value__ = htonl((uint32_t)sh->target_out); 649 sh->bw_out.value__ = htonl ((uint32_t) sh->target_out);
645 sh->last_allocation = GNUNET_TIME_absolute_get(); 650 sh->last_allocation = GNUNET_TIME_absolute_get ();
646 h->env->allocate_cb(h->env->cls, 651 h->env->allocate_cb (h->env->cls,
647 sh->session, 652 sh->session,
648 &peer->pid, 653 &peer->pid,
649 sh->bw_in, 654 sh->bw_in,
650 sh->bw_out); 655 sh->bw_out);
651} 656}
652 657
653 658
654/** 659/**
655 * Closure for #update_counters and #update_allocation. 660 * Closure for #update_counters and #update_allocation.
656 */ 661 */
657struct Counters { 662struct Counters
663{
658 /** 664 /**
659 * Plugin's state. 665 * Plugin's state.
660 */ 666 */
@@ -698,103 +704,103 @@ struct Counters {
698 * @return #GNUNET_YES (continue to iterate) 704 * @return #GNUNET_YES (continue to iterate)
699 */ 705 */
700static int 706static int
701update_counters(void *cls, const struct GNUNET_PeerIdentity *pid, void *value) 707update_counters (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
702{ 708{
703 struct Counters *c = cls; 709 struct Counters *c = cls;
704 struct Peer *peer = value; 710 struct Peer *peer = value;
705 struct GNUNET_ATS_SessionHandle *best[GNUNET_MQ_PREFERENCE_COUNT]; 711 struct GNUNET_ATS_SessionHandle *best[GNUNET_MQ_PREFERENCE_COUNT];
706 712
707 (void)pid; 713 (void) pid;
708 if (NULL == peer->sh_head) 714 if (NULL == peer->sh_head)
709 return GNUNET_YES; /* no available session, cannot allocate bandwidth */ 715 return GNUNET_YES; /* no available session, cannot allocate bandwidth */
710 memset(best, 0, sizeof(best)); 716 memset (best, 0, sizeof(best));
711 for (struct GNUNET_ATS_SessionHandle *sh = peer->sh_head; NULL != sh; 717 for (struct GNUNET_ATS_SessionHandle *sh = peer->sh_head; NULL != sh;
712 sh = sh->next) 718 sh = sh->next)
719 {
720 enum GNUNET_NetworkType nt = sh->data->prop.nt;
721
722 sh->target_out = MIN_BANDWIDTH_PER_SESSION;
723 c->bw_out_by_nt[nt] += MIN_BANDWIDTH_PER_SESSION;
724 c->bw_in_by_nt[nt] +=
725 GNUNET_MAX (MIN_BANDWIDTH_PER_SESSION, sh->data->prop.goodput_in);
726 for (enum GNUNET_MQ_PreferenceKind pk = 0; pk < GNUNET_MQ_PREFERENCE_COUNT;
727 pk++)
713 { 728 {
714 enum GNUNET_NetworkType nt = sh->data->prop.nt; 729 /* General rule: always prefer smaller distance if possible,
715 730 otherwise decide by pk: */
716 sh->target_out = MIN_BANDWIDTH_PER_SESSION; 731 switch (pk)
717 c->bw_out_by_nt[nt] += MIN_BANDWIDTH_PER_SESSION; 732 {
718 c->bw_in_by_nt[nt] += 733 case GNUNET_MQ_PREFERENCE_NONE:
719 GNUNET_MAX(MIN_BANDWIDTH_PER_SESSION, sh->data->prop.goodput_in); 734 break;
720 for (enum GNUNET_MQ_PreferenceKind pk = 0; pk < GNUNET_MQ_PREFERENCE_COUNT; 735
721 pk++) 736 case GNUNET_MQ_PREFERENCE_BANDWIDTH:
722 { 737 /* For bandwidth, we compare the sum of transmitted bytes and
723 /* General rule: always prefer smaller distance if possible, 738 confirmed transmitted bytes, so confirmed data counts twice */
724 otherwise decide by pk: */ 739 if ((NULL == best[pk]) ||
725 switch (pk) 740 (sh->data->prop.distance < best[pk]->data->prop.distance) ||
726 { 741 (sh->data->prop.utilization_out + sh->data->prop.goodput_out >
727 case GNUNET_MQ_PREFERENCE_NONE: 742 best[pk]->data->prop.utilization_out
728 break; 743 + best[pk]->data->prop.goodput_out))
729 744 best[pk] = sh;
730 case GNUNET_MQ_PREFERENCE_BANDWIDTH: 745 /* If both are equal (i.e. usually this happens if there is a zero), use
731 /* For bandwidth, we compare the sum of transmitted bytes and 746 latency as a yardstick */
732 confirmed transmitted bytes, so confirmed data counts twice */ 747 if ((sh->data->prop.utilization_out + sh->data->prop.goodput_out ==
733 if ((NULL == best[pk]) || 748 best[pk]->data->prop.utilization_out
734 (sh->data->prop.distance < best[pk]->data->prop.distance) || 749 + best[pk]->data->prop.goodput_out) &&
735 (sh->data->prop.utilization_out + sh->data->prop.goodput_out > 750 (sh->data->prop.distance == best[pk]->data->prop.distance) &&
736 best[pk]->data->prop.utilization_out + 751 (sh->data->prop.delay.rel_value_us <
737 best[pk]->data->prop.goodput_out)) 752 best[pk]->data->prop.delay.rel_value_us))
738 best[pk] = sh; 753 best[pk] = sh;
739 /* If both are equal (i.e. usually this happens if there is a zero), use 754 break;
740 latency as a yardstick */ 755
741 if ((sh->data->prop.utilization_out + sh->data->prop.goodput_out == 756 case GNUNET_MQ_PREFERENCE_LATENCY:
742 best[pk]->data->prop.utilization_out + 757 if ((NULL == best[pk]) ||
743 best[pk]->data->prop.goodput_out) && 758 (sh->data->prop.distance < best[pk]->data->prop.distance) ||
744 (sh->data->prop.distance == best[pk]->data->prop.distance) && 759 ((sh->data->prop.distance == best[pk]->data->prop.distance) &&
745 (sh->data->prop.delay.rel_value_us < 760 (sh->data->prop.delay.rel_value_us <
746 best[pk]->data->prop.delay.rel_value_us)) 761 best[pk]->data->prop.delay.rel_value_us)))
747 best[pk] = sh; 762 best[pk] = sh;
748 break; 763 break;
749 764
750 case GNUNET_MQ_PREFERENCE_LATENCY: 765 case GNUNET_MQ_PREFERENCE_RELIABILITY:
751 if ((NULL == best[pk]) || 766 /* For reliability, we consider the ratio of goodput to utilization
752 (sh->data->prop.distance < best[pk]->data->prop.distance) || 767 (but use multiplicative formultations to avoid division by zero) */
753 ((sh->data->prop.distance == best[pk]->data->prop.distance) && 768 if ((NULL == best[pk]) || (1ULL * sh->data->prop.goodput_out
754 (sh->data->prop.delay.rel_value_us < 769 * best[pk]->data->prop.utilization_out >
755 best[pk]->data->prop.delay.rel_value_us))) 770 1ULL * sh->data->prop.utilization_out
756 best[pk] = sh; 771 * best[pk]->data->prop.goodput_out))
757 break; 772 best[pk] = sh;
758 773 /* If both are equal (i.e. usually this happens if there is a zero), use
759 case GNUNET_MQ_PREFERENCE_RELIABILITY: 774 latency as a yardstick */
760 /* For reliability, we consider the ratio of goodput to utilization 775 if ((1ULL * sh->data->prop.goodput_out
761 (but use multiplicative formultations to avoid division by zero) */ 776 * best[pk]->data->prop.utilization_out ==
762 if ((NULL == best[pk]) || (1ULL * sh->data->prop.goodput_out * 777 1ULL * sh->data->prop.utilization_out
763 best[pk]->data->prop.utilization_out > 778 * best[pk]->data->prop.goodput_out) &&
764 1ULL * sh->data->prop.utilization_out * 779 (sh->data->prop.distance == best[pk]->data->prop.distance) &&
765 best[pk]->data->prop.goodput_out)) 780 (sh->data->prop.delay.rel_value_us <
766 best[pk] = sh; 781 best[pk]->data->prop.delay.rel_value_us))
767 /* If both are equal (i.e. usually this happens if there is a zero), use 782 best[pk] = sh;
768 latency as a yardstick */ 783 break;
769 if ((1ULL * sh->data->prop.goodput_out * 784 }
770 best[pk]->data->prop.utilization_out ==
771 1ULL * sh->data->prop.utilization_out *
772 best[pk]->data->prop.goodput_out) &&
773 (sh->data->prop.distance == best[pk]->data->prop.distance) &&
774 (sh->data->prop.delay.rel_value_us <
775 best[pk]->data->prop.delay.rel_value_us))
776 best[pk] = sh;
777 break;
778 }
779 }
780 } 785 }
786 }
781 /* for first round, assign target bandwidth simply to sum of 787 /* for first round, assign target bandwidth simply to sum of
782 requested bandwidth */ 788 requested bandwidth */
783 for (enum GNUNET_MQ_PreferenceKind pk = 789 for (enum GNUNET_MQ_PreferenceKind pk =
784 1 /* skip GNUNET_MQ_PREFERENCE_NONE */; 790 1 /* skip GNUNET_MQ_PREFERENCE_NONE */;
785 pk < GNUNET_MQ_PREFERENCE_COUNT; 791 pk < GNUNET_MQ_PREFERENCE_COUNT;
786 pk++) 792 pk++)
787 { 793 {
788 const struct GNUNET_ATS_SessionData *data = best[pk]->data; 794 const struct GNUNET_ATS_SessionData *data = best[pk]->data;
789 enum GNUNET_NetworkType nt; 795 enum GNUNET_NetworkType nt;
790 796
791 GNUNET_assert(NULL != data); 797 GNUNET_assert (NULL != data);
792 nt = data->prop.nt; 798 nt = data->prop.nt;
793 best[pk]->target_out = 799 best[pk]->target_out =
794 GNUNET_MIN(peer->bw_by_pk[pk], MIN_BANDWIDTH_PER_SESSION); 800 GNUNET_MIN (peer->bw_by_pk[pk], MIN_BANDWIDTH_PER_SESSION);
795 c->bw_out_by_nt[nt] += 801 c->bw_out_by_nt[nt] +=
796 (uint64_t)(best[pk]->target_out - MIN_BANDWIDTH_PER_SESSION); 802 (uint64_t) (best[pk]->target_out - MIN_BANDWIDTH_PER_SESSION);
797 } 803 }
798 return GNUNET_YES; 804 return GNUNET_YES;
799} 805}
800 806
@@ -809,23 +815,23 @@ update_counters(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
809 * @return #GNUNET_YES (continue to iterate) 815 * @return #GNUNET_YES (continue to iterate)
810 */ 816 */
811static int 817static int
812update_allocation(void *cls, 818update_allocation (void *cls,
813 const struct GNUNET_PeerIdentity *pid, 819 const struct GNUNET_PeerIdentity *pid,
814 void *value) 820 void *value)
815{ 821{
816 struct Counters *c = cls; 822 struct Counters *c = cls;
817 struct Peer *peer = value; 823 struct Peer *peer = value;
818 824
819 (void)pid; 825 (void) pid;
820 for (struct GNUNET_ATS_SessionHandle *sh = peer->sh_head; NULL != sh; 826 for (struct GNUNET_ATS_SessionHandle *sh = peer->sh_head; NULL != sh;
821 sh = sh->next) 827 sh = sh->next)
822 { 828 {
823 enum GNUNET_NetworkType nt = sh->data->prop.nt; 829 enum GNUNET_NetworkType nt = sh->data->prop.nt;
824 830
825 sh->target_out = (uint64_t)(c->scale_out[nt] * sh->target_out); 831 sh->target_out = (uint64_t) (c->scale_out[nt] * sh->target_out);
826 sh->target_in = (uint64_t)(c->scale_in[nt] * sh->target_in); 832 sh->target_in = (uint64_t) (c->scale_in[nt] * sh->target_in);
827 consider_notify_transport(sh); 833 consider_notify_transport (sh);
828 } 834 }
829 return GNUNET_YES; 835 return GNUNET_YES;
830} 836}
831 837
@@ -834,23 +840,23 @@ update_allocation(void *cls,
834 * The world changed, recalculate our allocations. 840 * The world changed, recalculate our allocations.
835 */ 841 */
836static void 842static void
837update(struct SimpleHandle *h) 843update (struct SimpleHandle *h)
838{ 844{
839 struct Counters cnt = { .h = h }; 845 struct Counters cnt = { .h = h };
840 846
841 GNUNET_CONTAINER_multipeermap_iterate(h->peers, &update_counters, &cnt); 847 GNUNET_CONTAINER_multipeermap_iterate (h->peers, &update_counters, &cnt);
842 /* calculate how badly the missmatch between requested 848 /* calculate how badly the missmatch between requested
843 allocations and available bandwidth is per network type */ 849 allocations and available bandwidth is per network type */
844 for (enum GNUNET_NetworkType nt = 0; nt < GNUNET_NT_COUNT; nt++) 850 for (enum GNUNET_NetworkType nt = 0; nt < GNUNET_NT_COUNT; nt++)
845 { 851 {
846 cnt.scale_out[nt] = 852 cnt.scale_out[nt] =
847 1.0 * cnt.bw_out_by_nt[nt] / h->networks[nt].total_quota_out; 853 1.0 * cnt.bw_out_by_nt[nt] / h->networks[nt].total_quota_out;
848 cnt.scale_in[nt] = 854 cnt.scale_in[nt] =
849 1.0 * cnt.bw_in_by_nt[nt] / h->networks[nt].total_quota_in; 855 1.0 * cnt.bw_in_by_nt[nt] / h->networks[nt].total_quota_in;
850 } 856 }
851 /* recalculate allocations, considering scaling factor, and 857 /* recalculate allocations, considering scaling factor, and
852 update transport if the change is significant */ 858 update transport if the change is significant */
853 GNUNET_CONTAINER_multipeermap_iterate(h->peers, &update_allocation, &cnt); 859 GNUNET_CONTAINER_multipeermap_iterate (h->peers, &update_allocation, &cnt);
854} 860}
855 861
856 862
@@ -862,15 +868,15 @@ update(struct SimpleHandle *h)
862 * @return plugin's internal representation, or NULL 868 * @return plugin's internal representation, or NULL
863 */ 869 */
864static struct GNUNET_ATS_PreferenceHandle * 870static struct GNUNET_ATS_PreferenceHandle *
865simple_preference_add(void *cls, const struct GNUNET_ATS_Preference *pref) 871simple_preference_add (void *cls, const struct GNUNET_ATS_Preference *pref)
866{ 872{
867 struct SimpleHandle *h = cls; 873 struct SimpleHandle *h = cls;
868 struct Peer *p = peer_add(h, &pref->peer); 874 struct Peer *p = peer_add (h, &pref->peer);
869 875
870 GNUNET_assert(pref->pk < GNUNET_MQ_PREFERENCE_COUNT); 876 GNUNET_assert (pref->pk < GNUNET_MQ_PREFERENCE_COUNT);
871 p->bw_by_pk[pref->pk] += ntohl(pref->bw.value__); 877 p->bw_by_pk[pref->pk] += ntohl (pref->bw.value__);
872 h->bw_by_pk[pref->pk] += ntohl(pref->bw.value__); 878 h->bw_by_pk[pref->pk] += ntohl (pref->bw.value__);
873 update(h); 879 update (h);
874 return NULL; 880 return NULL;
875} 881}
876 882
@@ -884,20 +890,20 @@ simple_preference_add(void *cls, const struct GNUNET_ATS_Preference *pref)
884 * @return plugin's internal representation, or NULL 890 * @return plugin's internal representation, or NULL
885 */ 891 */
886static void 892static void
887simple_preference_del(void *cls, 893simple_preference_del (void *cls,
888 struct GNUNET_ATS_PreferenceHandle *ph, 894 struct GNUNET_ATS_PreferenceHandle *ph,
889 const struct GNUNET_ATS_Preference *pref) 895 const struct GNUNET_ATS_Preference *pref)
890{ 896{
891 struct SimpleHandle *h = cls; 897 struct SimpleHandle *h = cls;
892 struct Peer *p = lookup_peer(h, &pref->peer); 898 struct Peer *p = lookup_peer (h, &pref->peer);
893 899
894 GNUNET_assert(NULL != p); 900 GNUNET_assert (NULL != p);
895 GNUNET_assert(pref->pk < GNUNET_MQ_PREFERENCE_COUNT); 901 GNUNET_assert (pref->pk < GNUNET_MQ_PREFERENCE_COUNT);
896 p->bw_by_pk[pref->pk] -= ntohl(pref->bw.value__); 902 p->bw_by_pk[pref->pk] -= ntohl (pref->bw.value__);
897 h->bw_by_pk[pref->pk] -= ntohl(pref->bw.value__); 903 h->bw_by_pk[pref->pk] -= ntohl (pref->bw.value__);
898 if ((0 == p->bw_by_pk[pref->pk]) && (GNUNET_YES == peer_test_dead(p))) 904 if ((0 == p->bw_by_pk[pref->pk]) && (GNUNET_YES == peer_test_dead (p)))
899 peer_free(p); 905 peer_free (p);
900 update(h); 906 update (h);
901} 907}
902 908
903 909
@@ -911,50 +917,50 @@ simple_preference_del(void *cls,
911 * @return handle by which the plugin will identify this session 917 * @return handle by which the plugin will identify this session
912 */ 918 */
913static struct GNUNET_ATS_SessionHandle * 919static struct GNUNET_ATS_SessionHandle *
914simple_session_add(void *cls, 920simple_session_add (void *cls,
915 const struct GNUNET_ATS_SessionData *data, 921 const struct GNUNET_ATS_SessionData *data,
916 const char *address) 922 const char *address)
917{ 923{
918 struct SimpleHandle *h = cls; 924 struct SimpleHandle *h = cls;
919 struct Peer *p = peer_add(h, &data->peer); 925 struct Peer *p = peer_add (h, &data->peer);
920 struct Hello *hello; 926 struct Hello *hello;
921 size_t alen; 927 size_t alen;
922 struct GNUNET_ATS_SessionHandle *sh; 928 struct GNUNET_ATS_SessionHandle *sh;
923 929
924 /* setup session handle */ 930 /* setup session handle */
925 GNUNET_assert(NULL != data); 931 GNUNET_assert (NULL != data);
926 if (NULL == address) 932 if (NULL == address)
927 alen = 0; 933 alen = 0;
928 else 934 else
929 alen = strlen(address) + 1; 935 alen = strlen (address) + 1;
930 sh = GNUNET_malloc(sizeof(struct GNUNET_ATS_SessionHandle) + alen); 936 sh = GNUNET_malloc (sizeof(struct GNUNET_ATS_SessionHandle) + alen);
931 sh->peer = p; 937 sh->peer = p;
932 sh->session = data->session; 938 sh->session = data->session;
933 sh->data = data; 939 sh->data = data;
934 if (NULL == address) 940 if (NULL == address)
935 { 941 {
936 sh->address = NULL; 942 sh->address = NULL;
937 } 943 }
938 else 944 else
939 { 945 {
940 memcpy(&sh[1], address, alen); 946 memcpy (&sh[1], address, alen);
941 sh->address = (const char *)&sh[1]; 947 sh->address = (const char *) &sh[1];
942 } 948 }
943 GNUNET_CONTAINER_DLL_insert(p->sh_head, p->sh_tail, sh); 949 GNUNET_CONTAINER_DLL_insert (p->sh_head, p->sh_tail, sh);
944 if (NULL != address) 950 if (NULL != address)
951 {
952 /* match HELLO */
953 hello = p->h_head;
954 while ((NULL != hello) && (0 != strcmp (address, hello->address)))
955 hello = hello->next;
956 if (NULL != hello)
945 { 957 {
946 /* match HELLO */ 958 hello->sh = sh;
947 hello = p->h_head; 959 hello->backoff = GNUNET_TIME_UNIT_ZERO;
948 while ((NULL != hello) && (0 != strcmp(address, hello->address))) 960 sh->hello = hello;
949 hello = hello->next;
950 if (NULL != hello)
951 {
952 hello->sh = sh;
953 hello->backoff = GNUNET_TIME_UNIT_ZERO;
954 sh->hello = hello;
955 }
956 } 961 }
957 update(h); 962 }
963 update (h);
958 return sh; 964 return sh;
959} 965}
960 966
@@ -968,15 +974,15 @@ simple_session_add(void *cls,
968 * @param data performance characteristics of @a sh 974 * @param data performance characteristics of @a sh
969 */ 975 */
970static void 976static void
971simple_session_update(void *cls, 977simple_session_update (void *cls,
972 struct GNUNET_ATS_SessionHandle *sh, 978 struct GNUNET_ATS_SessionHandle *sh,
973 const struct GNUNET_ATS_SessionData *data) 979 const struct GNUNET_ATS_SessionData *data)
974{ 980{
975 struct SimpleHandle *h = cls; 981 struct SimpleHandle *h = cls;
976 982
977 GNUNET_assert(NULL != data); 983 GNUNET_assert (NULL != data);
978 sh->data = data; /* this statement should not really do anything... */ 984 sh->data = data; /* this statement should not really do anything... */
979 update(h); 985 update (h);
980} 986}
981 987
982 988
@@ -988,30 +994,30 @@ simple_session_update(void *cls,
988 * @param data (last) performance characteristics of @a sh 994 * @param data (last) performance characteristics of @a sh
989 */ 995 */
990static void 996static void
991simple_session_del(void *cls, 997simple_session_del (void *cls,
992 struct GNUNET_ATS_SessionHandle *sh, 998 struct GNUNET_ATS_SessionHandle *sh,
993 const struct GNUNET_ATS_SessionData *data) 999 const struct GNUNET_ATS_SessionData *data)
994{ 1000{
995 struct SimpleHandle *h = cls; 1001 struct SimpleHandle *h = cls;
996 struct Peer *p = sh->peer; 1002 struct Peer *p = sh->peer;
997 struct Hello *hello = sh->hello; 1003 struct Hello *hello = sh->hello;
998 1004
999 /* clean up sh */ 1005 /* clean up sh */
1000 GNUNET_CONTAINER_DLL_remove(p->sh_head, p->sh_tail, sh); 1006 GNUNET_CONTAINER_DLL_remove (p->sh_head, p->sh_tail, sh);
1001 if (NULL != hello) 1007 if (NULL != hello)
1002 { 1008 {
1003 GNUNET_assert(sh == hello->sh); 1009 GNUNET_assert (sh == hello->sh);
1004 hello->sh = NULL; 1010 hello->sh = NULL;
1005 /* session went down, if necessary restart suggesting 1011 /* session went down, if necessary restart suggesting
1006 addresses */ 1012 addresses */
1007 if (NULL == p->task) 1013 if (NULL == p->task)
1008 p->task = GNUNET_SCHEDULER_add_now(&suggest_start_cb, p); 1014 p->task = GNUNET_SCHEDULER_add_now (&suggest_start_cb, p);
1009 } 1015 }
1010 GNUNET_free(sh); 1016 GNUNET_free (sh);
1011 /* del peer if otherwise dead */ 1017 /* del peer if otherwise dead */
1012 if ((NULL == p->sh_head) && (GNUNET_YES == peer_test_dead(p))) 1018 if ((NULL == p->sh_head) && (GNUNET_YES == peer_test_dead (p)))
1013 peer_free(p); 1019 peer_free (p);
1014 update(h); 1020 update (h);
1015} 1021}
1016 1022
1017 1023
@@ -1026,16 +1032,16 @@ simple_session_del(void *cls,
1026 * @return the `struct SimpleHandle` to pass as a closure 1032 * @return the `struct SimpleHandle` to pass as a closure
1027 */ 1033 */
1028void * 1034void *
1029libgnunet_plugin_ats2_simple_init(void *cls) 1035libgnunet_plugin_ats2_simple_init (void *cls)
1030{ 1036{
1031 static struct GNUNET_ATS_SolverFunctions sf; 1037 static struct GNUNET_ATS_SolverFunctions sf;
1032 struct GNUNET_ATS_PluginEnvironment *env = cls; 1038 struct GNUNET_ATS_PluginEnvironment *env = cls;
1033 struct SimpleHandle *s; 1039 struct SimpleHandle *s;
1034 1040
1035 s = GNUNET_new(struct SimpleHandle); 1041 s = GNUNET_new (struct SimpleHandle);
1036 s->env = env; 1042 s->env = env;
1037 s->peers = GNUNET_CONTAINER_multipeermap_create(128, GNUNET_YES); 1043 s->peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES);
1038 s->ps = GNUNET_PEERSTORE_connect(env->cfg); 1044 s->ps = GNUNET_PEERSTORE_connect (env->cfg);
1039 sf.cls = s; 1045 sf.cls = s;
1040 sf.preference_add = &simple_preference_add; 1046 sf.preference_add = &simple_preference_add;
1041 sf.preference_del = &simple_preference_del; 1047 sf.preference_del = &simple_preference_del;
@@ -1043,18 +1049,18 @@ libgnunet_plugin_ats2_simple_init(void *cls)
1043 sf.session_update = &simple_session_update; 1049 sf.session_update = &simple_session_update;
1044 sf.session_del = &simple_session_del; 1050 sf.session_del = &simple_session_del;
1045 for (enum GNUNET_NetworkType nt = 0; nt < GNUNET_NT_COUNT; nt++) 1051 for (enum GNUNET_NetworkType nt = 0; nt < GNUNET_NT_COUNT; nt++)
1052 {
1053 const char *name = GNUNET_NT_to_string (nt);
1054
1055 if (NULL == name)
1046 { 1056 {
1047 const char *name = GNUNET_NT_to_string(nt); 1057 GNUNET_break (0);
1048 1058 break;
1049 if (NULL == name)
1050 {
1051 GNUNET_break(0);
1052 break;
1053 }
1054 get_quota(env->cfg, name, "IN", &s->networks[nt].total_quota_in);
1055 get_quota(env->cfg, name, "OUT", &s->networks[nt].total_quota_out);
1056 s->networks[nt].type = nt;
1057 } 1059 }
1060 get_quota (env->cfg, name, "IN", &s->networks[nt].total_quota_in);
1061 get_quota (env->cfg, name, "OUT", &s->networks[nt].total_quota_out);
1062 s->networks[nt].type = nt;
1063 }
1058 return &sf; 1064 return &sf;
1059} 1065}
1060 1066
@@ -1065,15 +1071,15 @@ libgnunet_plugin_ats2_simple_init(void *cls)
1065 * @param cls return value from #libgnunet_plugin_ats_proportional_init() 1071 * @param cls return value from #libgnunet_plugin_ats_proportional_init()
1066 */ 1072 */
1067void * 1073void *
1068libgnunet_plugin_ats2_simple_done(void *cls) 1074libgnunet_plugin_ats2_simple_done (void *cls)
1069{ 1075{
1070 struct GNUNET_ATS_SolverFunctions *sf = cls; 1076 struct GNUNET_ATS_SolverFunctions *sf = cls;
1071 struct SimpleHandle *s = sf->cls; 1077 struct SimpleHandle *s = sf->cls;
1072 1078
1073 GNUNET_break(0 == GNUNET_CONTAINER_multipeermap_size(s->peers)); 1079 GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (s->peers));
1074 GNUNET_CONTAINER_multipeermap_destroy(s->peers); 1080 GNUNET_CONTAINER_multipeermap_destroy (s->peers);
1075 GNUNET_PEERSTORE_disconnect(s->ps, GNUNET_NO); 1081 GNUNET_PEERSTORE_disconnect (s->ps, GNUNET_NO);
1076 GNUNET_free(s); 1082 GNUNET_free (s);
1077 return NULL; 1083 return NULL;
1078} 1084}
1079 1085