diff options
author | Julius Bünger <buenger@mytum.de> | 2014-12-24 15:11:43 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2014-12-24 15:11:43 +0000 |
commit | 471ed8e8d0f2d7246fc2ec217357dadb9be0817b (patch) | |
tree | 961b4fc030445b9bdc2d62c7271f794abe487945 /src | |
parent | 0d2f7894d7ba9d3cfa1cb577c9ab6e00b3d9e9c7 (diff) | |
download | gnunet-471ed8e8d0f2d7246fc2ec217357dadb9be0817b.tar.gz gnunet-471ed8e8d0f2d7246fc2ec217357dadb9be0817b.zip |
fixed some issues
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 183 |
1 files changed, 103 insertions, 80 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 0c3fb792d..1e7344117 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -56,7 +56,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
56 | /** | 56 | /** |
57 | * Our own identity. | 57 | * Our own identity. |
58 | */ | 58 | */ |
59 | struct GNUNET_PeerIdentity *own_identity; | 59 | static struct GNUNET_PeerIdentity *own_identity; |
60 | 60 | ||
61 | 61 | ||
62 | struct GNUNET_PeerIdentity * | 62 | struct GNUNET_PeerIdentity * |
@@ -178,6 +178,31 @@ struct Samplers | |||
178 | }; | 178 | }; |
179 | 179 | ||
180 | /** | 180 | /** |
181 | * Reinitialise a previously initialised sampler. | ||
182 | * | ||
183 | * @param sampler the sampler element. | ||
184 | * @param id pointer to the memory that keeps the value. | ||
185 | */ | ||
186 | void | ||
187 | SAMPLER_reinitialise_sampler (struct Sampler *sampler, struct GNUNET_PeerIdentity *id) | ||
188 | { | ||
189 | // I guess I don't need to call GNUNET_CRYPTO_hmac_derive_key()... | ||
190 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_STRONG, | ||
191 | &(sampler->auth_key.key), | ||
192 | GNUNET_CRYPTO_HASH_LENGTH); | ||
193 | |||
194 | GNUNET_assert(NULL != id); | ||
195 | sampler->peer_id = id; | ||
196 | memcpy(sampler->peer_id, own_identity, sizeof(struct GNUNET_PeerIdentity)); // FIXME this should probably be NULL -- the caller has to handle those. | ||
197 | // Maybe take a PeerID as second argument. | ||
198 | |||
199 | GNUNET_CRYPTO_hmac(&sampler->auth_key, sampler->peer_id, | ||
200 | sizeof(struct GNUNET_PeerIdentity), | ||
201 | &sampler->peer_id_hash); | ||
202 | } | ||
203 | |||
204 | |||
205 | /** | ||
181 | * (Re)Initialise given Sampler with random min-wise independent function. | 206 | * (Re)Initialise given Sampler with random min-wise independent function. |
182 | * | 207 | * |
183 | * In this implementation this means choosing an auth_key for later use in | 208 | * In this implementation this means choosing an auth_key for later use in |
@@ -193,24 +218,10 @@ SAMPLER_init(struct GNUNET_PeerIdentity *id) | |||
193 | 218 | ||
194 | s = GNUNET_new(struct Sampler); | 219 | s = GNUNET_new(struct Sampler); |
195 | 220 | ||
196 | // I guess I don't need to call GNUNET_CRYPTO_hmac_derive_key()... | 221 | SAMPLER_reinitialise_sampler (s, id); |
197 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_STRONG, | ||
198 | &(s->auth_key.key), | ||
199 | GNUNET_CRYPTO_HASH_LENGTH); | ||
200 | |||
201 | GNUNET_assert(NULL != id); | ||
202 | s->peer_id = id; | ||
203 | memcpy(s->peer_id, own_identity, sizeof(struct GNUNET_PeerIdentity)); // FIXME this should probably be NULL -- the caller has to handle those. | ||
204 | //s->peer_id = own_identity; // Maybe set to own PeerID. So we always have | ||
205 | // a valid PeerID in the sampler. | ||
206 | // Maybe take a PeerID as second argument. | ||
207 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: initialised with PeerID %s (at %p) \n", | 222 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: initialised with PeerID %s (at %p) \n", |
208 | GNUNET_i2s(s->peer_id), s->peer_id); | 223 | GNUNET_i2s(s->peer_id), s->peer_id); |
209 | 224 | ||
210 | GNUNET_CRYPTO_hmac(&s->auth_key, s->peer_id, | ||
211 | sizeof(struct GNUNET_PeerIdentity), | ||
212 | &s->peer_id_hash); | ||
213 | |||
214 | s->prev = NULL; | 225 | s->prev = NULL; |
215 | s->next = NULL; | 226 | s->next = NULL; |
216 | 227 | ||
@@ -333,6 +344,8 @@ SAMPLER_samplers_resize (struct Samplers * samplers, | |||
333 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Removing %" PRIX64 ". sampler\n", i); | 344 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Removing %" PRIX64 ". sampler\n", i); |
334 | if (NULL != samplers->removeCB) | 345 | if (NULL != samplers->removeCB) |
335 | samplers->removeCB(samplers->removeCLS, iter->peer_id, iter->peer_id_hash); | 346 | samplers->removeCB(samplers->removeCLS, iter->peer_id, iter->peer_id_hash); |
347 | // FIXME When this is called and counts the amount of peer_ids in the samplers | ||
348 | // this gets a wrong number. | ||
336 | GNUNET_CONTAINER_DLL_remove(samplers->head, samplers->tail, iter); | 349 | GNUNET_CONTAINER_DLL_remove(samplers->head, samplers->tail, iter); |
337 | GNUNET_free(iter); | 350 | GNUNET_free(iter); |
338 | iter = tmp; | 351 | iter = tmp; |
@@ -411,17 +424,6 @@ SAMPLER_samplers_init(size_t init_size, struct GNUNET_PeerIdentity *id, | |||
411 | 424 | ||
412 | SAMPLER_samplers_resize(samplers, init_size, id); | 425 | SAMPLER_samplers_resize(samplers, init_size, id); |
413 | 426 | ||
414 | //for ( i = 0 ; i < init_size ; i++ ) | ||
415 | //{ | ||
416 | // GNUNET_array_append(samplers->peer_ids, | ||
417 | // samplers->size, | ||
418 | // *id); | ||
419 | // s = SAMPLER_init(&samplers->peer_ids[i]); | ||
420 | // GNUNET_CONTAINER_DLL_insert_tail(samplers->head, | ||
421 | // samplers->tail, | ||
422 | // s); | ||
423 | //} | ||
424 | //samplers->size = init_size; | ||
425 | GNUNET_assert(init_size == samplers->size); | 427 | GNUNET_assert(init_size == samplers->size); |
426 | return samplers; | 428 | return samplers; |
427 | } | 429 | } |
@@ -447,6 +449,31 @@ SAMPLER_update_list(struct Samplers *samplers, const struct GNUNET_PeerIdentity | |||
447 | } | 449 | } |
448 | 450 | ||
449 | /** | 451 | /** |
452 | * Reinitialise all previously initialised sampler with the given value. | ||
453 | * | ||
454 | * @param samplers the sampler list. | ||
455 | * @param id the id of the samplers to update. | ||
456 | */ | ||
457 | void | ||
458 | SAMPLER_reinitialise_samplers_by_value (struct Samplers *samplers, const struct GNUNET_PeerIdentity *id) | ||
459 | { | ||
460 | uint64_t i; | ||
461 | struct Sampler *iter; | ||
462 | |||
463 | iter = samplers->head; | ||
464 | for ( i = 0 ; i < samplers->size ; i++ ) | ||
465 | { | ||
466 | if ( 0 == GNUNET_CRYPTO_cmp_peer_identity(id, &samplers->peer_ids[i]) ) | ||
467 | { | ||
468 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Reinitialising sampler\n"); | ||
469 | SAMPLER_reinitialise_sampler (iter, &samplers->peer_ids[i]); | ||
470 | } | ||
471 | if (NULL != iter->next) | ||
472 | iter = iter->next; | ||
473 | } | ||
474 | } | ||
475 | |||
476 | /** | ||
450 | * Get one random peer out of the sampled peers. | 477 | * Get one random peer out of the sampled peers. |
451 | * | 478 | * |
452 | * We might want to reinitialise this sampler after giving the | 479 | * We might want to reinitialise this sampler after giving the |
@@ -529,19 +556,7 @@ SAMPLER_count_id ( struct Samplers *samplers, const struct GNUNET_PeerIdentity * | |||
529 | void | 556 | void |
530 | SAMPLER_samplers_destroy (struct Samplers *samplers) | 557 | SAMPLER_samplers_destroy (struct Samplers *samplers) |
531 | { | 558 | { |
532 | //struct Sampler *iter; | ||
533 | //struct Sampler *tmp; | ||
534 | |||
535 | SAMPLER_samplers_resize(samplers, 0, NULL); | 559 | SAMPLER_samplers_resize(samplers, 0, NULL); |
536 | //iter = samplers->head; | ||
537 | //while (NULL != iter) // use _samplers_resize(0)? | ||
538 | //{ | ||
539 | // iter = iter->next; | ||
540 | // tmp = iter->prev; | ||
541 | // GNUNET_CONTAINER_DLL_remove(samplers->head, samplers->tail, iter->prev); | ||
542 | // GNUNET_free(tmp); | ||
543 | //} | ||
544 | //GNUNET_array_grow(samplers->peer_ids, samplers->size, 0); | ||
545 | GNUNET_free(samplers); | 560 | GNUNET_free(samplers); |
546 | } | 561 | } |
547 | 562 | ||
@@ -624,18 +639,18 @@ static struct GNUNET_CONTAINER_MultiPeerMap *peer_map; | |||
624 | /** | 639 | /** |
625 | * The samplers. | 640 | * The samplers. |
626 | */ | 641 | */ |
627 | struct Samplers *sampler_list; | 642 | static struct Samplers *sampler_list; |
628 | 643 | ||
629 | 644 | ||
630 | /** | 645 | /** |
631 | * The gossiped list of peers. | 646 | * The gossiped list of peers. |
632 | */ | 647 | */ |
633 | struct GNUNET_PeerIdentity *gossip_list; | 648 | static struct GNUNET_PeerIdentity *gossip_list; |
634 | 649 | ||
635 | /** | 650 | /** |
636 | * Size of the gossiped list | 651 | * Size of the gossiped list |
637 | */ | 652 | */ |
638 | unsigned int gossip_list_size; | 653 | static unsigned int gossip_list_size; |
639 | 654 | ||
640 | 655 | ||
641 | /** | 656 | /** |
@@ -643,7 +658,7 @@ unsigned int gossip_list_size; | |||
643 | * | 658 | * |
644 | * Influenced by the stdev. | 659 | * Influenced by the stdev. |
645 | */ | 660 | */ |
646 | unsigned int est_size; | 661 | static unsigned int est_size; |
647 | //size_t est_size; | 662 | //size_t est_size; |
648 | 663 | ||
649 | 664 | ||
@@ -651,13 +666,13 @@ unsigned int est_size; | |||
651 | * Percentage of total peer number in the gossip list | 666 | * Percentage of total peer number in the gossip list |
652 | * to send random PUSHes to | 667 | * to send random PUSHes to |
653 | */ | 668 | */ |
654 | float alpha; | 669 | static float alpha; |
655 | 670 | ||
656 | /** | 671 | /** |
657 | * Percentage of total peer number in the gossip list | 672 | * Percentage of total peer number in the gossip list |
658 | * to send random PULLs to | 673 | * to send random PULLs to |
659 | */ | 674 | */ |
660 | float beta; | 675 | static float beta; |
661 | 676 | ||
662 | /** | 677 | /** |
663 | * The percentage gamma of history updates. | 678 | * The percentage gamma of history updates. |
@@ -670,47 +685,47 @@ float beta; | |||
670 | /** | 685 | /** |
671 | * Identifier for the main task that runs periodically. | 686 | * Identifier for the main task that runs periodically. |
672 | */ | 687 | */ |
673 | struct GNUNET_SCHEDULER_Task * do_round_task; | 688 | static struct GNUNET_SCHEDULER_Task * do_round_task; |
674 | 689 | ||
675 | /** | 690 | /** |
676 | * Time inverval the do_round task runs in. | 691 | * Time inverval the do_round task runs in. |
677 | */ | 692 | */ |
678 | struct GNUNET_TIME_Relative round_interval; | 693 | static struct GNUNET_TIME_Relative round_interval; |
679 | 694 | ||
680 | 695 | ||
681 | 696 | ||
682 | /** | 697 | /** |
683 | * List to store peers received through pushes temporary. | 698 | * List to store peers received through pushes temporary. |
684 | */ | 699 | */ |
685 | struct GNUNET_PeerIdentity *push_list; | 700 | static struct GNUNET_PeerIdentity *push_list; |
686 | 701 | ||
687 | /** | 702 | /** |
688 | * Size of the push_list; | 703 | * Size of the push_list; |
689 | */ | 704 | */ |
690 | unsigned int push_list_size; | 705 | static unsigned int push_list_size; |
691 | //size_t push_list_size; | 706 | //size_t push_list_size; |
692 | 707 | ||
693 | /** | 708 | /** |
694 | * List to store peers received through pulls temporary. | 709 | * List to store peers received through pulls temporary. |
695 | */ | 710 | */ |
696 | struct GNUNET_PeerIdentity *pull_list; | 711 | static struct GNUNET_PeerIdentity *pull_list; |
697 | 712 | ||
698 | /** | 713 | /** |
699 | * Size of the pull_list; | 714 | * Size of the pull_list; |
700 | */ | 715 | */ |
701 | unsigned int pull_list_size; | 716 | static unsigned int pull_list_size; |
702 | //size_t pull_list_size; | 717 | //size_t pull_list_size; |
703 | 718 | ||
704 | 719 | ||
705 | /** | 720 | /** |
706 | * Handler to NSE. | 721 | * Handler to NSE. |
707 | */ | 722 | */ |
708 | struct GNUNET_NSE_Handle *nse; | 723 | static struct GNUNET_NSE_Handle *nse; |
709 | 724 | ||
710 | /** | 725 | /** |
711 | * Handler to CADET. | 726 | * Handler to CADET. |
712 | */ | 727 | */ |
713 | struct GNUNET_CADET_Handle *cadet_handle; | 728 | static struct GNUNET_CADET_Handle *cadet_handle; |
714 | 729 | ||
715 | 730 | ||
716 | /*********************************************************************** | 731 | /*********************************************************************** |
@@ -721,32 +736,32 @@ struct GNUNET_CADET_Handle *cadet_handle; | |||
721 | * Get random peer from the gossip list. | 736 | * Get random peer from the gossip list. |
722 | */ | 737 | */ |
723 | struct GNUNET_PeerIdentity * | 738 | struct GNUNET_PeerIdentity * |
724 | get_rand_peer(struct GNUNET_PeerIdentity *peer_list, unsigned int size) | 739 | get_rand_peer(struct GNUNET_PeerIdentity *peer_list, unsigned int list_size) |
725 | { | 740 | { |
726 | uint64_t r_index; | 741 | uint64_t r_index; |
727 | struct GNUNET_PeerIdentity *peer; | 742 | struct GNUNET_PeerIdentity *peer; |
728 | 743 | ||
729 | // TODO find a better solution. | 744 | // FIXME if we have only NULL in gossip list this will block |
730 | // FIXME if we have only own ID in gossip list this will block | 745 | // but then we might have a problem nevertheless |
731 | // but then we might have a problem nevertheless ? | ||
732 | 746 | ||
733 | do { | 747 | do |
748 | { | ||
734 | 749 | ||
735 | /**; | 750 | /**; |
736 | * Choose the r_index of the peer we want to return | 751 | * Choose the r_index of the peer we want to return |
737 | * at random from the interval of the gossip list | 752 | * at random from the interval of the gossip list |
738 | */ | 753 | */ |
739 | r_index = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, | 754 | r_index = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, |
740 | size); | 755 | list_size); |
741 | 756 | ||
742 | peer = &(peer_list[r_index]); | 757 | peer = &(peer_list[r_index]); |
743 | } while ( own_identity == peer || NULL == peer ); | 758 | } while (NULL == peer); |
744 | 759 | ||
745 | return peer; | 760 | return peer; |
746 | } | 761 | } |
747 | 762 | ||
748 | /** | 763 | /** |
749 | * Make sure the context of a given peer exists. | 764 | * Make sure the context of a given peer exists in the given peer_map. |
750 | */ | 765 | */ |
751 | void | 766 | void |
752 | touch_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer) | 767 | touch_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer) |
@@ -795,7 +810,9 @@ touch_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUN | |||
795 | ctx->to_channel = GNUNET_CADET_channel_create(cadet_handle, NULL, peer, | 810 | ctx->to_channel = GNUNET_CADET_channel_create(cadet_handle, NULL, peer, |
796 | GNUNET_RPS_CADET_PORT, | 811 | GNUNET_RPS_CADET_PORT, |
797 | GNUNET_CADET_OPTION_RELIABLE); | 812 | GNUNET_CADET_OPTION_RELIABLE); |
798 | //TODO do I have to explicitly put it in the peer_map? | 813 | // do I have to explicitly put it in the peer_map? |
814 | GNUNET_CONTAINER_multipeermap_put(peer_map, peer, ctx, | ||
815 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
799 | } | 816 | } |
800 | } | 817 | } |
801 | 818 | ||
@@ -828,9 +845,9 @@ touch_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_Pe | |||
828 | { | 845 | { |
829 | touch_channel(peer_map, peer_id); | 846 | touch_channel(peer_map, peer_id); |
830 | ctx->mq = GNUNET_CADET_mq_create(ctx->to_channel); | 847 | ctx->mq = GNUNET_CADET_mq_create(ctx->to_channel); |
831 | //TODO do I have to explicitly put it in the peer_map? | 848 | //do I have to explicitly put it in the peer_map? |
832 | //GNUNET_CONTAINER_multipeermap_put(peer_map, peer_id, ctx, | 849 | GNUNET_CONTAINER_multipeermap_put(peer_map, peer_id, ctx, |
833 | // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 850 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
834 | } | 851 | } |
835 | } | 852 | } |
836 | 853 | ||
@@ -1097,37 +1114,39 @@ do_round(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1097 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) gossip_list_size); | 1114 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) gossip_list_size); |
1098 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %f (%f * %u) peers.\n", | 1115 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %f (%f * %u) peers.\n", |
1099 | alpha * gossip_list_size, alpha, gossip_list_size); | 1116 | alpha * gossip_list_size, alpha, gossip_list_size); |
1100 | for ( i = 0 ; i < alpha * gossip_list_size ; i++ ) { // TODO compute length | 1117 | for ( i = 0 ; i < alpha * gossip_list_size ; i++ ) |
1118 | { // TODO compute length | ||
1101 | peer = get_rand_peer(gossip_list, gossip_list_size); | 1119 | peer = get_rand_peer(gossip_list, gossip_list_size); |
1102 | // TODO check NULL == peer | 1120 | // TODO check NULL == peer |
1103 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s(peer)); | 1121 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s(peer)); |
1104 | 1122 | ||
1105 | ev = GNUNET_MQ_msg(push_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); | 1123 | ev = GNUNET_MQ_msg (push_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); |
1106 | //ev = GNUNET_MQ_msg_extra(); | 1124 | //ev = GNUNET_MQ_msg_extra(); |
1107 | /* TODO Compute proof of work here | 1125 | /* TODO Compute proof of work here |
1108 | push_msg; */ | 1126 | push_msg; */ |
1109 | push_msg->placeholder = 0; | 1127 | push_msg->placeholder = 0; |
1110 | GNUNET_MQ_send( get_mq(peer_map, peer), ev ); | 1128 | // FIXME sometimes it returns a pointer to a freed mq |
1129 | GNUNET_MQ_send (get_mq (peer_map, peer), ev); | ||
1111 | 1130 | ||
1112 | // TODO modify in_flags of respective peer? | 1131 | // modify in_flags of respective peer? |
1113 | } | 1132 | } |
1114 | 1133 | ||
1115 | 1134 | ||
1116 | /* Send PULL requests */ | 1135 | /* Send PULL requests */ |
1117 | // TODO | ||
1118 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size); | 1136 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size); |
1119 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pulls to %f (%f * %u) peers.\n", | 1137 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pulls to %f (%f * %u) peers.\n", |
1120 | beta * gossip_list_size, beta, gossip_list_size); | 1138 | beta * gossip_list_size, beta, gossip_list_size); |
1121 | for ( i = 0 ; i < beta * gossip_list_size ; i++ ){ // TODO compute length | 1139 | for ( i = 0 ; i < beta * gossip_list_size ; i++ ) |
1140 | { // TODO compute length | ||
1122 | peer = get_rand_peer(gossip_list, gossip_list_size); | 1141 | peer = get_rand_peer(gossip_list, gossip_list_size); |
1123 | // TODO check NULL == peer | 1142 | // TODO check empty_peer != peer |
1124 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s(peer)); | 1143 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s(peer)); |
1125 | 1144 | ||
1126 | ev = GNUNET_MQ_msg(pull_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); | 1145 | ev = GNUNET_MQ_msg(pull_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); |
1127 | //ev = GNUNET_MQ_msg_extra(); | 1146 | //ev = GNUNET_MQ_msg_extra(); |
1128 | pull_msg->placeholder = 0; | 1147 | pull_msg->placeholder = 0; |
1129 | GNUNET_MQ_send( get_mq(peer_map, peer), ev ); | 1148 | GNUNET_MQ_send( get_mq(peer_map, peer), ev ); |
1130 | // TODO modify in_flags of respective peer? | 1149 | // modify in_flags of respective peer? |
1131 | } | 1150 | } |
1132 | 1151 | ||
1133 | 1152 | ||
@@ -1322,7 +1341,6 @@ static void | |||
1322 | handle_client_disconnect (void *cls, | 1341 | handle_client_disconnect (void *cls, |
1323 | struct GNUNET_SERVER_Client * client) | 1342 | struct GNUNET_SERVER_Client * client) |
1324 | { | 1343 | { |
1325 | // TODO reinitialise that sampler | ||
1326 | } | 1344 | } |
1327 | 1345 | ||
1328 | /** | 1346 | /** |
@@ -1353,12 +1371,13 @@ handle_inbound_channel (void *cls, | |||
1353 | } else { | 1371 | } else { |
1354 | struct peer_context *ctx; | 1372 | struct peer_context *ctx; |
1355 | 1373 | ||
1356 | ctx = GNUNET_malloc( sizeof(struct peer_context)); | 1374 | ctx = GNUNET_malloc (sizeof(struct peer_context)); |
1357 | ctx->in_flags = in_other_gossip_list; | 1375 | ctx->in_flags = in_other_gossip_list; |
1358 | ctx->mq = NULL; // TODO create mq? | 1376 | ctx->mq = NULL; // TODO create mq? |
1359 | ctx->from_channel = channel; | 1377 | ctx->from_channel = channel; |
1360 | 1378 | ||
1361 | GNUNET_CONTAINER_multipeermap_put( peer_map, initiator, ctx, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1379 | GNUNET_CONTAINER_multipeermap_put (peer_map, initiator, ctx, |
1380 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1362 | } | 1381 | } |
1363 | return NULL; // TODO | 1382 | return NULL; // TODO |
1364 | } | 1383 | } |
@@ -1375,9 +1394,13 @@ cleanup_channel(void *cls, | |||
1375 | const struct GNUNET_CADET_Channel *channel, | 1394 | const struct GNUNET_CADET_Channel *channel, |
1376 | void *channel_ctx) | 1395 | void *channel_ctx) |
1377 | { | 1396 | { |
1378 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Channel was destroyed by remote peer.\n"); | 1397 | struct GNUNET_PeerIdentity *peer; |
1379 | // TODO test whether that was a peer in the samplers/a peer we opened a connection to | 1398 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n"); |
1380 | // and if so, reinitialise the sampler | 1399 | |
1400 | peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( | ||
1401 | (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER); | ||
1402 | // Guess simply casting isn't the nicest way... | ||
1403 | SAMPLER_reinitialise_samplers_by_value(sampler_list, peer); | ||
1381 | } | 1404 | } |
1382 | 1405 | ||
1383 | /** | 1406 | /** |
@@ -1399,7 +1422,7 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
1399 | 1422 | ||
1400 | 1423 | ||
1401 | 1424 | ||
1402 | do_round_task = GNUNET_SCHEDULER_add_delayed( round_interval, &do_round, NULL); | 1425 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
1403 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 1426 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
1404 | 1427 | ||
1405 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1428 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |