diff options
Diffstat (limited to 'src')
24 files changed, 891 insertions, 552 deletions
diff --git a/src/consensus/consensus_protocol.h b/src/consensus/consensus_protocol.h index a40162fb8..0afd56b27 100644 --- a/src/consensus/consensus_protocol.h +++ b/src/consensus/consensus_protocol.h | |||
@@ -124,6 +124,7 @@ struct ConsensusSizeElement | |||
124 | uint8_t sender_index; | 124 | uint8_t sender_index; |
125 | }; | 125 | }; |
126 | 126 | ||
127 | |||
127 | struct ConsensusStuffedElement | 128 | struct ConsensusStuffedElement |
128 | { | 129 | { |
129 | struct ConsensusElement ce; | 130 | struct ConsensusElement ce; |
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 13fa0d0e7..371b7f67f 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2012, 2013, 2017 GNUnet e.V. | 3 | Copyright (C) 2012, 2013, 2017, 2020 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -17,13 +17,11 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file consensus/gnunet-service-consensus.c | 21 | * @file consensus/gnunet-service-consensus.c |
23 | * @brief multi-peer set reconciliation | 22 | * @brief multi-peer set reconciliation |
24 | * @author Florian Dold <flo@dold.me> | 23 | * @author Florian Dold <flo@dold.me> |
25 | */ | 24 | */ |
26 | |||
27 | #include "platform.h" | 25 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_block_lib.h" | 27 | #include "gnunet_block_lib.h" |
@@ -62,11 +60,57 @@ enum EarlyStoppingPhase | |||
62 | }; | 60 | }; |
63 | 61 | ||
64 | 62 | ||
63 | enum PhaseKind | ||
64 | { | ||
65 | PHASE_KIND_ALL_TO_ALL, | ||
66 | PHASE_KIND_ALL_TO_ALL_2, | ||
67 | PHASE_KIND_GRADECAST_LEADER, | ||
68 | PHASE_KIND_GRADECAST_ECHO, | ||
69 | PHASE_KIND_GRADECAST_ECHO_GRADE, | ||
70 | PHASE_KIND_GRADECAST_CONFIRM, | ||
71 | PHASE_KIND_GRADECAST_CONFIRM_GRADE, | ||
72 | /** | ||
73 | * Apply a repetition of the all-to-all | ||
74 | * gradecast to the current set. | ||
75 | */ | ||
76 | PHASE_KIND_APPLY_REP, | ||
77 | PHASE_KIND_FINISH, | ||
78 | }; | ||
79 | |||
80 | |||
81 | enum SetKind | ||
82 | { | ||
83 | SET_KIND_NONE = 0, | ||
84 | SET_KIND_CURRENT, | ||
85 | /** | ||
86 | * Last result set from a gradecast | ||
87 | */ | ||
88 | SET_KIND_LAST_GRADECAST, | ||
89 | SET_KIND_LEADER_PROPOSAL, | ||
90 | SET_KIND_ECHO_RESULT, | ||
91 | }; | ||
92 | |||
93 | enum DiffKind | ||
94 | { | ||
95 | DIFF_KIND_NONE = 0, | ||
96 | DIFF_KIND_LEADER_PROPOSAL, | ||
97 | DIFF_KIND_LEADER_CONSENSUS, | ||
98 | DIFF_KIND_GRADECAST_RESULT, | ||
99 | }; | ||
100 | |||
101 | enum RfnKind | ||
102 | { | ||
103 | RFN_KIND_NONE = 0, | ||
104 | RFN_KIND_ECHO, | ||
105 | RFN_KIND_CONFIRM, | ||
106 | RFN_KIND_GRADECAST_RESULT | ||
107 | }; | ||
108 | |||
109 | |||
65 | GNUNET_NETWORK_STRUCT_BEGIN | 110 | GNUNET_NETWORK_STRUCT_BEGIN |
66 | 111 | ||
67 | /** | 112 | /** |
68 | * Tuple of integers that together | 113 | * Tuple of integers that together identify a task uniquely. |
69 | * identify a task uniquely. | ||
70 | */ | 114 | */ |
71 | struct TaskKey | 115 | struct TaskKey |
72 | { | 116 | { |
@@ -102,8 +146,14 @@ struct TaskKey | |||
102 | 146 | ||
103 | struct SetKey | 147 | struct SetKey |
104 | { | 148 | { |
105 | int set_kind GNUNET_PACKED; | 149 | enum SetKind set_kind GNUNET_PACKED; |
150 | /** | ||
151 | * Repetition counter. | ||
152 | */ | ||
106 | int k1 GNUNET_PACKED; | 153 | int k1 GNUNET_PACKED; |
154 | /** | ||
155 | * Leader (or 0). | ||
156 | */ | ||
107 | int k2 GNUNET_PACKED; | 157 | int k2 GNUNET_PACKED; |
108 | }; | 158 | }; |
109 | 159 | ||
@@ -112,9 +162,9 @@ struct SetEntry | |||
112 | { | 162 | { |
113 | struct SetKey key; | 163 | struct SetKey key; |
114 | struct GNUNET_SET_Handle *h; | 164 | struct GNUNET_SET_Handle *h; |
165 | |||
115 | /** | 166 | /** |
116 | * GNUNET_YES if the set resulted | 167 | * #GNUNET_YES if the set resulted from applying a referendum with contested |
117 | * from applying a referendum with contested | ||
118 | * elements. | 168 | * elements. |
119 | */ | 169 | */ |
120 | int is_contested; | 170 | int is_contested; |
@@ -123,14 +173,16 @@ struct SetEntry | |||
123 | 173 | ||
124 | struct DiffKey | 174 | struct DiffKey |
125 | { | 175 | { |
126 | int diff_kind GNUNET_PACKED; | 176 | enum DiffKind diff_kind GNUNET_PACKED; |
177 | |||
127 | int k1 GNUNET_PACKED; | 178 | int k1 GNUNET_PACKED; |
179 | |||
128 | int k2 GNUNET_PACKED; | 180 | int k2 GNUNET_PACKED; |
129 | }; | 181 | }; |
130 | 182 | ||
131 | struct RfnKey | 183 | struct RfnKey |
132 | { | 184 | { |
133 | int rfn_kind GNUNET_PACKED; | 185 | enum RfnKind rfn_kind GNUNET_PACKED; |
134 | int k1 GNUNET_PACKED; | 186 | int k1 GNUNET_PACKED; |
135 | int k2 GNUNET_PACKED; | 187 | int k2 GNUNET_PACKED; |
136 | }; | 188 | }; |
@@ -138,52 +190,6 @@ struct RfnKey | |||
138 | 190 | ||
139 | GNUNET_NETWORK_STRUCT_END | 191 | GNUNET_NETWORK_STRUCT_END |
140 | 192 | ||
141 | enum PhaseKind | ||
142 | { | ||
143 | PHASE_KIND_ALL_TO_ALL, | ||
144 | PHASE_KIND_ALL_TO_ALL_2, | ||
145 | PHASE_KIND_GRADECAST_LEADER, | ||
146 | PHASE_KIND_GRADECAST_ECHO, | ||
147 | PHASE_KIND_GRADECAST_ECHO_GRADE, | ||
148 | PHASE_KIND_GRADECAST_CONFIRM, | ||
149 | PHASE_KIND_GRADECAST_CONFIRM_GRADE, | ||
150 | /** | ||
151 | * Apply a repetition of the all-to-all | ||
152 | * gradecast to the current set. | ||
153 | */ | ||
154 | PHASE_KIND_APPLY_REP, | ||
155 | PHASE_KIND_FINISH, | ||
156 | }; | ||
157 | |||
158 | |||
159 | enum SetKind | ||
160 | { | ||
161 | SET_KIND_NONE = 0, | ||
162 | SET_KIND_CURRENT, | ||
163 | /** | ||
164 | * Last result set from a gradecast | ||
165 | */ | ||
166 | SET_KIND_LAST_GRADECAST, | ||
167 | SET_KIND_LEADER_PROPOSAL, | ||
168 | SET_KIND_ECHO_RESULT, | ||
169 | }; | ||
170 | |||
171 | enum DiffKind | ||
172 | { | ||
173 | DIFF_KIND_NONE = 0, | ||
174 | DIFF_KIND_LEADER_PROPOSAL, | ||
175 | DIFF_KIND_LEADER_CONSENSUS, | ||
176 | DIFF_KIND_GRADECAST_RESULT, | ||
177 | }; | ||
178 | |||
179 | enum RfnKind | ||
180 | { | ||
181 | RFN_KIND_NONE = 0, | ||
182 | RFN_KIND_ECHO, | ||
183 | RFN_KIND_CONFIRM, | ||
184 | RFN_KIND_GRADECAST_RESULT | ||
185 | }; | ||
186 | |||
187 | 193 | ||
188 | struct SetOpCls | 194 | struct SetOpCls |
189 | { | 195 | { |
@@ -216,9 +222,13 @@ union TaskFuncCls | |||
216 | struct FinishCls finish; | 222 | struct FinishCls finish; |
217 | }; | 223 | }; |
218 | 224 | ||
225 | |||
219 | struct TaskEntry; | 226 | struct TaskEntry; |
220 | 227 | ||
221 | typedef void (*TaskFunc) (struct TaskEntry *task); | 228 | |
229 | typedef void | ||
230 | (*TaskFunc) (struct TaskEntry *task); | ||
231 | |||
222 | 232 | ||
223 | /* | 233 | /* |
224 | * Node in the consensus task graph. | 234 | * Node in the consensus task graph. |
@@ -277,14 +287,12 @@ struct Step | |||
277 | unsigned int subordinates_cap; | 287 | unsigned int subordinates_cap; |
278 | 288 | ||
279 | /** | 289 | /** |
280 | * Counter for the prerequisites of | 290 | * Counter for the prerequisites of this step. |
281 | * this step. | ||
282 | */ | 291 | */ |
283 | size_t pending_prereq; | 292 | size_t pending_prereq; |
284 | 293 | ||
285 | /* | 294 | /** |
286 | * Task that will run this step despite | 295 | * Task that will run this step despite any pending prerequisites. |
287 | * any pending prerequisites. | ||
288 | */ | 296 | */ |
289 | struct GNUNET_SCHEDULER_Task *timeout_task; | 297 | struct GNUNET_SCHEDULER_Task *timeout_task; |
290 | 298 | ||
@@ -292,28 +300,23 @@ struct Step | |||
292 | 300 | ||
293 | unsigned int is_finished; | 301 | unsigned int is_finished; |
294 | 302 | ||
295 | /* | 303 | /** |
296 | * Synchrony round of the task. | 304 | * Synchrony round of the task. Determines the deadline for the task. |
297 | * Determines the deadline for the task. | ||
298 | */ | 305 | */ |
299 | unsigned int round; | 306 | unsigned int round; |
300 | 307 | ||
301 | /** | 308 | /** |
302 | * Human-readable name for | 309 | * Human-readable name for the task, used for debugging. |
303 | * the task, used for debugging. | ||
304 | */ | 310 | */ |
305 | char *debug_name; | 311 | char *debug_name; |
306 | 312 | ||
307 | /** | 313 | /** |
308 | * When we're doing an early finish, how should this step be | 314 | * When we're doing an early finish, how should this step be treated? If |
309 | * treated? | 315 | * #GNUNET_YES, the step will be marked as finished without actually running |
310 | * If GNUNET_YES, the step will be marked as finished | 316 | * its tasks. Otherwise, the step will still be run even after an early |
311 | * without actually running its tasks. | 317 | * finish. |
312 | * Otherwise, the step will still be run even after | ||
313 | * an early finish. | ||
314 | * | 318 | * |
315 | * Note that a task may never be finished early if | 319 | * Note that a task may never be finished early if it is already running. |
316 | * it is already running. | ||
317 | */ | 320 | */ |
318 | int early_finishable; | 321 | int early_finishable; |
319 | }; | 322 | }; |
@@ -323,14 +326,13 @@ struct RfnElementInfo | |||
323 | { | 326 | { |
324 | const struct GNUNET_SET_Element *element; | 327 | const struct GNUNET_SET_Element *element; |
325 | 328 | ||
326 | /* | 329 | /** |
327 | * GNUNET_YES if the peer votes for the proposal. | 330 | * #GNUNET_YES if the peer votes for the proposal. |
328 | */ | 331 | */ |
329 | int *votes; | 332 | int *votes; |
330 | 333 | ||
331 | /** | 334 | /** |
332 | * Proposal for this element, | 335 | * Proposal for this element, can only be #VOTE_ADD or #VOTE_REMOVE. |
333 | * can only be VOTE_ADD or VOTE_REMOVE. | ||
334 | */ | 336 | */ |
335 | enum ReferendumVote proposal; | 337 | enum ReferendumVote proposal; |
336 | }; | 338 | }; |
@@ -638,7 +640,7 @@ debug_str_element (const struct GNUNET_SET_Element *el) | |||
638 | 640 | ||
639 | 641 | ||
640 | static const char * | 642 | static const char * |
641 | debug_str_task_key (struct TaskKey *tk) | 643 | debug_str_task_key (const struct TaskKey *tk) |
642 | { | 644 | { |
643 | static char buf[256]; | 645 | static char buf[256]; |
644 | 646 | ||
@@ -652,7 +654,7 @@ debug_str_task_key (struct TaskKey *tk) | |||
652 | 654 | ||
653 | 655 | ||
654 | static const char * | 656 | static const char * |
655 | debug_str_diff_key (struct DiffKey *dk) | 657 | debug_str_diff_key (const struct DiffKey *dk) |
656 | { | 658 | { |
657 | static char buf[256]; | 659 | static char buf[256]; |
658 | 660 | ||
@@ -671,8 +673,9 @@ debug_str_set_key (const struct SetKey *sk) | |||
671 | 673 | ||
672 | snprintf (buf, sizeof(buf), | 674 | snprintf (buf, sizeof(buf), |
673 | "SetKey kind=%s, k1=%d, k2=%d", | 675 | "SetKey kind=%s, k1=%d, k2=%d", |
674 | setname (sk->set_kind), sk->k1, sk->k2); | 676 | setname (sk->set_kind), |
675 | 677 | sk->k1, | |
678 | sk->k2); | ||
676 | return buf; | 679 | return buf; |
677 | } | 680 | } |
678 | 681 | ||
@@ -684,8 +687,9 @@ debug_str_rfn_key (const struct RfnKey *rk) | |||
684 | 687 | ||
685 | snprintf (buf, sizeof(buf), | 688 | snprintf (buf, sizeof(buf), |
686 | "RfnKey kind=%s, k1=%d, k2=%d", | 689 | "RfnKey kind=%s, k1=%d, k2=%d", |
687 | rfnname (rk->rfn_kind), rk->k1, rk->k2); | 690 | rfnname (rk->rfn_kind), |
688 | 691 | rk->k1, | |
692 | rk->k2); | ||
689 | return buf; | 693 | return buf; |
690 | } | 694 | } |
691 | 695 | ||
@@ -730,13 +734,15 @@ send_to_client_iter (void *cls, | |||
730 | session->local_peer_idx, | 734 | session->local_peer_idx, |
731 | debug_str_element (element)); | 735 | debug_str_element (element)); |
732 | 736 | ||
733 | ev = GNUNET_MQ_msg_extra (m, element->size - sizeof(struct | 737 | ev = GNUNET_MQ_msg_extra (m, |
734 | ConsensusElement), | 738 | element->size - sizeof(struct ConsensusElement), |
735 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT); | 739 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_RECEIVED_ELEMENT); |
736 | m->element_type = ce->payload_type; | 740 | m->element_type = ce->payload_type; |
737 | GNUNET_memcpy (&m[1], &ce[1], element->size - sizeof(struct | 741 | GNUNET_memcpy (&m[1], |
738 | ConsensusElement)); | 742 | &ce[1], |
739 | GNUNET_MQ_send (session->client_mq, ev); | 743 | element->size - sizeof(struct ConsensusElement)); |
744 | GNUNET_MQ_send (session->client_mq, | ||
745 | ev); | ||
740 | } | 746 | } |
741 | else | 747 | else |
742 | { | 748 | { |
@@ -745,14 +751,16 @@ send_to_client_iter (void *cls, | |||
745 | session->local_peer_idx); | 751 | session->local_peer_idx); |
746 | ev = GNUNET_MQ_msg_header ( | 752 | ev = GNUNET_MQ_msg_header ( |
747 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE); | 753 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE); |
748 | GNUNET_MQ_send (session->client_mq, ev); | 754 | GNUNET_MQ_send (session->client_mq, |
755 | ev); | ||
749 | } | 756 | } |
750 | return GNUNET_YES; | 757 | return GNUNET_YES; |
751 | } | 758 | } |
752 | 759 | ||
753 | 760 | ||
754 | static struct SetEntry * | 761 | static struct SetEntry * |
755 | lookup_set (struct ConsensusSession *session, struct SetKey *key) | 762 | lookup_set (struct ConsensusSession *session, |
763 | const struct SetKey *key) | ||
756 | { | 764 | { |
757 | struct GNUNET_HashCode hash; | 765 | struct GNUNET_HashCode hash; |
758 | 766 | ||
@@ -762,13 +770,17 @@ lookup_set (struct ConsensusSession *session, struct SetKey *key) | |||
762 | debug_str_set_key (key)); | 770 | debug_str_set_key (key)); |
763 | 771 | ||
764 | GNUNET_assert (SET_KIND_NONE != key->set_kind); | 772 | GNUNET_assert (SET_KIND_NONE != key->set_kind); |
765 | GNUNET_CRYPTO_hash (key, sizeof(struct SetKey), &hash); | 773 | GNUNET_CRYPTO_hash (key, |
766 | return GNUNET_CONTAINER_multihashmap_get (session->setmap, &hash); | 774 | sizeof(struct SetKey), |
775 | &hash); | ||
776 | return GNUNET_CONTAINER_multihashmap_get (session->setmap, | ||
777 | &hash); | ||
767 | } | 778 | } |
768 | 779 | ||
769 | 780 | ||
770 | static struct DiffEntry * | 781 | static struct DiffEntry * |
771 | lookup_diff (struct ConsensusSession *session, struct DiffKey *key) | 782 | lookup_diff (struct ConsensusSession *session, |
783 | const struct DiffKey *key) | ||
772 | { | 784 | { |
773 | struct GNUNET_HashCode hash; | 785 | struct GNUNET_HashCode hash; |
774 | 786 | ||
@@ -776,15 +788,18 @@ lookup_diff (struct ConsensusSession *session, struct DiffKey *key) | |||
776 | "P%u: looking up diff {%s}\n", | 788 | "P%u: looking up diff {%s}\n", |
777 | session->local_peer_idx, | 789 | session->local_peer_idx, |
778 | debug_str_diff_key (key)); | 790 | debug_str_diff_key (key)); |
779 | |||
780 | GNUNET_assert (DIFF_KIND_NONE != key->diff_kind); | 791 | GNUNET_assert (DIFF_KIND_NONE != key->diff_kind); |
781 | GNUNET_CRYPTO_hash (key, sizeof(struct DiffKey), &hash); | 792 | GNUNET_CRYPTO_hash (key, |
782 | return GNUNET_CONTAINER_multihashmap_get (session->diffmap, &hash); | 793 | sizeof(struct DiffKey), |
794 | &hash); | ||
795 | return GNUNET_CONTAINER_multihashmap_get (session->diffmap, | ||
796 | &hash); | ||
783 | } | 797 | } |
784 | 798 | ||
785 | 799 | ||
786 | static struct ReferendumEntry * | 800 | static struct ReferendumEntry * |
787 | lookup_rfn (struct ConsensusSession *session, struct RfnKey *key) | 801 | lookup_rfn (struct ConsensusSession *session, |
802 | const struct RfnKey *key) | ||
788 | { | 803 | { |
789 | struct GNUNET_HashCode hash; | 804 | struct GNUNET_HashCode hash; |
790 | 805 | ||
@@ -792,10 +807,12 @@ lookup_rfn (struct ConsensusSession *session, struct RfnKey *key) | |||
792 | "P%u: looking up rfn {%s}\n", | 807 | "P%u: looking up rfn {%s}\n", |
793 | session->local_peer_idx, | 808 | session->local_peer_idx, |
794 | debug_str_rfn_key (key)); | 809 | debug_str_rfn_key (key)); |
795 | |||
796 | GNUNET_assert (RFN_KIND_NONE != key->rfn_kind); | 810 | GNUNET_assert (RFN_KIND_NONE != key->rfn_kind); |
797 | GNUNET_CRYPTO_hash (key, sizeof(struct RfnKey), &hash); | 811 | GNUNET_CRYPTO_hash (key, |
798 | return GNUNET_CONTAINER_multihashmap_get (session->rfnmap, &hash); | 812 | sizeof(struct RfnKey), |
813 | &hash); | ||
814 | return GNUNET_CONTAINER_multihashmap_get (session->rfnmap, | ||
815 | &hash); | ||
799 | } | 816 | } |
800 | 817 | ||
801 | 818 | ||
@@ -829,7 +846,8 @@ diff_insert (struct DiffEntry *diff, | |||
829 | di->element = GNUNET_SET_element_dup (element); | 846 | di->element = GNUNET_SET_element_dup (element); |
830 | GNUNET_assert (GNUNET_OK == | 847 | GNUNET_assert (GNUNET_OK == |
831 | GNUNET_CONTAINER_multihashmap_put (diff->changes, | 848 | GNUNET_CONTAINER_multihashmap_put (diff->changes, |
832 | &hash, di, | 849 | &hash, |
850 | di, | ||
833 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 851 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
834 | } | 852 | } |
835 | 853 | ||
@@ -860,11 +878,10 @@ rfn_contest (struct ReferendumEntry *rfn, | |||
860 | static uint16_t | 878 | static uint16_t |
861 | rfn_noncontested (struct ReferendumEntry *rfn) | 879 | rfn_noncontested (struct ReferendumEntry *rfn) |
862 | { | 880 | { |
863 | uint16_t i; | ||
864 | uint16_t ret; | 881 | uint16_t ret; |
865 | 882 | ||
866 | ret = 0; | 883 | ret = 0; |
867 | for (i = 0; i < rfn->num_peers; i++) | 884 | for (uint16_t i = 0; i < rfn->num_peers; i++) |
868 | if ((GNUNET_YES == rfn->peer_commited[i]) && (GNUNET_NO == | 885 | if ((GNUNET_YES == rfn->peer_commited[i]) && (GNUNET_NO == |
869 | rfn->peer_contested[i])) | 886 | rfn->peer_contested[i])) |
870 | ret++; | 887 | ret++; |
@@ -993,7 +1010,8 @@ set_result_cb (void *cls, | |||
993 | 1010 | ||
994 | if (SET_KIND_NONE != setop->output_set.set_kind) | 1011 | if (SET_KIND_NONE != setop->output_set.set_kind) |
995 | { | 1012 | { |
996 | output_set = lookup_set (session, &setop->output_set); | 1013 | output_set = lookup_set (session, |
1014 | &setop->output_set); | ||
997 | GNUNET_assert (NULL != output_set); | 1015 | GNUNET_assert (NULL != output_set); |
998 | } | 1016 | } |
999 | 1017 | ||
@@ -1226,8 +1244,8 @@ struct Evilness | |||
1226 | 1244 | ||
1227 | 1245 | ||
1228 | static int | 1246 | static int |
1229 | parse_evilness_cram_subtype (const char *evil_subtype_str, struct | 1247 | parse_evilness_cram_subtype (const char *evil_subtype_str, |
1230 | Evilness *evil) | 1248 | struct Evilness *evil) |
1231 | { | 1249 | { |
1232 | if (0 == strcmp ("replace", evil_subtype_str)) | 1250 | if (0 == strcmp ("replace", evil_subtype_str)) |
1233 | { | 1251 | { |
@@ -1360,8 +1378,7 @@ cleanup: | |||
1360 | 1378 | ||
1361 | 1379 | ||
1362 | /** | 1380 | /** |
1363 | * Commit the appropriate set for a | 1381 | * Commit the appropriate set for a task. |
1364 | * task. | ||
1365 | */ | 1382 | */ |
1366 | static void | 1383 | static void |
1367 | commit_set (struct ConsensusSession *session, | 1384 | commit_set (struct ConsensusSession *session, |
@@ -1379,6 +1396,7 @@ commit_set (struct ConsensusSession *session, | |||
1379 | { | 1396 | { |
1380 | struct GNUNET_SET_Element element; | 1397 | struct GNUNET_SET_Element element; |
1381 | struct ConsensusElement ce = { 0 }; | 1398 | struct ConsensusElement ce = { 0 }; |
1399 | |||
1382 | ce.marker = CONSENSUS_MARKER_CONTESTED; | 1400 | ce.marker = CONSENSUS_MARKER_CONTESTED; |
1383 | element.data = &ce; | 1401 | element.data = &ce; |
1384 | element.size = sizeof(struct ConsensusElement); | 1402 | element.size = sizeof(struct ConsensusElement); |
@@ -1405,7 +1423,6 @@ commit_set (struct ConsensusSession *session, | |||
1405 | 1423 | ||
1406 | #ifdef EVIL | 1424 | #ifdef EVIL |
1407 | { | 1425 | { |
1408 | unsigned int i; | ||
1409 | struct Evilness evil; | 1426 | struct Evilness evil; |
1410 | 1427 | ||
1411 | get_evilness (session, &evil); | 1428 | get_evilness (session, &evil); |
@@ -1444,7 +1461,7 @@ commit_set (struct ConsensusSession *session, | |||
1444 | GNUNET_SET_commit (setop->op, set->h); | 1461 | GNUNET_SET_commit (setop->op, set->h); |
1445 | break; | 1462 | break; |
1446 | } | 1463 | } |
1447 | for (i = 0; i < evil.num; i++) | 1464 | for (unsigned int i = 0; i < evil.num; i++) |
1448 | { | 1465 | { |
1449 | struct GNUNET_SET_Element element; | 1466 | struct GNUNET_SET_Element element; |
1450 | struct ConsensusStuffedElement se = { | 1467 | struct ConsensusStuffedElement se = { |
@@ -1504,12 +1521,14 @@ commit_set (struct ConsensusSession *session, | |||
1504 | } | 1521 | } |
1505 | else | 1522 | else |
1506 | { | 1523 | { |
1507 | GNUNET_SET_commit (setop->op, set->h); | 1524 | GNUNET_SET_commit (setop->op, |
1525 | set->h); | ||
1508 | } | 1526 | } |
1509 | break; | 1527 | break; |
1510 | 1528 | ||
1511 | case EVILNESS_NONE: | 1529 | case EVILNESS_NONE: |
1512 | GNUNET_SET_commit (setop->op, set->h); | 1530 | GNUNET_SET_commit (setop->op, |
1531 | set->h); | ||
1513 | break; | 1532 | break; |
1514 | } | 1533 | } |
1515 | } | 1534 | } |
@@ -1536,11 +1555,12 @@ put_diff (struct ConsensusSession *session, | |||
1536 | { | 1555 | { |
1537 | struct GNUNET_HashCode hash; | 1556 | struct GNUNET_HashCode hash; |
1538 | 1557 | ||
1539 | GNUNET_assert (NULL != diff); | 1558 | GNUNET_CRYPTO_hash (&diff->key, |
1540 | 1559 | sizeof(struct DiffKey), | |
1541 | GNUNET_CRYPTO_hash (&diff->key, sizeof(struct DiffKey), &hash); | 1560 | &hash); |
1542 | GNUNET_assert (GNUNET_OK == | 1561 | GNUNET_assert (GNUNET_OK == |
1543 | GNUNET_CONTAINER_multihashmap_put (session->diffmap, &hash, | 1562 | GNUNET_CONTAINER_multihashmap_put (session->diffmap, |
1563 | &hash, | ||
1544 | diff, | 1564 | diff, |
1545 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1565 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1546 | } | 1566 | } |
@@ -1553,14 +1573,16 @@ put_set (struct ConsensusSession *session, | |||
1553 | struct GNUNET_HashCode hash; | 1573 | struct GNUNET_HashCode hash; |
1554 | 1574 | ||
1555 | GNUNET_assert (NULL != set->h); | 1575 | GNUNET_assert (NULL != set->h); |
1556 | |||
1557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1558 | "Putting set %s\n", | 1577 | "Putting set %s\n", |
1559 | debug_str_set_key (&set->key)); | 1578 | debug_str_set_key (&set->key)); |
1560 | 1579 | GNUNET_CRYPTO_hash (&set->key, | |
1561 | GNUNET_CRYPTO_hash (&set->key, sizeof(struct SetKey), &hash); | 1580 | sizeof(struct SetKey), |
1581 | &hash); | ||
1562 | GNUNET_assert (GNUNET_SYSERR != | 1582 | GNUNET_assert (GNUNET_SYSERR != |
1563 | GNUNET_CONTAINER_multihashmap_put (session->setmap, &hash, set, | 1583 | GNUNET_CONTAINER_multihashmap_put (session->setmap, |
1584 | &hash, | ||
1585 | set, | ||
1564 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); | 1586 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); |
1565 | } | 1587 | } |
1566 | 1588 | ||
@@ -1573,7 +1595,9 @@ put_rfn (struct ConsensusSession *session, | |||
1573 | 1595 | ||
1574 | GNUNET_CRYPTO_hash (&rfn->key, sizeof(struct RfnKey), &hash); | 1596 | GNUNET_CRYPTO_hash (&rfn->key, sizeof(struct RfnKey), &hash); |
1575 | GNUNET_assert (GNUNET_OK == | 1597 | GNUNET_assert (GNUNET_OK == |
1576 | GNUNET_CONTAINER_multihashmap_put (session->rfnmap, &hash, rfn, | 1598 | GNUNET_CONTAINER_multihashmap_put (session->rfnmap, |
1599 | &hash, | ||
1600 | rfn, | ||
1577 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1601 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1578 | } | 1602 | } |
1579 | 1603 | ||
@@ -1616,18 +1640,20 @@ apply_diff_to_rfn (struct DiffEntry *diff, | |||
1616 | } | 1640 | } |
1617 | 1641 | ||
1618 | 1642 | ||
1619 | struct DiffEntry * | 1643 | static struct DiffEntry * |
1620 | diff_create () | 1644 | diff_create (void) |
1621 | { | 1645 | { |
1622 | struct DiffEntry *d = GNUNET_new (struct DiffEntry); | 1646 | struct DiffEntry *d = GNUNET_new (struct DiffEntry); |
1623 | 1647 | ||
1624 | d->changes = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO); | 1648 | d->changes = GNUNET_CONTAINER_multihashmap_create (8, |
1649 | GNUNET_NO); | ||
1625 | 1650 | ||
1626 | return d; | 1651 | return d; |
1627 | } | 1652 | } |
1628 | 1653 | ||
1629 | 1654 | ||
1630 | struct DiffEntry * | 1655 | #if 0 |
1656 | static struct DiffEntry * | ||
1631 | diff_compose (struct DiffEntry *diff_1, | 1657 | diff_compose (struct DiffEntry *diff_1, |
1632 | struct DiffEntry *diff_2) | 1658 | struct DiffEntry *diff_2) |
1633 | { | 1659 | { |
@@ -1638,22 +1664,26 @@ diff_compose (struct DiffEntry *diff_1, | |||
1638 | diff_new = diff_create (); | 1664 | diff_new = diff_create (); |
1639 | 1665 | ||
1640 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (diff_1->changes); | 1666 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (diff_1->changes); |
1641 | while (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, | 1667 | while (GNUNET_YES == |
1642 | (const | 1668 | GNUNET_CONTAINER_multihashmap_iterator_next (iter, |
1643 | void **) & | 1669 | NULL, |
1644 | di)) | 1670 | (const void **) &di)) |
1645 | { | 1671 | { |
1646 | diff_insert (diff_new, di->weight, di->element); | 1672 | diff_insert (diff_new, |
1673 | di->weight, | ||
1674 | di->element); | ||
1647 | } | 1675 | } |
1648 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); | 1676 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); |
1649 | 1677 | ||
1650 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (diff_2->changes); | 1678 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (diff_2->changes); |
1651 | while (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, | 1679 | while (GNUNET_YES == |
1652 | (const | 1680 | GNUNET_CONTAINER_multihashmap_iterator_next (iter, |
1653 | void **) & | 1681 | NULL, |
1654 | di)) | 1682 | (const void **) &di)) |
1655 | { | 1683 | { |
1656 | diff_insert (diff_new, di->weight, di->element); | 1684 | diff_insert (diff_new, |
1685 | di->weight, | ||
1686 | di->element); | ||
1657 | } | 1687 | } |
1658 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); | 1688 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); |
1659 | 1689 | ||
@@ -1661,6 +1691,9 @@ diff_compose (struct DiffEntry *diff_1, | |||
1661 | } | 1691 | } |
1662 | 1692 | ||
1663 | 1693 | ||
1694 | #endif | ||
1695 | |||
1696 | |||
1664 | struct ReferendumEntry * | 1697 | struct ReferendumEntry * |
1665 | rfn_create (uint16_t size) | 1698 | rfn_create (uint16_t size) |
1666 | { | 1699 | { |
@@ -1701,14 +1734,13 @@ rfn_majority (const struct ReferendumEntry *rfn, | |||
1701 | { | 1734 | { |
1702 | uint16_t votes_yes = 0; | 1735 | uint16_t votes_yes = 0; |
1703 | uint16_t num_commited = 0; | 1736 | uint16_t num_commited = 0; |
1704 | uint16_t i; | ||
1705 | 1737 | ||
1706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1707 | "Computing rfn majority for element %s of rfn {%s}\n", | 1739 | "Computing rfn majority for element %s of rfn {%s}\n", |
1708 | debug_str_element (ri->element), | 1740 | debug_str_element (ri->element), |
1709 | debug_str_rfn_key (&rfn->key)); | 1741 | debug_str_rfn_key (&rfn->key)); |
1710 | 1742 | ||
1711 | for (i = 0; i < rfn->num_peers; i++) | 1743 | for (uint16_t i = 0; i < rfn->num_peers; i++) |
1712 | { | 1744 | { |
1713 | if (GNUNET_NO == rfn->peer_commited[i]) | 1745 | if (GNUNET_NO == rfn->peer_commited[i]) |
1714 | continue; | 1746 | continue; |
@@ -1739,7 +1771,8 @@ struct SetCopyCls | |||
1739 | 1771 | ||
1740 | 1772 | ||
1741 | static void | 1773 | static void |
1742 | set_copy_cb (void *cls, struct GNUNET_SET_Handle *copy) | 1774 | set_copy_cb (void *cls, |
1775 | struct GNUNET_SET_Handle *copy) | ||
1743 | { | 1776 | { |
1744 | struct SetCopyCls *scc = cls; | 1777 | struct SetCopyCls *scc = cls; |
1745 | struct TaskEntry *task = scc->task; | 1778 | struct TaskEntry *task = scc->task; |
@@ -1821,8 +1854,6 @@ set_mutation_done (void *cls) | |||
1821 | static void | 1854 | static void |
1822 | try_finish_step_early (struct Step *step) | 1855 | try_finish_step_early (struct Step *step) |
1823 | { | 1856 | { |
1824 | unsigned int i; | ||
1825 | |||
1826 | if (GNUNET_YES == step->is_running) | 1857 | if (GNUNET_YES == step->is_running) |
1827 | return; | 1858 | return; |
1828 | if (GNUNET_YES == step->is_finished) | 1859 | if (GNUNET_YES == step->is_finished) |
@@ -1838,7 +1869,7 @@ try_finish_step_early (struct Step *step) | |||
1838 | step->debug_name); | 1869 | step->debug_name); |
1839 | #endif | 1870 | #endif |
1840 | 1871 | ||
1841 | for (i = 0; i < step->subordinates_len; i++) | 1872 | for (unsigned int i = 0; i < step->subordinates_len; i++) |
1842 | { | 1873 | { |
1843 | GNUNET_assert (step->subordinates[i]->pending_prereq > 0); | 1874 | GNUNET_assert (step->subordinates[i]->pending_prereq > 0); |
1844 | step->subordinates[i]->pending_prereq--; | 1875 | step->subordinates[i]->pending_prereq--; |
@@ -1859,8 +1890,6 @@ try_finish_step_early (struct Step *step) | |||
1859 | static void | 1890 | static void |
1860 | finish_step (struct Step *step) | 1891 | finish_step (struct Step *step) |
1861 | { | 1892 | { |
1862 | unsigned int i; | ||
1863 | |||
1864 | GNUNET_assert (step->finished_tasks == step->tasks_len); | 1893 | GNUNET_assert (step->finished_tasks == step->tasks_len); |
1865 | GNUNET_assert (GNUNET_YES == step->is_running); | 1894 | GNUNET_assert (GNUNET_YES == step->is_running); |
1866 | GNUNET_assert (GNUNET_NO == step->is_finished); | 1895 | GNUNET_assert (GNUNET_NO == step->is_finished); |
@@ -1872,7 +1901,7 @@ finish_step (struct Step *step) | |||
1872 | step->subordinates_len); | 1901 | step->subordinates_len); |
1873 | #endif | 1902 | #endif |
1874 | 1903 | ||
1875 | for (i = 0; i < step->subordinates_len; i++) | 1904 | for (unsigned int i = 0; i < step->subordinates_len; i++) |
1876 | { | 1905 | { |
1877 | GNUNET_assert (step->subordinates[i]->pending_prereq > 0); | 1906 | GNUNET_assert (step->subordinates[i]->pending_prereq > 0); |
1878 | step->subordinates[i]->pending_prereq--; | 1907 | step->subordinates[i]->pending_prereq--; |
@@ -1918,7 +1947,9 @@ task_start_apply_round (struct TaskEntry *task) | |||
1918 | set_out = lookup_set (session, &sk_out); | 1947 | set_out = lookup_set (session, &sk_out); |
1919 | if (NULL == set_out) | 1948 | if (NULL == set_out) |
1920 | { | 1949 | { |
1921 | create_set_copy_for_task (task, &sk_in, &sk_out); | 1950 | create_set_copy_for_task (task, |
1951 | &sk_in, | ||
1952 | &sk_out); | ||
1922 | return; | 1953 | return; |
1923 | } | 1954 | } |
1924 | 1955 | ||
@@ -2162,7 +2193,9 @@ task_start_reconcile (struct TaskEntry *task) | |||
2162 | we clone the input set. */ | 2193 | we clone the input set. */ |
2163 | if (NULL == lookup_set (session, &setop->output_set)) | 2194 | if (NULL == lookup_set (session, &setop->output_set)) |
2164 | { | 2195 | { |
2165 | create_set_copy_for_task (task, &setop->input_set, &setop->output_set); | 2196 | create_set_copy_for_task (task, |
2197 | &setop->input_set, | ||
2198 | &setop->output_set); | ||
2166 | return; | 2199 | return; |
2167 | } | 2200 | } |
2168 | } | 2201 | } |
@@ -2212,11 +2245,8 @@ task_start_reconcile (struct TaskEntry *task) | |||
2212 | "P%u: Looking up set {%s} to run remote union\n", | 2245 | "P%u: Looking up set {%s} to run remote union\n", |
2213 | session->local_peer_idx, | 2246 | session->local_peer_idx, |
2214 | debug_str_set_key (&setop->input_set)); | 2247 | debug_str_set_key (&setop->input_set)); |
2215 | |||
2216 | rcm.header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT); | 2248 | rcm.header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT); |
2217 | rcm.header.size = htons (sizeof(struct | 2249 | rcm.header.size = htons (sizeof(rcm)); |
2218 | GNUNET_CONSENSUS_RoundContextMessage)); | ||
2219 | |||
2220 | rcm.kind = htons (task->key.kind); | 2250 | rcm.kind = htons (task->key.kind); |
2221 | rcm.peer1 = htons (task->key.peer1); | 2251 | rcm.peer1 = htons (task->key.peer1); |
2222 | rcm.peer2 = htons (task->key.peer2); | 2252 | rcm.peer2 = htons (task->key.peer2); |
@@ -2227,8 +2257,9 @@ task_start_reconcile (struct TaskEntry *task) | |||
2227 | GNUNET_assert (NULL == setop->op); | 2257 | GNUNET_assert (NULL == setop->op); |
2228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2229 | "P%u: initiating set op with P%u, our set is %s\n", | 2259 | "P%u: initiating set op with P%u, our set is %s\n", |
2230 | session->local_peer_idx, task->key.peer2, debug_str_set_key ( | 2260 | session->local_peer_idx, |
2231 | &setop->input_set)); | 2261 | task->key.peer2, |
2262 | debug_str_set_key (&setop->input_set)); | ||
2232 | 2263 | ||
2233 | struct GNUNET_SET_Option opts[] = { | 2264 | struct GNUNET_SET_Option opts[] = { |
2234 | { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, | 2265 | { GNUNET_SET_OPTION_BYZANTINE, { .num = session->lower_bound } }, |
@@ -2286,15 +2317,17 @@ task_start_eval_echo (struct TaskEntry *task) | |||
2286 | output_set = lookup_set (session, &sk_out); | 2317 | output_set = lookup_set (session, &sk_out); |
2287 | if (NULL == output_set) | 2318 | if (NULL == output_set) |
2288 | { | 2319 | { |
2289 | create_set_copy_for_task (task, &sk_in, &sk_out); | 2320 | create_set_copy_for_task (task, |
2321 | &sk_in, | ||
2322 | &sk_out); | ||
2290 | return; | 2323 | return; |
2291 | } | 2324 | } |
2292 | 2325 | ||
2293 | |||
2294 | { | 2326 | { |
2295 | // FIXME: should be marked as a shallow copy, so | 2327 | // FIXME: should be marked as a shallow copy, so |
2296 | // we can destroy everything correctly | 2328 | // we can destroy everything correctly |
2297 | struct SetEntry *last_set = GNUNET_new (struct SetEntry); | 2329 | struct SetEntry *last_set = GNUNET_new (struct SetEntry); |
2330 | |||
2298 | last_set->h = output_set->h; | 2331 | last_set->h = output_set->h; |
2299 | last_set->key = (struct SetKey) { SET_KIND_LAST_GRADECAST }; | 2332 | last_set->key = (struct SetKey) { SET_KIND_LAST_GRADECAST }; |
2300 | put_set (session, last_set); | 2333 | put_set (session, last_set); |
@@ -2306,13 +2339,10 @@ task_start_eval_echo (struct TaskEntry *task) | |||
2306 | 2339 | ||
2307 | progress_cls = GNUNET_new (struct SetMutationProgressCls); | 2340 | progress_cls = GNUNET_new (struct SetMutationProgressCls); |
2308 | progress_cls->task = task; | 2341 | progress_cls->task = task; |
2309 | |||
2310 | rk_in = (struct RfnKey) { RFN_KIND_ECHO, task->key.repetition, | 2342 | rk_in = (struct RfnKey) { RFN_KIND_ECHO, task->key.repetition, |
2311 | task->key.leader }; | 2343 | task->key.leader }; |
2312 | input_rfn = lookup_rfn (session, &rk_in); | 2344 | input_rfn = lookup_rfn (session, &rk_in); |
2313 | |||
2314 | GNUNET_assert (NULL != input_rfn); | 2345 | GNUNET_assert (NULL != input_rfn); |
2315 | |||
2316 | iter = GNUNET_CONTAINER_multihashmap_iterator_create ( | 2346 | iter = GNUNET_CONTAINER_multihashmap_iterator_create ( |
2317 | input_rfn->rfn_elements); | 2347 | input_rfn->rfn_elements); |
2318 | GNUNET_assert (NULL != iter); | 2348 | GNUNET_assert (NULL != iter); |
@@ -2334,7 +2364,8 @@ task_start_eval_echo (struct TaskEntry *task) | |||
2334 | can't simply send "nothing" for the value. Thus we mark our 'confirm' | 2364 | can't simply send "nothing" for the value. Thus we mark our 'confirm' |
2335 | reconciliation as contested. Other peers might not know that the | 2365 | reconciliation as contested. Other peers might not know that the |
2336 | leader is faulty, thus we still re-distribute in the confirmation | 2366 | leader is faulty, thus we still re-distribute in the confirmation |
2337 | round. */output_set->is_contested = GNUNET_YES; | 2367 | round. */// |
2368 | output_set->is_contested = GNUNET_YES; | ||
2338 | } | 2369 | } |
2339 | 2370 | ||
2340 | switch (majority_vote) | 2371 | switch (majority_vote) |
@@ -2384,29 +2415,27 @@ task_start_finish (struct TaskEntry *task) | |||
2384 | struct SetEntry *final_set; | 2415 | struct SetEntry *final_set; |
2385 | struct ConsensusSession *session = task->step->session; | 2416 | struct ConsensusSession *session = task->step->session; |
2386 | 2417 | ||
2387 | final_set = lookup_set (session, &task->cls.finish.input_set); | 2418 | final_set = lookup_set (session, |
2388 | 2419 | &task->cls.finish.input_set); | |
2389 | GNUNET_assert (NULL != final_set); | 2420 | GNUNET_assert (NULL != final_set); |
2390 | |||
2391 | |||
2392 | GNUNET_SET_iterate (final_set->h, | 2421 | GNUNET_SET_iterate (final_set->h, |
2393 | send_to_client_iter, | 2422 | &send_to_client_iter, |
2394 | task); | 2423 | task); |
2395 | } | 2424 | } |
2396 | 2425 | ||
2397 | 2426 | ||
2398 | static void | 2427 | static void |
2399 | start_task (struct ConsensusSession *session, struct TaskEntry *task) | 2428 | start_task (struct ConsensusSession *session, |
2429 | struct TaskEntry *task) | ||
2400 | { | 2430 | { |
2401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "P%u: starting task {%s}\n", | 2431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2402 | session->local_peer_idx, debug_str_task_key (&task->key)); | 2432 | "P%u: starting task {%s}\n", |
2403 | 2433 | session->local_peer_idx, | |
2434 | debug_str_task_key (&task->key)); | ||
2404 | GNUNET_assert (GNUNET_NO == task->is_started); | 2435 | GNUNET_assert (GNUNET_NO == task->is_started); |
2405 | GNUNET_assert (GNUNET_NO == task->is_finished); | 2436 | GNUNET_assert (GNUNET_NO == task->is_finished); |
2406 | GNUNET_assert (NULL != task->start); | 2437 | GNUNET_assert (NULL != task->start); |
2407 | |||
2408 | task->start (task); | 2438 | task->start (task); |
2409 | |||
2410 | task->is_started = GNUNET_YES; | 2439 | task->is_started = GNUNET_YES; |
2411 | } | 2440 | } |
2412 | 2441 | ||
@@ -2427,8 +2456,6 @@ run_ready_steps (struct ConsensusSession *session) | |||
2427 | if ((GNUNET_NO == step->is_running) && (0 == step->pending_prereq) && | 2456 | if ((GNUNET_NO == step->is_running) && (0 == step->pending_prereq) && |
2428 | (GNUNET_NO == step->is_finished)) | 2457 | (GNUNET_NO == step->is_finished)) |
2429 | { | 2458 | { |
2430 | size_t i; | ||
2431 | |||
2432 | GNUNET_assert (0 == step->finished_tasks); | 2459 | GNUNET_assert (0 == step->finished_tasks); |
2433 | 2460 | ||
2434 | #ifdef GNUNET_EXTRA_LOGGING | 2461 | #ifdef GNUNET_EXTRA_LOGGING |
@@ -2440,7 +2467,7 @@ run_ready_steps (struct ConsensusSession *session) | |||
2440 | #endif | 2467 | #endif |
2441 | 2468 | ||
2442 | step->is_running = GNUNET_YES; | 2469 | step->is_running = GNUNET_YES; |
2443 | for (i = 0; i < step->tasks_len; i++) | 2470 | for (size_t i = 0; i < step->tasks_len; i++) |
2444 | start_task (session, step->tasks[i]); | 2471 | start_task (session, step->tasks[i]); |
2445 | 2472 | ||
2446 | /* Sometimes there is no task to trigger finishing the step, so we have to do it here. */ | 2473 | /* Sometimes there is no task to trigger finishing the step, so we have to do it here. */ |
@@ -2463,9 +2490,7 @@ finish_task (struct TaskEntry *task) | |||
2463 | { | 2490 | { |
2464 | GNUNET_assert (GNUNET_NO == task->is_finished); | 2491 | GNUNET_assert (GNUNET_NO == task->is_finished); |
2465 | task->is_finished = GNUNET_YES; | 2492 | task->is_finished = GNUNET_YES; |
2466 | |||
2467 | task->step->finished_tasks++; | 2493 | task->step->finished_tasks++; |
2468 | |||
2469 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2494 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2470 | "P%u: Finishing Task {%s} (now %u/%u tasks finished in step)\n", | 2495 | "P%u: Finishing Task {%s} (now %u/%u tasks finished in step)\n", |
2471 | task->step->session->local_peer_idx, | 2496 | task->step->session->local_peer_idx, |
@@ -2486,12 +2511,10 @@ finish_task (struct TaskEntry *task) | |||
2486 | * @return index of peer, -1 if peer is not in session | 2511 | * @return index of peer, -1 if peer is not in session |
2487 | */ | 2512 | */ |
2488 | static int | 2513 | static int |
2489 | get_peer_idx (const struct GNUNET_PeerIdentity *peer, const struct | 2514 | get_peer_idx (const struct GNUNET_PeerIdentity *peer, |
2490 | ConsensusSession *session) | 2515 | const struct ConsensusSession *session) |
2491 | { | 2516 | { |
2492 | int i; | 2517 | for (int i = 0; i < session->num_peers; i++) |
2493 | |||
2494 | for (i = 0; i < session->num_peers; i++) | ||
2495 | if (0 == GNUNET_memcmp (peer, &session->peers[i])) | 2518 | if (0 == GNUNET_memcmp (peer, &session->peers[i])) |
2496 | return i; | 2519 | return i; |
2497 | return -1; | 2520 | return -1; |
@@ -2528,14 +2551,15 @@ compute_global_id (struct ConsensusSession *session, | |||
2528 | 2551 | ||
2529 | 2552 | ||
2530 | /** | 2553 | /** |
2531 | * Compare two peer identities. | 2554 | * Compare two peer identities (for qsort()). |
2532 | * | 2555 | * |
2533 | * @param h1 some peer identity | 2556 | * @param h1 some peer identity |
2534 | * @param h2 some peer identity | 2557 | * @param h2 some peer identity |
2535 | * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. | 2558 | * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. |
2536 | */ | 2559 | */ |
2537 | static int | 2560 | static int |
2538 | peer_id_cmp (const void *h1, const void *h2) | 2561 | peer_id_cmp (const void *h1, |
2562 | const void *h2) | ||
2539 | { | 2563 | { |
2540 | return memcmp (h1, h2, sizeof(struct GNUNET_PeerIdentity)); | 2564 | return memcmp (h1, h2, sizeof(struct GNUNET_PeerIdentity)); |
2541 | } | 2565 | } |
@@ -2549,9 +2573,9 @@ peer_id_cmp (const void *h1, const void *h2) | |||
2549 | * @param join_msg join message with the list of peers participating at the end | 2573 | * @param join_msg join message with the list of peers participating at the end |
2550 | */ | 2574 | */ |
2551 | static void | 2575 | static void |
2552 | initialize_session_peer_list (struct ConsensusSession *session, | 2576 | initialize_session_peer_list ( |
2553 | const struct | 2577 | struct ConsensusSession *session, |
2554 | GNUNET_CONSENSUS_JoinMessage *join_msg) | 2578 | const struct GNUNET_CONSENSUS_JoinMessage *join_msg) |
2555 | { | 2579 | { |
2556 | const struct GNUNET_PeerIdentity *msg_peers | 2580 | const struct GNUNET_PeerIdentity *msg_peers |
2557 | = (const struct GNUNET_PeerIdentity *) &join_msg[1]; | 2581 | = (const struct GNUNET_PeerIdentity *) &join_msg[1]; |
@@ -2578,29 +2602,31 @@ initialize_session_peer_list (struct ConsensusSession *session, | |||
2578 | struct GNUNET_PeerIdentity); | 2602 | struct GNUNET_PeerIdentity); |
2579 | if (GNUNET_NO == local_peer_in_list) | 2603 | if (GNUNET_NO == local_peer_in_list) |
2580 | session->peers[session->num_peers - 1] = my_peer; | 2604 | session->peers[session->num_peers - 1] = my_peer; |
2581 | |||
2582 | GNUNET_memcpy (session->peers, | 2605 | GNUNET_memcpy (session->peers, |
2583 | msg_peers, | 2606 | msg_peers, |
2584 | ntohl (join_msg->num_peers) * sizeof(struct | 2607 | ntohl (join_msg->num_peers) |
2585 | GNUNET_PeerIdentity)); | 2608 | * sizeof(struct GNUNET_PeerIdentity)); |
2586 | qsort (session->peers, | 2609 | qsort (session->peers, |
2587 | session->num_peers, | 2610 | session->num_peers, |
2588 | sizeof(struct GNUNET_PeerIdentity), | 2611 | sizeof (struct GNUNET_PeerIdentity), |
2589 | &peer_id_cmp); | 2612 | &peer_id_cmp); |
2590 | } | 2613 | } |
2591 | 2614 | ||
2592 | 2615 | ||
2593 | static struct TaskEntry * | 2616 | static struct TaskEntry * |
2594 | lookup_task (struct ConsensusSession *session, | 2617 | lookup_task (const struct ConsensusSession *session, |
2595 | struct TaskKey *key) | 2618 | const struct TaskKey *key) |
2596 | { | 2619 | { |
2597 | struct GNUNET_HashCode hash; | 2620 | struct GNUNET_HashCode hash; |
2598 | 2621 | ||
2599 | 2622 | GNUNET_CRYPTO_hash (key, | |
2600 | GNUNET_CRYPTO_hash (key, sizeof(struct TaskKey), &hash); | 2623 | sizeof(struct TaskKey), |
2601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up task hash %s\n", | 2624 | &hash); |
2625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2626 | "Looking up task hash %s\n", | ||
2602 | GNUNET_h2s (&hash)); | 2627 | GNUNET_h2s (&hash)); |
2603 | return GNUNET_CONTAINER_multihashmap_get (session->taskmap, &hash); | 2628 | return GNUNET_CONTAINER_multihashmap_get (session->taskmap, |
2629 | &hash); | ||
2604 | } | 2630 | } |
2605 | 2631 | ||
2606 | 2632 | ||
@@ -2695,7 +2721,7 @@ set_listen_cb (void *cls, | |||
2695 | task->cls.setop.op = GNUNET_SET_accept (request, | 2721 | task->cls.setop.op = GNUNET_SET_accept (request, |
2696 | GNUNET_SET_RESULT_SYMMETRIC, | 2722 | GNUNET_SET_RESULT_SYMMETRIC, |
2697 | opts, | 2723 | opts, |
2698 | set_result_cb, | 2724 | &set_result_cb, |
2699 | task); | 2725 | task); |
2700 | 2726 | ||
2701 | /* If the task hasn't been started yet, | 2727 | /* If the task hasn't been started yet, |
@@ -2716,11 +2742,8 @@ put_task (struct GNUNET_CONTAINER_MultiHashMap *taskmap, | |||
2716 | struct Step *s; | 2742 | struct Step *s; |
2717 | 2743 | ||
2718 | GNUNET_assert (NULL != t->step); | 2744 | GNUNET_assert (NULL != t->step); |
2719 | |||
2720 | t = GNUNET_memdup (t, sizeof(struct TaskEntry)); | 2745 | t = GNUNET_memdup (t, sizeof(struct TaskEntry)); |
2721 | |||
2722 | s = t->step; | 2746 | s = t->step; |
2723 | |||
2724 | if (s->tasks_len == s->tasks_cap) | 2747 | if (s->tasks_len == s->tasks_cap) |
2725 | { | 2748 | { |
2726 | unsigned int target_size = 3 * (s->tasks_cap + 1) / 2; | 2749 | unsigned int target_size = 3 * (s->tasks_cap + 1) / 2; |
@@ -2739,9 +2762,13 @@ put_task (struct GNUNET_CONTAINER_MultiHashMap *taskmap, | |||
2739 | s->tasks[s->tasks_len] = t; | 2762 | s->tasks[s->tasks_len] = t; |
2740 | s->tasks_len++; | 2763 | s->tasks_len++; |
2741 | 2764 | ||
2742 | GNUNET_CRYPTO_hash (&t->key, sizeof(struct TaskKey), &round_hash); | 2765 | GNUNET_CRYPTO_hash (&t->key, |
2766 | sizeof(struct TaskKey), | ||
2767 | &round_hash); | ||
2743 | GNUNET_assert (GNUNET_OK == | 2768 | GNUNET_assert (GNUNET_OK == |
2744 | GNUNET_CONTAINER_multihashmap_put (taskmap, &round_hash, t, | 2769 | GNUNET_CONTAINER_multihashmap_put (taskmap, |
2770 | &round_hash, | ||
2771 | t, | ||
2745 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 2772 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
2746 | } | 2773 | } |
2747 | 2774 | ||
@@ -2762,7 +2789,9 @@ install_step_timeouts (struct ConsensusSession *session) | |||
2762 | * Arrange two peers in some canonical order. | 2789 | * Arrange two peers in some canonical order. |
2763 | */ | 2790 | */ |
2764 | static void | 2791 | static void |
2765 | arrange_peers (uint16_t *p1, uint16_t *p2, uint16_t n) | 2792 | arrange_peers (uint16_t *p1, |
2793 | uint16_t *p2, | ||
2794 | uint16_t n) | ||
2766 | { | 2795 | { |
2767 | uint16_t a; | 2796 | uint16_t a; |
2768 | uint16_t b; | 2797 | uint16_t b; |
@@ -2800,7 +2829,8 @@ arrange_peers (uint16_t *p1, uint16_t *p2, uint16_t n) | |||
2800 | * Record @a dep as a dependency of @a step. | 2829 | * Record @a dep as a dependency of @a step. |
2801 | */ | 2830 | */ |
2802 | static void | 2831 | static void |
2803 | step_depend_on (struct Step *step, struct Step *dep) | 2832 | step_depend_on (struct Step *step, |
2833 | struct Step *dep) | ||
2804 | { | 2834 | { |
2805 | /* We're not checking for cyclic dependencies, | 2835 | /* We're not checking for cyclic dependencies, |
2806 | but this is a cheap sanity check. */ | 2836 | but this is a cheap sanity check. */ |
@@ -2839,7 +2869,9 @@ step_depend_on (struct Step *step, struct Step *dep) | |||
2839 | 2869 | ||
2840 | 2870 | ||
2841 | static struct Step * | 2871 | static struct Step * |
2842 | create_step (struct ConsensusSession *session, int round, int early_finishable) | 2872 | create_step (struct ConsensusSession *session, |
2873 | int round, | ||
2874 | int early_finishable) | ||
2843 | { | 2875 | { |
2844 | struct Step *step; | 2876 | struct Step *step; |
2845 | 2877 | ||
@@ -2855,8 +2887,7 @@ create_step (struct ConsensusSession *session, int round, int early_finishable) | |||
2855 | 2887 | ||
2856 | 2888 | ||
2857 | /** | 2889 | /** |
2858 | * Construct the task graph for a single | 2890 | * Construct the task graph for a single gradecast. |
2859 | * gradecast. | ||
2860 | */ | 2891 | */ |
2861 | static void | 2892 | static void |
2862 | construct_task_graph_gradecast (struct ConsensusSession *session, | 2893 | construct_task_graph_gradecast (struct ConsensusSession *session, |
@@ -2867,35 +2898,32 @@ construct_task_graph_gradecast (struct ConsensusSession *session, | |||
2867 | { | 2898 | { |
2868 | uint16_t n = session->num_peers; | 2899 | uint16_t n = session->num_peers; |
2869 | uint16_t me = session->local_peer_idx; | 2900 | uint16_t me = session->local_peer_idx; |
2870 | |||
2871 | uint16_t p1; | 2901 | uint16_t p1; |
2872 | uint16_t p2; | 2902 | uint16_t p2; |
2873 | |||
2874 | /* The task we're currently setting up. */ | 2903 | /* The task we're currently setting up. */ |
2875 | struct TaskEntry task; | 2904 | struct TaskEntry task; |
2876 | |||
2877 | struct Step *step; | 2905 | struct Step *step; |
2878 | struct Step *prev_step; | 2906 | struct Step *prev_step; |
2879 | |||
2880 | uint16_t round; | 2907 | uint16_t round; |
2881 | 2908 | ||
2882 | unsigned int k; | ||
2883 | |||
2884 | round = step_before->round + 1; | 2909 | round = step_before->round + 1; |
2885 | 2910 | ||
2886 | /* gcast step 1: leader disseminates */ | 2911 | /* gcast step 1: leader disseminates */ |
2887 | 2912 | step = create_step (session, | |
2888 | step = create_step (session, round, GNUNET_YES); | 2913 | round, |
2889 | 2914 | GNUNET_YES); | |
2890 | #ifdef GNUNET_EXTRA_LOGGING | 2915 | #ifdef GNUNET_EXTRA_LOGGING |
2891 | GNUNET_asprintf (&step->debug_name, "disseminate leader %u rep %u", lead, | 2916 | GNUNET_asprintf (&step->debug_name, |
2917 | "disseminate leader %u rep %u", | ||
2918 | lead, | ||
2892 | rep); | 2919 | rep); |
2893 | #endif | 2920 | #endif |
2894 | step_depend_on (step, step_before); | 2921 | step_depend_on (step, |
2922 | step_before); | ||
2895 | 2923 | ||
2896 | if (lead == me) | 2924 | if (lead == me) |
2897 | { | 2925 | { |
2898 | for (k = 0; k < n; k++) | 2926 | for (unsigned int k = 0; k < n; k++) |
2899 | { | 2927 | { |
2900 | if (k == me) | 2928 | if (k == me) |
2901 | continue; | 2929 | continue; |
@@ -2952,13 +2980,19 @@ construct_task_graph_gradecast (struct ConsensusSession *session, | |||
2952 | /* gcast phase 2: echo */ | 2980 | /* gcast phase 2: echo */ |
2953 | prev_step = step; | 2981 | prev_step = step; |
2954 | round += 1; | 2982 | round += 1; |
2955 | step = create_step (session, round, GNUNET_YES); | 2983 | step = create_step (session, |
2984 | round, | ||
2985 | GNUNET_YES); | ||
2956 | #ifdef GNUNET_EXTRA_LOGGING | 2986 | #ifdef GNUNET_EXTRA_LOGGING |
2957 | GNUNET_asprintf (&step->debug_name, "echo leader %u rep %u", lead, rep); | 2987 | GNUNET_asprintf (&step->debug_name, |
2988 | "echo leader %u rep %u", | ||
2989 | lead, | ||
2990 | rep); | ||
2958 | #endif | 2991 | #endif |
2959 | step_depend_on (step, prev_step); | 2992 | step_depend_on (step, |
2993 | prev_step); | ||
2960 | 2994 | ||
2961 | for (k = 0; k < n; k++) | 2995 | for (unsigned int k = 0; k < n; k++) |
2962 | { | 2996 | { |
2963 | p1 = k; | 2997 | p1 = k; |
2964 | p2 = me; | 2998 | p2 = me; |
@@ -3001,7 +3035,7 @@ construct_task_graph_gradecast (struct ConsensusSession *session, | |||
3001 | step_depend_on (step, prev_step); | 3035 | step_depend_on (step, prev_step); |
3002 | 3036 | ||
3003 | /* gcast phase 3: confirmation and grading */ | 3037 | /* gcast phase 3: confirmation and grading */ |
3004 | for (k = 0; k < n; k++) | 3038 | for (unsigned int k = 0; k < n; k++) |
3005 | { | 3039 | { |
3006 | p1 = k; | 3040 | p1 = k; |
3007 | p2 = me; | 3041 | p2 = me; |
@@ -3050,22 +3084,15 @@ construct_task_graph (struct ConsensusSession *session) | |||
3050 | { | 3084 | { |
3051 | uint16_t n = session->num_peers; | 3085 | uint16_t n = session->num_peers; |
3052 | uint16_t t = n / 3; | 3086 | uint16_t t = n / 3; |
3053 | |||
3054 | uint16_t me = session->local_peer_idx; | 3087 | uint16_t me = session->local_peer_idx; |
3055 | |||
3056 | /* The task we're currently setting up. */ | 3088 | /* The task we're currently setting up. */ |
3057 | struct TaskEntry task; | 3089 | struct TaskEntry task; |
3058 | |||
3059 | /* Current leader */ | 3090 | /* Current leader */ |
3060 | unsigned int lead; | 3091 | unsigned int lead; |
3061 | |||
3062 | struct Step *step; | 3092 | struct Step *step; |
3063 | struct Step *prev_step; | 3093 | struct Step *prev_step; |
3064 | |||
3065 | unsigned int round = 0; | 3094 | unsigned int round = 0; |
3066 | 3095 | ||
3067 | unsigned int i; | ||
3068 | |||
3069 | // XXX: introduce first step, | 3096 | // XXX: introduce first step, |
3070 | // where we wait for all insert acks | 3097 | // where we wait for all insert acks |
3071 | // from the set service | 3098 | // from the set service |
@@ -3082,7 +3109,7 @@ construct_task_graph (struct ConsensusSession *session) | |||
3082 | step->debug_name = GNUNET_strdup ("all to all"); | 3109 | step->debug_name = GNUNET_strdup ("all to all"); |
3083 | #endif | 3110 | #endif |
3084 | 3111 | ||
3085 | for (i = 0; i < n; i++) | 3112 | for (unsigned int i = 0; i < n; i++) |
3086 | { | 3113 | { |
3087 | uint16_t p1; | 3114 | uint16_t p1; |
3088 | uint16_t p2; | 3115 | uint16_t p2; |
@@ -3111,7 +3138,7 @@ construct_task_graph (struct ConsensusSession *session) | |||
3111 | step_depend_on (step, prev_step); | 3138 | step_depend_on (step, prev_step); |
3112 | 3139 | ||
3113 | 3140 | ||
3114 | for (i = 0; i < n; i++) | 3141 | for (unsigned int i = 0; i < n; i++) |
3115 | { | 3142 | { |
3116 | uint16_t p1; | 3143 | uint16_t p1; |
3117 | uint16_t p2; | 3144 | uint16_t p2; |
@@ -3140,7 +3167,7 @@ construct_task_graph (struct ConsensusSession *session) | |||
3140 | /* Byzantine union */ | 3167 | /* Byzantine union */ |
3141 | 3168 | ||
3142 | /* sequential repetitions of the gradecasts */ | 3169 | /* sequential repetitions of the gradecasts */ |
3143 | for (i = 0; i < t + 1; i++) | 3170 | for (unsigned int i = 0; i < t + 1; i++) |
3144 | { | 3171 | { |
3145 | struct Step *step_rep_start; | 3172 | struct Step *step_rep_start; |
3146 | struct Step *step_rep_end; | 3173 | struct Step *step_rep_end; |
@@ -3243,9 +3270,9 @@ handle_client_join (void *cls, | |||
3243 | NULL != other_session; | 3270 | NULL != other_session; |
3244 | other_session = other_session->next) | 3271 | other_session = other_session->next) |
3245 | { | 3272 | { |
3246 | if ((other_session != session) && | 3273 | if ( (other_session != session) && |
3247 | (0 == GNUNET_CRYPTO_hash_cmp (&session->global_id, | 3274 | (0 == GNUNET_CRYPTO_hash_cmp (&session->global_id, |
3248 | &other_session->global_id))) | 3275 | &other_session->global_id)) ) |
3249 | break; | 3276 | break; |
3250 | } | 3277 | } |
3251 | 3278 | ||
@@ -3262,9 +3289,9 @@ handle_client_join (void *cls, | |||
3262 | GNUNET_h2s (&m->session_id), | 3289 | GNUNET_h2s (&m->session_id), |
3263 | session->num_peers, | 3290 | session->num_peers, |
3264 | session->local_peer_idx, | 3291 | session->local_peer_idx, |
3265 | GNUNET_STRINGS_relative_time_to_string | 3292 | GNUNET_STRINGS_relative_time_to_string ( |
3266 | (GNUNET_TIME_absolute_get_difference (session->conclude_start, | 3293 | GNUNET_TIME_absolute_get_difference (session->conclude_start, |
3267 | session->conclude_deadline), | 3294 | session->conclude_deadline), |
3268 | GNUNET_YES)); | 3295 | GNUNET_YES)); |
3269 | 3296 | ||
3270 | session->set_listener | 3297 | session->set_listener |
@@ -3309,13 +3336,6 @@ handle_client_join (void *cls, | |||
3309 | } | 3336 | } |
3310 | 3337 | ||
3311 | 3338 | ||
3312 | static void | ||
3313 | client_insert_done (void *cls) | ||
3314 | { | ||
3315 | // FIXME: implement | ||
3316 | } | ||
3317 | |||
3318 | |||
3319 | /** | 3339 | /** |
3320 | * Called when a client performs an insert operation. | 3340 | * Called when a client performs an insert operation. |
3321 | * | 3341 | * |
@@ -3352,19 +3372,13 @@ handle_client_insert (void *cls, | |||
3352 | GNUNET_SERVICE_client_drop (session->client); | 3372 | GNUNET_SERVICE_client_drop (session->client); |
3353 | return; | 3373 | return; |
3354 | } | 3374 | } |
3355 | 3375 | element_size = ntohs (msg->header.size) - sizeof(*msg); | |
3356 | element_size = ntohs (msg->header.size) - sizeof(struct | ||
3357 | GNUNET_CONSENSUS_ElementMessage); | ||
3358 | ce = GNUNET_malloc (sizeof(struct ConsensusElement) + element_size); | 3376 | ce = GNUNET_malloc (sizeof(struct ConsensusElement) + element_size); |
3359 | GNUNET_memcpy (&ce[1], &msg[1], element_size); | 3377 | GNUNET_memcpy (&ce[1], |
3378 | &msg[1], | ||
3379 | element_size); | ||
3360 | ce->payload_type = msg->element_type; | 3380 | ce->payload_type = msg->element_type; |
3361 | 3381 | ||
3362 | struct GNUNET_SET_Element element = { | ||
3363 | .element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT, | ||
3364 | .size = sizeof(struct ConsensusElement) + element_size, | ||
3365 | .data = ce, | ||
3366 | }; | ||
3367 | |||
3368 | { | 3382 | { |
3369 | struct SetKey key = { SET_KIND_CURRENT, 0, 0 }; | 3383 | struct SetKey key = { SET_KIND_CURRENT, 0, 0 }; |
3370 | struct SetEntry *entry; | 3384 | struct SetEntry *entry; |
@@ -3376,19 +3390,25 @@ handle_client_insert (void *cls, | |||
3376 | } | 3390 | } |
3377 | 3391 | ||
3378 | session->num_client_insert_pending++; | 3392 | session->num_client_insert_pending++; |
3379 | GNUNET_SET_add_element (initial_set, | ||
3380 | &element, | ||
3381 | &client_insert_done, | ||
3382 | session); | ||
3383 | 3393 | ||
3384 | #ifdef GNUNET_EXTRA_LOGGING | ||
3385 | { | 3394 | { |
3395 | struct GNUNET_SET_Element element = { | ||
3396 | .element_type = GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT, | ||
3397 | .size = sizeof(struct ConsensusElement) + element_size, | ||
3398 | .data = ce, | ||
3399 | }; | ||
3400 | |||
3401 | GNUNET_SET_add_element (initial_set, | ||
3402 | &element, | ||
3403 | NULL, | ||
3404 | NULL); | ||
3405 | #ifdef GNUNET_EXTRA_LOGGING | ||
3386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3387 | "P%u: element %s added\n", | 3407 | "P%u: element %s added\n", |
3388 | session->local_peer_idx, | 3408 | session->local_peer_idx, |
3389 | debug_str_element (&element)); | 3409 | debug_str_element (&element)); |
3390 | } | ||
3391 | #endif | 3410 | #endif |
3411 | } | ||
3392 | GNUNET_free (ce); | 3412 | GNUNET_free (ce); |
3393 | GNUNET_SERVICE_client_continue (session->client); | 3413 | GNUNET_SERVICE_client_continue (session->client); |
3394 | } | 3414 | } |
@@ -3513,10 +3533,10 @@ client_disconnect_cb (void *cls, | |||
3513 | GNUNET_CONTAINER_DLL_remove (sessions_head, | 3533 | GNUNET_CONTAINER_DLL_remove (sessions_head, |
3514 | sessions_tail, | 3534 | sessions_tail, |
3515 | session); | 3535 | session); |
3516 | |||
3517 | while (session->set_handles_head) | 3536 | while (session->set_handles_head) |
3518 | { | 3537 | { |
3519 | struct SetHandle *sh = session->set_handles_head; | 3538 | struct SetHandle *sh = session->set_handles_head; |
3539 | |||
3520 | session->set_handles_head = sh->next; | 3540 | session->set_handles_head = sh->next; |
3521 | GNUNET_SET_destroy (sh->h); | 3541 | GNUNET_SET_destroy (sh->h); |
3522 | GNUNET_free (sh); | 3542 | GNUNET_free (sh); |
@@ -3528,8 +3548,8 @@ client_disconnect_cb (void *cls, | |||
3528 | /** | 3548 | /** |
3529 | * Define "main" method using service macro. | 3549 | * Define "main" method using service macro. |
3530 | */ | 3550 | */ |
3531 | GNUNET_SERVICE_MAIN | 3551 | GNUNET_SERVICE_MAIN ( |
3532 | ("consensus", | 3552 | "consensus", |
3533 | GNUNET_SERVICE_OPTION_NONE, | 3553 | GNUNET_SERVICE_OPTION_NONE, |
3534 | &run, | 3554 | &run, |
3535 | &client_connect_cb, | 3555 | &client_connect_cb, |
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c index fb6da5bcd..cdac12ed5 100644 --- a/src/consensus/plugin_block_consensus.c +++ b/src/consensus/plugin_block_consensus.c | |||
@@ -58,13 +58,12 @@ block_plugin_consensus_evaluate (void *cls, | |||
58 | const void *reply_block, | 58 | const void *reply_block, |
59 | size_t reply_block_size) | 59 | size_t reply_block_size) |
60 | { | 60 | { |
61 | if (reply_block_size < sizeof(struct ConsensusElement)) | ||
62 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
63 | |||
64 | const struct ConsensusElement *ce = reply_block; | 61 | const struct ConsensusElement *ce = reply_block; |
65 | 62 | ||
66 | if ((0 != ce->marker) || | 63 | if (reply_block_size < sizeof(struct ConsensusElement)) |
67 | (0 == ce->payload_type)) | 64 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
65 | if ( (0 != ce->marker) || | ||
66 | (0 == ce->payload_type) ) | ||
68 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 67 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
69 | 68 | ||
70 | return GNUNET_BLOCK_evaluate (ctx, | 69 | return GNUNET_BLOCK_evaluate (ctx, |
@@ -75,8 +74,8 @@ block_plugin_consensus_evaluate (void *cls, | |||
75 | xquery, | 74 | xquery, |
76 | xquery_size, | 75 | xquery_size, |
77 | &ce[1], | 76 | &ce[1], |
78 | reply_block_size - sizeof(struct | 77 | reply_block_size |
79 | ConsensusElement)); | 78 | - sizeof(struct ConsensusElement)); |
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c index 13764d520..579de774f 100644 --- a/src/gns/test_gns_proxy.c +++ b/src/gns/test_gns_proxy.c | |||
@@ -189,7 +189,7 @@ copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | static int | 192 | static enum MHD_Result |
193 | mhd_ahc (void *cls, | 193 | mhd_ahc (void *cls, |
194 | struct MHD_Connection *connection, | 194 | struct MHD_Connection *connection, |
195 | const char *url, | 195 | const char *url, |
@@ -528,8 +528,6 @@ run (void *cls, | |||
528 | int | 528 | int |
529 | main (int argc, char *const *argv) | 529 | main (int argc, char *const *argv) |
530 | { | 530 | { |
531 | char *tmp_argv; | ||
532 | |||
533 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 531 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
534 | GNUNET_GETOPT_option_uint16 ('p', | 532 | GNUNET_GETOPT_option_uint16 ('p', |
535 | "port", | 533 | "port", |
@@ -559,7 +557,7 @@ main (int argc, char *const *argv) | |||
559 | } | 557 | } |
560 | if (GNUNET_OK != | 558 | if (GNUNET_OK != |
561 | GNUNET_STRINGS_get_utf8_args (argc, argv, | 559 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
562 | &argc, &tmp_argv)) | 560 | &argc, &argv)) |
563 | return 2; | 561 | return 2; |
564 | GNUNET_log_setup ("gnunet-gns-proxy-test", | 562 | GNUNET_log_setup ("gnunet-gns-proxy-test", |
565 | "WARNING", | 563 | "WARNING", |
@@ -570,7 +568,7 @@ main (int argc, char *const *argv) | |||
570 | options, | 568 | options, |
571 | &run, NULL)) | 569 | &run, NULL)) |
572 | return 1; | 570 | return 1; |
573 | GNUNET_free (tmp_argv); | 571 | GNUNET_free_nz ((void*) argv); |
574 | return global_ret; | 572 | return global_ret; |
575 | } | 573 | } |
576 | 574 | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e542038d3..202abb7ac 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -99,6 +99,8 @@ gnunetinclude_HEADERS = \ | |||
99 | gnunet_secretsharing_service.h \ | 99 | gnunet_secretsharing_service.h \ |
100 | gnunet_service_lib.h \ | 100 | gnunet_service_lib.h \ |
101 | gnunet_set_service.h \ | 101 | gnunet_set_service.h \ |
102 | gnunet_seti_service.h \ | ||
103 | gnunet_setu_service.h \ | ||
102 | gnunet_signal_lib.h \ | 104 | gnunet_signal_lib.h \ |
103 | gnunet_signatures.h \ | 105 | gnunet_signatures.h \ |
104 | gnunet_socks.h \ | 106 | gnunet_socks.h \ |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index efd696b36..085d7187f 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -619,7 +619,7 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, | |||
619 | * @param result where to store the hash code | 619 | * @param result where to store the hash code |
620 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 620 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
621 | */ | 621 | */ |
622 | int | 622 | enum GNUNET_GenericReturnValue |
623 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, | 623 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, |
624 | size_t enclen, | 624 | size_t enclen, |
625 | struct GNUNET_HashCode *result); | 625 | struct GNUNET_HashCode *result); |
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index ea6b95e2d..431b9a671 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -336,6 +336,14 @@ void | |||
336 | GNUNET_TRANSPORT_communicator_address_remove ( | 336 | GNUNET_TRANSPORT_communicator_address_remove ( |
337 | struct GNUNET_TRANSPORT_AddressIdentifier *ai); | 337 | struct GNUNET_TRANSPORT_AddressIdentifier *ai); |
338 | 338 | ||
339 | /** | ||
340 | * Notify transport service that this communicator no longer provides all its addresses for this peer. | ||
341 | * | ||
342 | * @param ch The communicator handle. | ||
343 | */ | ||
344 | void | ||
345 | GNUNET_TRANSPORT_communicator_address_remove_all ( | ||
346 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch); | ||
339 | 347 | ||
340 | /** | 348 | /** |
341 | * The communicator asks the transport service to route a message via | 349 | * The communicator asks the transport service to route a message via |
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index ab281a645..b9306b802 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -862,7 +862,7 @@ main (int argc, char *const argv[]) | |||
862 | gettext_noop ("List credentials for EGO"), | 862 | gettext_noop ("List credentials for EGO"), |
863 | &list_credentials), | 863 | &list_credentials), |
864 | GNUNET_GETOPT_option_string ('I', | 864 | GNUNET_GETOPT_option_string ('I', |
865 | "Credential ID", | 865 | "credential-id", |
866 | "CREDENTIAL_ID", | 866 | "CREDENTIAL_ID", |
867 | gettext_noop ( | 867 | gettext_noop ( |
868 | "Credential to use for attribute"), | 868 | "Credential to use for attribute"), |
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c index 148865223..6f52f3a4e 100644 --- a/src/reclaim/plugin_reclaim_credential_jwt.c +++ b/src/reclaim/plugin_reclaim_credential_jwt.c | |||
@@ -177,6 +177,8 @@ jwt_parse_attributes (void *cls, | |||
177 | json_object_foreach (json_val, key, value) { | 177 | json_object_foreach (json_val, key, value) { |
178 | if (0 == strcmp ("iss", key)) | 178 | if (0 == strcmp ("iss", key)) |
179 | continue; | 179 | continue; |
180 | if (0 == strcmp ("jti", key)) | ||
181 | continue; | ||
180 | if (0 == strcmp ("exp", key)) | 182 | if (0 == strcmp ("exp", key)) |
181 | continue; | 183 | continue; |
182 | if (0 == strcmp ("iat", key)) | 184 | if (0 == strcmp ("iat", key)) |
diff --git a/src/seti/Makefile.am b/src/seti/Makefile.am index b4980b670..522f33ece 100644 --- a/src/seti/Makefile.am +++ b/src/seti/Makefile.am | |||
@@ -37,7 +37,7 @@ gnunet_seti_profiler_LDADD = \ | |||
37 | 37 | ||
38 | gnunet_service_seti_SOURCES = \ | 38 | gnunet_service_seti_SOURCES = \ |
39 | gnunet-service-seti.c \ | 39 | gnunet-service-seti.c \ |
40 | gnunet-service-set_protocol.h | 40 | gnunet-service-seti_protocol.h |
41 | gnunet_service_seti_LDADD = \ | 41 | gnunet_service_seti_LDADD = \ |
42 | $(top_builddir)/src/util/libgnunetutil.la \ | 42 | $(top_builddir)/src/util/libgnunetutil.la \ |
43 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 43 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
diff --git a/src/setu/Makefile.am b/src/setu/Makefile.am index b37ceba51..cc7711462 100644 --- a/src/setu/Makefile.am +++ b/src/setu/Makefile.am | |||
@@ -46,7 +46,7 @@ gnunet_setu_ibf_profiler_LDADD = \ | |||
46 | $(GN_LIBINTL) | 46 | $(GN_LIBINTL) |
47 | 47 | ||
48 | gnunet_service_setu_SOURCES = \ | 48 | gnunet_service_setu_SOURCES = \ |
49 | gnunet-service-setu.c gnunet-service-setu.h \ | 49 | gnunet-service-setu.c gnunet-service-setu_protocol.h \ |
50 | ibf.c ibf.h \ | 50 | ibf.c ibf.h \ |
51 | gnunet-service-setu_strata_estimator.c gnunet-service-setu_strata_estimator.h \ | 51 | gnunet-service-setu_strata_estimator.c gnunet-service-setu_strata_estimator.h \ |
52 | gnunet-service-setu_protocol.h | 52 | gnunet-service-setu_protocol.h |
diff --git a/src/setu/test_setu.conf b/src/setu/test_setu.conf new file mode 100644 index 000000000..4eaf3f0c0 --- /dev/null +++ b/src/setu/test_setu.conf | |||
@@ -0,0 +1,32 @@ | |||
1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-set/ | ||
5 | |||
6 | [setu] | ||
7 | START_ON_DEMAND = YES | ||
8 | #PREFIX = valgrind --leak-check=full | ||
9 | #PREFIX = gdbserver :1234 | ||
10 | OPTIONS = -L INFO | ||
11 | |||
12 | [transport] | ||
13 | PLUGINS = unix | ||
14 | OPTIONS = -LERROR | ||
15 | |||
16 | [nat] | ||
17 | RETURN_LOCAL_ADDRESSES = YES | ||
18 | DISABLEV6 = YES | ||
19 | USE_LOCALADDR = YES | ||
20 | |||
21 | [peerinfo] | ||
22 | NO_IO = YES | ||
23 | |||
24 | [nat] | ||
25 | # Use addresses from the local network interfaces (inluding loopback, but also others) | ||
26 | USE_LOCALADDR = YES | ||
27 | |||
28 | # Disable IPv6 support | ||
29 | DISABLEV6 = NO | ||
30 | |||
31 | # Do we use addresses from localhost address ranges? (::1, 127.0.0.0/8) | ||
32 | RETURN_LOCAL_ADDRESSES = YES | ||
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 880145424..59f42496a 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -308,6 +308,38 @@ struct TCPRekey | |||
308 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; | 308 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; |
309 | }; | 309 | }; |
310 | 310 | ||
311 | /** | ||
312 | * Signature we use to verify that the ephemeral key was really chosen by | ||
313 | * the specified sender. | ||
314 | */ | ||
315 | struct TcpRekeySignature | ||
316 | { | ||
317 | /** | ||
318 | * Purpose must be #GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY | ||
319 | */ | ||
320 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
321 | |||
322 | /** | ||
323 | * Identity of the inititor of the TCP connection (TCP client). | ||
324 | */ | ||
325 | struct GNUNET_PeerIdentity sender; | ||
326 | |||
327 | /** | ||
328 | * Presumed identity of the target of the TCP connection (TCP server) | ||
329 | */ | ||
330 | struct GNUNET_PeerIdentity receiver; | ||
331 | |||
332 | /** | ||
333 | * Ephemeral key used by the @e sender. | ||
334 | */ | ||
335 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral; | ||
336 | |||
337 | /** | ||
338 | * Monotonic time of @e sender, to possibly help detect replay attacks | ||
339 | * (if receiver persists times by sender). | ||
340 | */ | ||
341 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; | ||
342 | }; | ||
311 | 343 | ||
312 | /** | 344 | /** |
313 | * TCP finish. Sender asks for the connection to be closed. | 345 | * TCP finish. Sender asks for the connection to be closed. |
@@ -362,11 +394,6 @@ struct Queue | |||
362 | struct GNUNET_PeerIdentity target; | 394 | struct GNUNET_PeerIdentity target; |
363 | 395 | ||
364 | /** | 396 | /** |
365 | * ID of listen task | ||
366 | */ | ||
367 | struct GNUNET_SCHEDULER_Task *listen_task; | ||
368 | |||
369 | /** | ||
370 | * Listen socket. | 397 | * Listen socket. |
371 | */ | 398 | */ |
372 | struct GNUNET_NETWORK_Handle *listen_sock; | 399 | struct GNUNET_NETWORK_Handle *listen_sock; |
@@ -606,11 +633,6 @@ struct ProtoQueue | |||
606 | struct ProtoQueue *prev; | 633 | struct ProtoQueue *prev; |
607 | 634 | ||
608 | /** | 635 | /** |
609 | * ID of listen task | ||
610 | */ | ||
611 | struct GNUNET_SCHEDULER_Task *listen_task; | ||
612 | |||
613 | /** | ||
614 | * Listen socket. | 636 | * Listen socket. |
615 | */ | 637 | */ |
616 | struct GNUNET_NETWORK_Handle *listen_sock; | 638 | struct GNUNET_NETWORK_Handle *listen_sock; |
@@ -729,6 +751,11 @@ static struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | |||
729 | static struct GNUNET_CONTAINER_MultiPeerMap *queue_map; | 751 | static struct GNUNET_CONTAINER_MultiPeerMap *queue_map; |
730 | 752 | ||
731 | /** | 753 | /** |
754 | * ListenTasks (map from socket to `struct ListenTask`) | ||
755 | */ | ||
756 | static struct GNUNET_CONTAINER_MultiHashMap *lt_map; | ||
757 | |||
758 | /** | ||
732 | * Our public key. | 759 | * Our public key. |
733 | */ | 760 | */ |
734 | static struct GNUNET_PeerIdentity my_identity; | 761 | static struct GNUNET_PeerIdentity my_identity; |
@@ -784,6 +811,16 @@ struct Addresses *addrs_head; | |||
784 | struct Addresses *addrs_tail; | 811 | struct Addresses *addrs_tail; |
785 | 812 | ||
786 | /** | 813 | /** |
814 | * Head of DLL with ListenTasks. | ||
815 | */ | ||
816 | struct ListenTask *lts_head; | ||
817 | |||
818 | /** | ||
819 | * Head of DLL with ListenTask. | ||
820 | */ | ||
821 | struct ListenTask *lts_tail; | ||
822 | |||
823 | /** | ||
787 | * Number of addresses in the DLL for register at NAT service. | 824 | * Number of addresses in the DLL for register at NAT service. |
788 | */ | 825 | */ |
789 | int addrs_lens; | 826 | int addrs_lens; |
@@ -799,6 +836,16 @@ size_t unverified_size; | |||
799 | static struct GNUNET_PEERSTORE_Handle *peerstore; | 836 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
800 | 837 | ||
801 | /** | 838 | /** |
839 | * A flag indicating we are already doing a shutdown. | ||
840 | */ | ||
841 | int shutdown_running = GNUNET_NO; | ||
842 | |||
843 | /** | ||
844 | * The port the communicator should be assigned to. | ||
845 | */ | ||
846 | unsigned int bind_port; | ||
847 | |||
848 | /** | ||
802 | * We have been notified that our listen socket has something to | 849 | * We have been notified that our listen socket has something to |
803 | * read. Do the read and reschedule this function to be called again | 850 | * read. Do the read and reschedule this function to be called again |
804 | * once more is available. | 851 | * once more is available. |
@@ -808,7 +855,6 @@ static struct GNUNET_PEERSTORE_Handle *peerstore; | |||
808 | static void | 855 | static void |
809 | listen_cb (void *cls); | 856 | listen_cb (void *cls); |
810 | 857 | ||
811 | |||
812 | /** | 858 | /** |
813 | * Functions with this signature are called whenever we need | 859 | * Functions with this signature are called whenever we need |
814 | * to close a queue due to a disconnect or failure to | 860 | * to close a queue due to a disconnect or failure to |
@@ -819,11 +865,14 @@ listen_cb (void *cls); | |||
819 | static void | 865 | static void |
820 | queue_destroy (struct Queue *queue) | 866 | queue_destroy (struct Queue *queue) |
821 | { | 867 | { |
822 | struct GNUNET_MQ_Handle *mq; | 868 | struct ListenTask *lt = NULL; |
823 | struct ListenTask *lt; | 869 | struct GNUNET_HashCode h_sock; |
824 | lt = GNUNET_new (struct ListenTask); | 870 | |
825 | lt->listen_sock = queue->listen_sock; | 871 | GNUNET_CRYPTO_hash (queue->listen_sock, |
826 | lt->listen_task = queue->listen_task; | 872 | sizeof(queue->listen_sock), |
873 | &h_sock); | ||
874 | |||
875 | lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock); | ||
827 | 876 | ||
828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
829 | "Disconnecting queue for peer `%s'\n", | 878 | "Disconnecting queue for peer `%s'\n", |
@@ -858,11 +907,6 @@ queue_destroy (struct Queue *queue) | |||
858 | GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get); | 907 | GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get); |
859 | queue->handshake_ack_monotime_get = NULL; | 908 | queue->handshake_ack_monotime_get = NULL; |
860 | } | 909 | } |
861 | if (NULL != (mq = queue->mq)) | ||
862 | { | ||
863 | queue->mq = NULL; | ||
864 | GNUNET_MQ_destroy (mq); | ||
865 | } | ||
866 | if (NULL != queue->qh) | 910 | if (NULL != queue->qh) |
867 | { | 911 | { |
868 | GNUNET_TRANSPORT_communicator_mq_del (queue->qh); | 912 | GNUNET_TRANSPORT_communicator_mq_del (queue->qh); |
@@ -885,7 +929,11 @@ queue_destroy (struct Queue *queue) | |||
885 | GNUNET_SCHEDULER_cancel (queue->write_task); | 929 | GNUNET_SCHEDULER_cancel (queue->write_task); |
886 | queue->write_task = NULL; | 930 | queue->write_task = NULL; |
887 | } | 931 | } |
888 | GNUNET_NETWORK_socket_close (queue->sock); | 932 | if (GNUNET_SYSERR == GNUNET_NETWORK_socket_close (queue->sock)) |
933 | { | ||
934 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
935 | "closing socket failed\n"); | ||
936 | } | ||
889 | gcry_cipher_close (queue->in_cipher); | 937 | gcry_cipher_close (queue->in_cipher); |
890 | gcry_cipher_close (queue->out_cipher); | 938 | gcry_cipher_close (queue->out_cipher); |
891 | GNUNET_free (queue->address); | 939 | GNUNET_free (queue->address); |
@@ -894,12 +942,18 @@ queue_destroy (struct Queue *queue) | |||
894 | else | 942 | else |
895 | GNUNET_free (queue); | 943 | GNUNET_free (queue); |
896 | 944 | ||
897 | if (NULL == lt->listen_task) | 945 | if ((! shutdown_running) && (NULL == lt->listen_task)) |
946 | { | ||
947 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
948 | "add read net listen\n"); | ||
898 | lt->listen_task = GNUNET_SCHEDULER_add_read_net ( | 949 | lt->listen_task = GNUNET_SCHEDULER_add_read_net ( |
899 | GNUNET_TIME_UNIT_FOREVER_REL, | 950 | GNUNET_TIME_UNIT_FOREVER_REL, |
900 | lt->listen_sock, | 951 | lt->listen_sock, |
901 | &listen_cb, | 952 | &listen_cb, |
902 | lt); | 953 | lt); |
954 | } | ||
955 | else | ||
956 | GNUNET_free (lt); | ||
903 | } | 957 | } |
904 | 958 | ||
905 | 959 | ||
@@ -1001,6 +1055,13 @@ core_read_finished_cb (void *cls, int success) | |||
1001 | "# messages lost in communicator API towards CORE", | 1055 | "# messages lost in communicator API towards CORE", |
1002 | 1, | 1056 | 1, |
1003 | GNUNET_NO); | 1057 | GNUNET_NO); |
1058 | if (NULL == queue) | ||
1059 | return; | ||
1060 | |||
1061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1062 | "backpressure %u\n", | ||
1063 | queue->backpressure); | ||
1064 | |||
1004 | queue->backpressure--; | 1065 | queue->backpressure--; |
1005 | /* handle deferred queue destruction */ | 1066 | /* handle deferred queue destruction */ |
1006 | if ((queue->destroyed) && (0 == queue->backpressure)) | 1067 | if ((queue->destroyed) && (0 == queue->backpressure)) |
@@ -1008,15 +1069,18 @@ core_read_finished_cb (void *cls, int success) | |||
1008 | GNUNET_free (queue); | 1069 | GNUNET_free (queue); |
1009 | return; | 1070 | return; |
1010 | } | 1071 | } |
1011 | reschedule_queue_timeout (queue); | 1072 | else if (GNUNET_YES != queue->destroyed) |
1012 | /* possibly unchoke reading, now that CORE made progress */ | 1073 | { |
1013 | if (NULL == queue->read_task) | 1074 | reschedule_queue_timeout (queue); |
1014 | queue->read_task = | 1075 | /* possibly unchoke reading, now that CORE made progress */ |
1015 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( | 1076 | if (NULL == queue->read_task) |
1016 | queue->timeout), | 1077 | queue->read_task = |
1017 | queue->sock, | 1078 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( |
1018 | &queue_read, | 1079 | queue->timeout), |
1019 | queue); | 1080 | queue->sock, |
1081 | &queue_read, | ||
1082 | queue); | ||
1083 | } | ||
1020 | } | 1084 | } |
1021 | 1085 | ||
1022 | 1086 | ||
@@ -1219,13 +1283,34 @@ rekey_monotime_cb (void *cls, | |||
1219 | static void | 1283 | static void |
1220 | do_rekey (struct Queue *queue, const struct TCPRekey *rekey) | 1284 | do_rekey (struct Queue *queue, const struct TCPRekey *rekey) |
1221 | { | 1285 | { |
1222 | struct TcpHandshakeSignature thp; | 1286 | struct TcpRekeySignature thp; |
1287 | |||
1223 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); | 1288 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); |
1224 | thp.purpose.size = htonl (sizeof(thp)); | 1289 | thp.purpose.size = htonl (sizeof(thp)); |
1290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1291 | "do_rekey size %u\n", | ||
1292 | thp.purpose.size); | ||
1225 | thp.sender = queue->target; | 1293 | thp.sender = queue->target; |
1294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1295 | "sender %s\n", | ||
1296 | GNUNET_p2s (&thp.sender.public_key)); | ||
1297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1298 | "sender %s\n", | ||
1299 | GNUNET_p2s (&queue->target.public_key)); | ||
1226 | thp.receiver = my_identity; | 1300 | thp.receiver = my_identity; |
1301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1302 | "receiver %s\n", | ||
1303 | GNUNET_p2s (&thp.receiver.public_key)); | ||
1227 | thp.ephemeral = rekey->ephemeral; | 1304 | thp.ephemeral = rekey->ephemeral; |
1305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1306 | "ephemeral %s\n", | ||
1307 | GNUNET_e2s (&thp.ephemeral)); | ||
1228 | thp.monotonic_time = rekey->monotonic_time; | 1308 | thp.monotonic_time = rekey->monotonic_time; |
1309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1310 | "time %s\n", | ||
1311 | GNUNET_STRINGS_absolute_time_to_string ( | ||
1312 | GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); | ||
1313 | GNUNET_assert (ntohl ((&thp)->purpose.size) == sizeof (*(&thp))); | ||
1229 | if (GNUNET_OK != | 1314 | if (GNUNET_OK != |
1230 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, | 1315 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, |
1231 | &thp, | 1316 | &thp, |
@@ -1359,7 +1444,7 @@ try_handle_plaintext (struct Queue *queue) | |||
1359 | if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) | 1444 | if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) |
1360 | { | 1445 | { |
1361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1362 | "Already received data of size %u bigger than KX size %u!\n", | 1447 | "Already received data of size %lu bigger than KX size %lu!\n", |
1363 | unverified_size, | 1448 | unverified_size, |
1364 | INITIAL_CORE_KX_SIZE); | 1449 | INITIAL_CORE_KX_SIZE); |
1365 | GNUNET_break_op (0); | 1450 | GNUNET_break_op (0); |
@@ -1636,6 +1721,8 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, | |||
1636 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1721 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1637 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); | 1722 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); |
1638 | #endif | 1723 | #endif |
1724 | v6.sin6_flowinfo = 0; | ||
1725 | v6.sin6_scope_id = 0; | ||
1639 | in = GNUNET_memdup (&v6, sizeof(v6)); | 1726 | in = GNUNET_memdup (&v6, sizeof(v6)); |
1640 | *sock_len = sizeof(struct sockaddr_in6); | 1727 | *sock_len = sizeof(struct sockaddr_in6); |
1641 | 1728 | ||
@@ -1739,11 +1826,19 @@ extract_address (const char *bindto) | |||
1739 | char *cp; | 1826 | char *cp; |
1740 | char *rest = NULL; | 1827 | char *rest = NULL; |
1741 | 1828 | ||
1829 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1830 | "extract address with bindto %s\n", | ||
1831 | bindto); | ||
1832 | |||
1742 | if (NULL == bindto) | 1833 | if (NULL == bindto) |
1743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1834 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1744 | "bindto is NULL\n"); | 1835 | "bindto is NULL\n"); |
1745 | 1836 | ||
1746 | cp = GNUNET_strdup (bindto); | 1837 | cp = GNUNET_strdup (bindto); |
1838 | |||
1839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1840 | "extract address 2\n"); | ||
1841 | |||
1747 | start = cp; | 1842 | start = cp; |
1748 | if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) | 1843 | if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) |
1749 | { | 1844 | { |
@@ -1763,7 +1858,11 @@ extract_address (const char *bindto) | |||
1763 | } | 1858 | } |
1764 | } | 1859 | } |
1765 | 1860 | ||
1766 | GNUNET_free (cp); | 1861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1862 | "extract address 3\n"); | ||
1863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1864 | "extract address with start %s\n", | ||
1865 | start); | ||
1767 | 1866 | ||
1768 | return start; | 1867 | return start; |
1769 | } | 1868 | } |
@@ -1865,10 +1964,25 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1865 | // cp = GNUNET_strdup (bindto); | 1964 | // cp = GNUNET_strdup (bindto); |
1866 | start = extract_address (bindto); | 1965 | start = extract_address (bindto); |
1867 | 1966 | ||
1967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1968 | "start %s\n", | ||
1969 | start); | ||
1970 | |||
1971 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1972 | "!bindto %s\n", | ||
1973 | bindto); | ||
1974 | |||
1975 | |||
1976 | |||
1868 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | 1977 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) |
1869 | { | 1978 | { |
1870 | // colon = strrchr (cp, ':'); | 1979 | // colon = strrchr (cp, ':'); |
1871 | port = extract_port (bindto); | 1980 | port = extract_port (bindto); |
1981 | |||
1982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1983 | "port %u\n", | ||
1984 | port); | ||
1985 | |||
1872 | in = tcp_address_to_sockaddr_numeric_v4 (sock_len, v4, port); | 1986 | in = tcp_address_to_sockaddr_numeric_v4 (sock_len, v4, port); |
1873 | } | 1987 | } |
1874 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | 1988 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) |
@@ -1877,6 +1991,11 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1877 | port = extract_port (bindto); | 1991 | port = extract_port (bindto); |
1878 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); | 1992 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); |
1879 | } | 1993 | } |
1994 | else{ | ||
1995 | GNUNET_assert (0); | ||
1996 | } | ||
1997 | |||
1998 | // GNUNET_free (start); | ||
1880 | 1999 | ||
1881 | return in; | 2000 | return in; |
1882 | } | 2001 | } |
@@ -1913,7 +2032,7 @@ static void | |||
1913 | inject_rekey (struct Queue *queue) | 2032 | inject_rekey (struct Queue *queue) |
1914 | { | 2033 | { |
1915 | struct TCPRekey rekey; | 2034 | struct TCPRekey rekey; |
1916 | struct TcpHandshakeSignature thp; | 2035 | struct TcpRekeySignature thp; |
1917 | 2036 | ||
1918 | GNUNET_assert (0 == queue->pwrite_off); | 2037 | GNUNET_assert (0 == queue->pwrite_off); |
1919 | memset (&rekey, 0, sizeof(rekey)); | 2038 | memset (&rekey, 0, sizeof(rekey)); |
@@ -1925,10 +2044,26 @@ inject_rekey (struct Queue *queue) | |||
1925 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); | 2044 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); |
1926 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); | 2045 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); |
1927 | thp.purpose.size = htonl (sizeof(thp)); | 2046 | thp.purpose.size = htonl (sizeof(thp)); |
2047 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2048 | "inject_rekey size %u\n", | ||
2049 | thp.purpose.size); | ||
1928 | thp.sender = my_identity; | 2050 | thp.sender = my_identity; |
2051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2052 | "sender %s\n", | ||
2053 | GNUNET_p2s (&thp.sender.public_key)); | ||
1929 | thp.receiver = queue->target; | 2054 | thp.receiver = queue->target; |
2055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2056 | "receiver %s\n", | ||
2057 | GNUNET_p2s (&thp.receiver.public_key)); | ||
1930 | thp.ephemeral = rekey.ephemeral; | 2058 | thp.ephemeral = rekey.ephemeral; |
2059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2060 | "ephemeral %s\n", | ||
2061 | GNUNET_e2s (&thp.ephemeral)); | ||
1931 | thp.monotonic_time = rekey.monotonic_time; | 2062 | thp.monotonic_time = rekey.monotonic_time; |
2063 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2064 | "time %s\n", | ||
2065 | GNUNET_STRINGS_absolute_time_to_string ( | ||
2066 | GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); | ||
1932 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 2067 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
1933 | &thp, | 2068 | &thp, |
1934 | &rekey.sender_sig); | 2069 | &rekey.sender_sig); |
@@ -2004,10 +2139,11 @@ queue_write (void *cls) | |||
2004 | queue->cwrite_off += queue->pwrite_off; | 2139 | queue->cwrite_off += queue->pwrite_off; |
2005 | queue->pwrite_off = 0; | 2140 | queue->pwrite_off = 0; |
2006 | } | 2141 | } |
2007 | if ((0 == queue->pwrite_off) && | 2142 | if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) && |
2008 | ((0 == queue->rekey_left_bytes) || | 2143 | ((0 == queue->rekey_left_bytes) || |
2009 | (0 == | 2144 | (0 == |
2010 | GNUNET_TIME_absolute_get_remaining (queue->rekey_time).rel_value_us))) | 2145 | GNUNET_TIME_absolute_get_remaining ( |
2146 | queue->rekey_time).rel_value_us)))) | ||
2011 | { | 2147 | { |
2012 | inject_rekey (queue); | 2148 | inject_rekey (queue); |
2013 | } | 2149 | } |
@@ -2403,11 +2539,6 @@ decrypt_and_check_tc (struct Queue *queue, | |||
2403 | static void | 2539 | static void |
2404 | free_proto_queue (struct ProtoQueue *pq) | 2540 | free_proto_queue (struct ProtoQueue *pq) |
2405 | { | 2541 | { |
2406 | if (NULL != pq->listen_task) | ||
2407 | { | ||
2408 | GNUNET_SCHEDULER_cancel (pq->listen_task); | ||
2409 | pq->listen_task = NULL; | ||
2410 | } | ||
2411 | if (NULL != pq->listen_sock) | 2542 | if (NULL != pq->listen_sock) |
2412 | { | 2543 | { |
2413 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock)); | 2544 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock)); |
@@ -2526,7 +2657,6 @@ proto_read_kx (void *cls) | |||
2526 | queue->address = pq->address; /* steals reference */ | 2657 | queue->address = pq->address; /* steals reference */ |
2527 | queue->address_len = pq->address_len; | 2658 | queue->address_len = pq->address_len; |
2528 | queue->target = tc.sender; | 2659 | queue->target = tc.sender; |
2529 | queue->listen_task = pq->listen_task; | ||
2530 | queue->listen_sock = pq->listen_sock; | 2660 | queue->listen_sock = pq->listen_sock; |
2531 | queue->sock = pq->sock; | 2661 | queue->sock = pq->sock; |
2532 | 2662 | ||
@@ -2569,6 +2699,9 @@ listen_cb (void *cls) | |||
2569 | struct ProtoQueue *pq; | 2699 | struct ProtoQueue *pq; |
2570 | struct ListenTask *lt; | 2700 | struct ListenTask *lt; |
2571 | 2701 | ||
2702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2703 | "listen_cb\n"); | ||
2704 | |||
2572 | lt = cls; | 2705 | lt = cls; |
2573 | 2706 | ||
2574 | lt->listen_task = NULL; | 2707 | lt->listen_task = NULL; |
@@ -2707,7 +2840,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2707 | struct Queue *queue; | 2840 | struct Queue *queue; |
2708 | const char *path; | 2841 | const char *path; |
2709 | struct sockaddr *in; | 2842 | struct sockaddr *in; |
2710 | socklen_t in_len; | 2843 | socklen_t in_len = 0; |
2711 | struct GNUNET_NETWORK_Handle *sock; | 2844 | struct GNUNET_NETWORK_Handle *sock; |
2712 | 2845 | ||
2713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2729,6 +2862,10 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2729 | return GNUNET_SYSERR; | 2862 | return GNUNET_SYSERR; |
2730 | } | 2863 | } |
2731 | 2864 | ||
2865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2866 | "in %s\n", | ||
2867 | GNUNET_a2s (in, in_len)); | ||
2868 | |||
2732 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); | 2869 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); |
2733 | if (NULL == sock) | 2870 | if (NULL == sock) |
2734 | { | 2871 | { |
@@ -2778,6 +2915,36 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2778 | } | 2915 | } |
2779 | 2916 | ||
2780 | /** | 2917 | /** |
2918 | * Iterator over all ListenTasks to clean up. | ||
2919 | * | ||
2920 | * @param cls NULL | ||
2921 | * @param key unused | ||
2922 | * @param value the ListenTask to cancel. | ||
2923 | * @return #GNUNET_OK to continue to iterate | ||
2924 | */ | ||
2925 | static int | ||
2926 | get_lt_delete_it (void *cls, | ||
2927 | const struct GNUNET_HashCode *key, | ||
2928 | void *value) | ||
2929 | { | ||
2930 | struct ListenTask *lt = value; | ||
2931 | |||
2932 | (void) cls; | ||
2933 | (void) key; | ||
2934 | if (NULL != lt->listen_task) | ||
2935 | { | ||
2936 | GNUNET_SCHEDULER_cancel (lt->listen_task); | ||
2937 | lt->listen_task = NULL; | ||
2938 | } | ||
2939 | if (NULL != lt->listen_sock) | ||
2940 | { | ||
2941 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (lt->listen_sock)); | ||
2942 | lt->listen_sock = NULL; | ||
2943 | } | ||
2944 | return GNUNET_OK; | ||
2945 | } | ||
2946 | |||
2947 | /** | ||
2781 | * Iterator over all message queues to clean up. | 2948 | * Iterator over all message queues to clean up. |
2782 | * | 2949 | * |
2783 | * @param cls NULL | 2950 | * @param cls NULL |
@@ -2798,7 +2965,6 @@ get_queue_delete_it (void *cls, | |||
2798 | return GNUNET_OK; | 2965 | return GNUNET_OK; |
2799 | } | 2966 | } |
2800 | 2967 | ||
2801 | |||
2802 | /** | 2968 | /** |
2803 | * Shutdown the UNIX communicator. | 2969 | * Shutdown the UNIX communicator. |
2804 | * | 2970 | * |
@@ -2807,6 +2973,15 @@ get_queue_delete_it (void *cls, | |||
2807 | static void | 2973 | static void |
2808 | do_shutdown (void *cls) | 2974 | do_shutdown (void *cls) |
2809 | { | 2975 | { |
2976 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2977 | "Shutdown %s!\n", | ||
2978 | shutdown_running ? "running" : "not running"); | ||
2979 | |||
2980 | if (GNUNET_YES == shutdown_running) | ||
2981 | return; | ||
2982 | else | ||
2983 | shutdown_running = GNUNET_YES; | ||
2984 | |||
2810 | while (NULL != proto_head) | 2985 | while (NULL != proto_head) |
2811 | free_proto_queue (proto_head); | 2986 | free_proto_queue (proto_head); |
2812 | if (NULL != nat) | 2987 | if (NULL != nat) |
@@ -2814,8 +2989,10 @@ do_shutdown (void *cls) | |||
2814 | GNUNET_NAT_unregister (nat); | 2989 | GNUNET_NAT_unregister (nat); |
2815 | nat = NULL; | 2990 | nat = NULL; |
2816 | } | 2991 | } |
2992 | GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL); | ||
2817 | GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); | 2993 | GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); |
2818 | GNUNET_CONTAINER_multipeermap_destroy (queue_map); | 2994 | GNUNET_CONTAINER_multipeermap_destroy (queue_map); |
2995 | GNUNET_TRANSPORT_communicator_address_remove_all (ch); | ||
2819 | if (NULL != ch) | 2996 | if (NULL != ch) |
2820 | { | 2997 | { |
2821 | GNUNET_TRANSPORT_communicator_disconnect (ch); | 2998 | GNUNET_TRANSPORT_communicator_disconnect (ch); |
@@ -2836,6 +3013,18 @@ do_shutdown (void *cls) | |||
2836 | GNUNET_NT_scanner_done (is); | 3013 | GNUNET_NT_scanner_done (is); |
2837 | is = NULL; | 3014 | is = NULL; |
2838 | } | 3015 | } |
3016 | if (NULL != peerstore) | ||
3017 | { | ||
3018 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); | ||
3019 | peerstore = NULL; | ||
3020 | } | ||
3021 | if (NULL != resolve_request_handle) | ||
3022 | { | ||
3023 | GNUNET_RESOLVER_request_cancel (resolve_request_handle); | ||
3024 | resolve_request_handle = NULL; | ||
3025 | } | ||
3026 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3027 | "Shutdown done!\n"); | ||
2839 | } | 3028 | } |
2840 | 3029 | ||
2841 | 3030 | ||
@@ -2886,6 +3075,11 @@ nat_address_cb (void *cls, | |||
2886 | char *my_addr; | 3075 | char *my_addr; |
2887 | struct GNUNET_TRANSPORT_AddressIdentifier *ai; | 3076 | struct GNUNET_TRANSPORT_AddressIdentifier *ai; |
2888 | 3077 | ||
3078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3079 | "nat address cb %s %s\n", | ||
3080 | add_remove ? "add" : "remove", | ||
3081 | GNUNET_a2s (addr, addrlen)); | ||
3082 | |||
2889 | if (GNUNET_YES == add_remove) | 3083 | if (GNUNET_YES == add_remove) |
2890 | { | 3084 | { |
2891 | enum GNUNET_NetworkType nt; | 3085 | enum GNUNET_NetworkType nt; |
@@ -2912,6 +3106,35 @@ nat_address_cb (void *cls, | |||
2912 | } | 3106 | } |
2913 | 3107 | ||
2914 | /** | 3108 | /** |
3109 | * This method adds addresses to the DLL, that are later register at the NAT service. | ||
3110 | */ | ||
3111 | static void | ||
3112 | add_addr (struct sockaddr *in, socklen_t in_len) | ||
3113 | { | ||
3114 | |||
3115 | struct Addresses *saddrs; | ||
3116 | |||
3117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3118 | "add address %s\n", | ||
3119 | GNUNET_a2s (in, in_len)); | ||
3120 | |||
3121 | saddrs = GNUNET_new (struct Addresses); | ||
3122 | saddrs->addr = in; | ||
3123 | saddrs->addr_len = in_len; | ||
3124 | GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); | ||
3125 | |||
3126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3127 | "after add address %s\n", | ||
3128 | GNUNET_a2s (in, in_len)); | ||
3129 | |||
3130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3131 | "add address %s\n", | ||
3132 | GNUNET_a2s (saddrs->addr, saddrs->addr_len)); | ||
3133 | |||
3134 | addrs_lens++; | ||
3135 | } | ||
3136 | |||
3137 | /** | ||
2915 | * This method launch network interactions for each address we like to bind to. | 3138 | * This method launch network interactions for each address we like to bind to. |
2916 | * | 3139 | * |
2917 | * @param addr The address we will listen to. | 3140 | * @param addr The address we will listen to. |
@@ -2919,13 +3142,14 @@ nat_address_cb (void *cls, | |||
2919 | * @return GNUNET_SYSERR in case of error. GNUNET_OK in case we are successfully listen to the address. | 3142 | * @return GNUNET_SYSERR in case of error. GNUNET_OK in case we are successfully listen to the address. |
2920 | */ | 3143 | */ |
2921 | static int | 3144 | static int |
2922 | init_socket (const struct sockaddr *addr, | 3145 | init_socket (struct sockaddr *addr, |
2923 | socklen_t in_len) | 3146 | socklen_t in_len) |
2924 | { | 3147 | { |
2925 | struct sockaddr_storage in_sto; | 3148 | struct sockaddr_storage in_sto; |
2926 | socklen_t sto_len; | 3149 | socklen_t sto_len; |
2927 | struct GNUNET_NETWORK_Handle *listen_sock; | 3150 | struct GNUNET_NETWORK_Handle *listen_sock; |
2928 | struct ListenTask *lt; | 3151 | struct ListenTask *lt; |
3152 | struct GNUNET_HashCode h_sock; | ||
2929 | 3153 | ||
2930 | if (NULL == addr) | 3154 | if (NULL == addr) |
2931 | { | 3155 | { |
@@ -2977,13 +3201,12 @@ init_socket (const struct sockaddr *addr, | |||
2977 | sto_len = in_len; | 3201 | sto_len = in_len; |
2978 | } | 3202 | } |
2979 | 3203 | ||
2980 | addr = (struct sockaddr *) &in_sto; | 3204 | // addr = (struct sockaddr *) &in_sto; |
2981 | in_len = sto_len; | 3205 | in_len = sto_len; |
2982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2983 | "Bound to `%s'\n", | 3207 | "Bound to `%s'\n", |
2984 | GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); | 3208 | GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); |
2985 | stats = GNUNET_STATISTICS_create ("C-TCP", cfg); | 3209 | stats = GNUNET_STATISTICS_create ("C-TCP", cfg); |
2986 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
2987 | 3210 | ||
2988 | if (NULL == is) | 3211 | if (NULL == is) |
2989 | is = GNUNET_NT_scanner_init (); | 3212 | is = GNUNET_NT_scanner_init (); |
@@ -3012,6 +3235,27 @@ init_socket (const struct sockaddr *addr, | |||
3012 | &listen_cb, | 3235 | &listen_cb, |
3013 | lt); | 3236 | lt); |
3014 | 3237 | ||
3238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3239 | "creating hash\n"); | ||
3240 | GNUNET_CRYPTO_hash (lt->listen_sock, | ||
3241 | sizeof(lt->listen_sock), | ||
3242 | &h_sock); | ||
3243 | |||
3244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3245 | "creating map\n"); | ||
3246 | if (NULL == lt_map) | ||
3247 | lt_map = GNUNET_CONTAINER_multihashmap_create (2, GNUNET_NO); | ||
3248 | |||
3249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3250 | "creating map entry\n"); | ||
3251 | GNUNET_CONTAINER_multihashmap_put (lt_map, | ||
3252 | &h_sock, | ||
3253 | lt, | ||
3254 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
3255 | |||
3256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3257 | "map entry created\n"); | ||
3258 | |||
3015 | if (NULL == queue_map) | 3259 | if (NULL == queue_map) |
3016 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 3260 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
3017 | 3261 | ||
@@ -3034,6 +3278,7 @@ init_socket (const struct sockaddr *addr, | |||
3034 | return GNUNET_SYSERR; | 3278 | return GNUNET_SYSERR; |
3035 | } | 3279 | } |
3036 | 3280 | ||
3281 | add_addr (addr, in_len); | ||
3037 | return GNUNET_OK; | 3282 | return GNUNET_OK; |
3038 | 3283 | ||
3039 | } | 3284 | } |
@@ -3050,6 +3295,10 @@ nat_register () | |||
3050 | int i; | 3295 | int i; |
3051 | struct Addresses *pos; | 3296 | struct Addresses *pos; |
3052 | 3297 | ||
3298 | |||
3299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3300 | "starting nat register!\n"); | ||
3301 | |||
3053 | i = 0; | 3302 | i = 0; |
3054 | saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); | 3303 | saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); |
3055 | 3304 | ||
@@ -3058,9 +3307,12 @@ nat_register () | |||
3058 | for (pos = addrs_head; NULL != pos; pos = pos->next) | 3307 | for (pos = addrs_head; NULL != pos; pos = pos->next) |
3059 | { | 3308 | { |
3060 | 3309 | ||
3310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3311 | "registering address %s\n", | ||
3312 | GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); | ||
3313 | |||
3061 | saddr_lens[i] = addrs_head->addr_len; | 3314 | saddr_lens[i] = addrs_head->addr_len; |
3062 | saddrs[i] = GNUNET_malloc (saddr_lens[i]); | 3315 | saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); |
3063 | saddrs[i] = addrs_head->addr; | ||
3064 | 3316 | ||
3065 | i++; | 3317 | i++; |
3066 | 3318 | ||
@@ -3078,8 +3330,8 @@ nat_register () | |||
3078 | 3330 | ||
3079 | i = 0; | 3331 | i = 0; |
3080 | 3332 | ||
3081 | /*for (i = addrs_lens - 1; i >= 0; i--) | 3333 | for (i = addrs_lens - 1; i >= 0; i--) |
3082 | GNUNET_free (saddrs[i]);*/ | 3334 | GNUNET_free (saddrs[i]); |
3083 | GNUNET_free (saddrs); | 3335 | GNUNET_free (saddrs); |
3084 | GNUNET_free (saddr_lens); | 3336 | GNUNET_free (saddr_lens); |
3085 | 3337 | ||
@@ -3093,22 +3345,6 @@ nat_register () | |||
3093 | } | 3345 | } |
3094 | 3346 | ||
3095 | /** | 3347 | /** |
3096 | * This method adds addresses to the DLL, that are later register at the NAT service. | ||
3097 | */ | ||
3098 | static void | ||
3099 | add_addr (struct sockaddr *in, socklen_t in_len) | ||
3100 | { | ||
3101 | |||
3102 | struct Addresses *saddrs; | ||
3103 | |||
3104 | saddrs = GNUNET_new (struct Addresses); | ||
3105 | saddrs->addr = in; | ||
3106 | saddrs->addr_len = in_len; | ||
3107 | GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); | ||
3108 | addrs_lens++; | ||
3109 | } | ||
3110 | |||
3111 | /** | ||
3112 | * This method is the callback called by the resolver API, and wraps method init_socket. | 3348 | * This method is the callback called by the resolver API, and wraps method init_socket. |
3113 | * | 3349 | * |
3114 | * @param cls The port we will bind to. | 3350 | * @param cls The port we will bind to. |
@@ -3123,22 +3359,19 @@ init_socket_resolv (void *cls, | |||
3123 | struct sockaddr_in *v4; | 3359 | struct sockaddr_in *v4; |
3124 | struct sockaddr_in6 *v6; | 3360 | struct sockaddr_in6 *v6; |
3125 | struct sockaddr *in; | 3361 | struct sockaddr *in; |
3126 | unsigned int *port; | ||
3127 | 3362 | ||
3128 | port = cls; | 3363 | (void) cls; |
3129 | if (NULL != addr) | 3364 | if (NULL != addr) |
3130 | { | 3365 | { |
3131 | if (AF_INET == addr->sa_family) | 3366 | if (AF_INET == addr->sa_family) |
3132 | { | 3367 | { |
3133 | v4 = (struct sockaddr_in *) addr; | 3368 | v4 = (struct sockaddr_in *) addr; |
3134 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, *port);// _global); | 3369 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, bind_port);// _global); |
3135 | add_addr (in, in_len); | ||
3136 | } | 3370 | } |
3137 | else if (AF_INET6 == addr->sa_family) | 3371 | else if (AF_INET6 == addr->sa_family) |
3138 | { | 3372 | { |
3139 | v6 = (struct sockaddr_in6 *) addr; | 3373 | v6 = (struct sockaddr_in6 *) addr; |
3140 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, *port);// _global); | 3374 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, bind_port);// _global); |
3141 | add_addr (in, in_len); | ||
3142 | } | 3375 | } |
3143 | else | 3376 | else |
3144 | { | 3377 | { |
@@ -3149,14 +3382,20 @@ init_socket_resolv (void *cls, | |||
3149 | AF_INET6); | 3382 | AF_INET6); |
3150 | return; | 3383 | return; |
3151 | } | 3384 | } |
3152 | init_socket (in, | 3385 | init_socket (in, in_len); |
3153 | in_len); | ||
3154 | } | 3386 | } |
3155 | else | 3387 | else |
3156 | { | 3388 | { |
3157 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3389 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3158 | "Address is NULL. This might be an error or the resolver finished resolving.\n"); | 3390 | "Address is NULL. This might be an error or the resolver finished resolving.\n"); |
3391 | if (NULL == addrs_head) | ||
3392 | { | ||
3393 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3394 | "Resolver finished resolving, but we do not listen to an address!.\n"); | ||
3395 | return; | ||
3396 | } | ||
3159 | nat_register (); | 3397 | nat_register (); |
3398 | |||
3160 | } | 3399 | } |
3161 | } | 3400 | } |
3162 | 3401 | ||
@@ -3221,12 +3460,11 @@ run (void *cls, | |||
3221 | return; | 3460 | return; |
3222 | } | 3461 | } |
3223 | 3462 | ||
3224 | // cp = GNUNET_strdup (bindto); | 3463 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
3225 | start = extract_address (bindto); | ||
3226 | 3464 | ||
3227 | if (1 == sscanf (bindto, "%u%1s", &port, dummy)) | 3465 | if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy)) |
3228 | { | 3466 | { |
3229 | po = tcp_address_to_sockaddr_port_only (bindto, &port); | 3467 | po = tcp_address_to_sockaddr_port_only (bindto, &bind_port); |
3230 | 3468 | ||
3231 | addr_len_ipv4 = po->addr_len_ipv4; | 3469 | addr_len_ipv4 = po->addr_len_ipv4; |
3232 | 3470 | ||
@@ -3238,46 +3476,55 @@ run (void *cls, | |||
3238 | if (NULL != po->addr_ipv4) | 3476 | if (NULL != po->addr_ipv4) |
3239 | { | 3477 | { |
3240 | init_socket (po->addr_ipv4, addr_len_ipv4); | 3478 | init_socket (po->addr_ipv4, addr_len_ipv4); |
3241 | add_addr (po->addr_ipv4, addr_len_ipv4); | ||
3242 | } | 3479 | } |
3243 | 3480 | ||
3244 | if (NULL != po->addr_ipv6) | 3481 | if (NULL != po->addr_ipv6) |
3245 | { | 3482 | { |
3246 | addr_len_ipv6 = po->addr_len_ipv6; | 3483 | addr_len_ipv6 = po->addr_len_ipv6; |
3247 | init_socket (po->addr_ipv6, addr_len_ipv6); | 3484 | init_socket (po->addr_ipv6, addr_len_ipv6); |
3248 | add_addr (po->addr_ipv6, addr_len_ipv6); | ||
3249 | } | 3485 | } |
3250 | 3486 | ||
3487 | GNUNET_free (po); | ||
3251 | nat_register (); | 3488 | nat_register (); |
3489 | GNUNET_free (bindto); | ||
3490 | |||
3491 | return; | ||
3252 | } | 3492 | } |
3253 | else if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | 3493 | |
3494 | start = extract_address (bindto); | ||
3495 | |||
3496 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | ||
3254 | { | 3497 | { |
3255 | port = extract_port (bindto); | 3498 | bind_port = extract_port (bindto); |
3256 | 3499 | ||
3257 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, port); | 3500 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); |
3258 | init_socket (in, in_len); | 3501 | init_socket (in, in_len); |
3259 | add_addr (in, in_len); | ||
3260 | nat_register (); | 3502 | nat_register (); |
3503 | GNUNET_free (bindto); | ||
3504 | |||
3505 | return; | ||
3261 | } | 3506 | } |
3262 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | 3507 | |
3508 | if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | ||
3263 | { | 3509 | { |
3264 | port = extract_port (bindto); | 3510 | bind_port = extract_port (bindto); |
3265 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, port); | 3511 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); |
3266 | init_socket (in, in_len); | 3512 | init_socket (in, in_len); |
3267 | add_addr (in, in_len); | ||
3268 | nat_register (); | 3513 | nat_register (); |
3269 | } | 3514 | GNUNET_free (bindto); |
3270 | else | ||
3271 | { | ||
3272 | port = extract_port (bindto); | ||
3273 | 3515 | ||
3274 | resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", | 3516 | return; |
3275 | &rest), | ||
3276 | AF_UNSPEC, | ||
3277 | GNUNET_TIME_UNIT_MINUTES, | ||
3278 | &init_socket_resolv, | ||
3279 | &port); | ||
3280 | } | 3517 | } |
3518 | |||
3519 | |||
3520 | bind_port = extract_port (bindto); | ||
3521 | |||
3522 | resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", | ||
3523 | &rest), | ||
3524 | AF_UNSPEC, | ||
3525 | GNUNET_TIME_UNIT_MINUTES, | ||
3526 | &init_socket_resolv, | ||
3527 | &port); | ||
3281 | GNUNET_free (bindto); | 3528 | GNUNET_free (bindto); |
3282 | } | 3529 | } |
3283 | 3530 | ||
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index e2d2eb73c..aa02bda93 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -124,6 +124,25 @@ communicator_available_cb (void *cls, | |||
124 | address_prefix); | 124 | address_prefix); |
125 | } | 125 | } |
126 | 126 | ||
127 | static void | ||
128 | open_queue (void *cls) | ||
129 | { | ||
130 | char *address = cls; | ||
131 | |||
132 | if (NULL != tc_hs[PEER_A]->c_mq) | ||
133 | { | ||
134 | queue_est = GNUNET_YES; | ||
135 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A], | ||
136 | &peer_id[PEER_B], | ||
137 | address); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
142 | &open_queue, | ||
143 | address); | ||
144 | } | ||
145 | } | ||
127 | 146 | ||
128 | static void | 147 | static void |
129 | add_address_cb (void *cls, | 148 | add_address_cb (void *cls, |
@@ -144,10 +163,7 @@ add_address_cb (void *cls, | |||
144 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && | 163 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && |
145 | (GNUNET_NO == queue_est)) | 164 | (GNUNET_NO == queue_est)) |
146 | { | 165 | { |
147 | queue_est = GNUNET_YES; | 166 | open_queue (address); |
148 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A], | ||
149 | &peer_id[PEER_B], | ||
150 | address); | ||
151 | } | 167 | } |
152 | } | 168 | } |
153 | 169 | ||
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf index 138650a3b..643b037b2 100644 --- a/src/transport/test_communicator_tcp_rekey_peer2.conf +++ b/src/transport/test_communicator_tcp_rekey_peer2.conf | |||
@@ -31,10 +31,10 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | |||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock | 31 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock |
32 | 32 | ||
33 | [communicator-tcp] | 33 | [communicator-tcp] |
34 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | 34 | #PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args |
35 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 35 | #PREFIX = valgrind --leak-check=full --track-origins=yes |
36 | BINDTO = 60003 | 36 | BINDTO = 60003 |
37 | DISABLE_V6 = YES | 37 | DISABLE_V6 = NO |
38 | REKEY_INTERVAL = 100ms | 38 | REKEY_INTERVAL = 100ms |
39 | 39 | ||
40 | [communicator-udp] | 40 | [communicator-udp] |
diff --git a/src/transport/test_communicator_unix_basic_peer1.conf b/src/transport/test_communicator_unix_basic_peer1.conf index 71283e381..8e9700108 100644 --- a/src/transport/test_communicator_unix_basic_peer1.conf +++ b/src/transport/test_communicator_unix_basic_peer1.conf | |||
@@ -28,6 +28,8 @@ PORT = 62089 | |||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock | 28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock |
29 | 29 | ||
30 | [communicator-unix] | 30 | [communicator-unix] |
31 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | ||
32 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock | 33 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock |
32 | 34 | ||
33 | [communicator-tcp] | 35 | [communicator-tcp] |
diff --git a/src/transport/test_communicator_unix_basic_peer2.conf b/src/transport/test_communicator_unix_basic_peer2.conf index ac95845b2..c12cc9111 100644 --- a/src/transport/test_communicator_unix_basic_peer2.conf +++ b/src/transport/test_communicator_unix_basic_peer2.conf | |||
@@ -28,6 +28,8 @@ PORT = 62090 | |||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | 28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock |
29 | 29 | ||
30 | [communicator-unix] | 30 | [communicator-unix] |
31 | #PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args | ||
32 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock | 33 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock |
32 | 34 | ||
33 | [communicator-tcp] | 35 | [communicator-tcp] |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 13944e9f0..98cfd5e29 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -59,145 +59,6 @@ struct MyClient | |||
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * @brief Handle to a transport communicator | ||
63 | */ | ||
64 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | ||
65 | { | ||
66 | /** | ||
67 | * Clients | ||
68 | */ | ||
69 | struct MyClient *client_head; | ||
70 | struct MyClient *client_tail; | ||
71 | |||
72 | /** | ||
73 | * @brief Handle to the client | ||
74 | */ | ||
75 | struct GNUNET_MQ_Handle *c_mq; | ||
76 | |||
77 | /** | ||
78 | * @brief Handle to the configuration | ||
79 | */ | ||
80 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
81 | |||
82 | /** | ||
83 | * @brief File name of configuration file | ||
84 | */ | ||
85 | char *cfg_filename; | ||
86 | |||
87 | struct GNUNET_PeerIdentity peer_id; | ||
88 | |||
89 | /** | ||
90 | * @brief Handle to the transport service | ||
91 | */ | ||
92 | struct GNUNET_SERVICE_Handle *tsh; | ||
93 | |||
94 | /** | ||
95 | * @brief Task that will be run on shutdown to stop and clean transport | ||
96 | * service | ||
97 | */ | ||
98 | struct GNUNET_SCHEDULER_Task *ts_shutdown_task; | ||
99 | |||
100 | |||
101 | /** | ||
102 | * @brief Process of the communicator | ||
103 | */ | ||
104 | struct GNUNET_OS_Process *c_proc; | ||
105 | |||
106 | /** | ||
107 | * NAT process | ||
108 | */ | ||
109 | struct GNUNET_OS_Process *nat_proc; | ||
110 | |||
111 | /** | ||
112 | * resolver service process | ||
113 | */ | ||
114 | struct GNUNET_OS_Process *resolver_proc; | ||
115 | |||
116 | /** | ||
117 | * peerstore service process | ||
118 | */ | ||
119 | struct GNUNET_OS_Process *ps_proc; | ||
120 | |||
121 | /** | ||
122 | * @brief Task that will be run on shutdown to stop and clean communicator | ||
123 | */ | ||
124 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; | ||
125 | |||
126 | /** | ||
127 | * @brief Characteristics of the communicator | ||
128 | */ | ||
129 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics; | ||
130 | |||
131 | /** | ||
132 | * @brief Specifies supported addresses | ||
133 | */ | ||
134 | char *c_addr_prefix; | ||
135 | |||
136 | /** | ||
137 | * @brief Specifies supported addresses | ||
138 | */ | ||
139 | char *c_address; | ||
140 | |||
141 | /** | ||
142 | * @brief Head of the DLL of queues associated with this communicator | ||
143 | */ | ||
144 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head; | ||
145 | |||
146 | /** | ||
147 | * @brief Tail of the DLL of queues associated with this communicator | ||
148 | */ | ||
149 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail; | ||
150 | |||
151 | /* Callbacks + Closures */ | ||
152 | /** | ||
153 | * @brief Callback called when a new communicator connects | ||
154 | */ | ||
155 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback | ||
156 | communicator_available_cb; | ||
157 | |||
158 | /** | ||
159 | * @brief Callback called when a new communicator connects | ||
160 | */ | ||
161 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb; | ||
162 | |||
163 | /** | ||
164 | * @brief Callback called when a new communicator connects | ||
165 | */ | ||
166 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb; | ||
167 | |||
168 | /** | ||
169 | * @brief Callback called when a new communicator connects | ||
170 | */ | ||
171 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb; | ||
172 | |||
173 | /** | ||
174 | * @brief Callback called when a new communicator connects | ||
175 | */ | ||
176 | GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb; | ||
177 | |||
178 | /** | ||
179 | * @brief Backchannel callback | ||
180 | */ | ||
181 | GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb; | ||
182 | |||
183 | /** | ||
184 | * Our service handle | ||
185 | */ | ||
186 | struct GNUNET_SERVICE_Handle *sh; | ||
187 | |||
188 | /** | ||
189 | * @brief Closure to the callback | ||
190 | */ | ||
191 | void *cb_cls; | ||
192 | |||
193 | /** | ||
194 | * Backchannel supported | ||
195 | */ | ||
196 | int bc_enabled; | ||
197 | }; | ||
198 | |||
199 | |||
200 | /** | ||
201 | * @brief Queue of a communicator and some context | 62 | * @brief Queue of a communicator and some context |
202 | */ | 63 | */ |
203 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue | 64 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue |
@@ -707,6 +568,9 @@ shutdown_service (void *cls) | |||
707 | { | 568 | { |
708 | struct GNUNET_SERVICE_Handle *h = cls; | 569 | struct GNUNET_SERVICE_Handle *h = cls; |
709 | 570 | ||
571 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
572 | "Shutting down service!\n"); | ||
573 | |||
710 | GNUNET_SERVICE_stop (h); | 574 | GNUNET_SERVICE_stop (h); |
711 | } | 575 | } |
712 | 576 | ||
@@ -897,7 +761,6 @@ shutdown_process (struct GNUNET_OS_Process *proc) | |||
897 | GNUNET_OS_process_destroy (proc); | 761 | GNUNET_OS_process_destroy (proc); |
898 | } | 762 | } |
899 | 763 | ||
900 | |||
901 | static void | 764 | static void |
902 | shutdown_peerstore (void *cls) | 765 | shutdown_peerstore (void *cls) |
903 | { | 766 | { |
@@ -905,7 +768,6 @@ shutdown_peerstore (void *cls) | |||
905 | shutdown_process (proc); | 768 | shutdown_process (proc); |
906 | } | 769 | } |
907 | 770 | ||
908 | |||
909 | static void | 771 | static void |
910 | shutdown_communicator (void *cls) | 772 | shutdown_communicator (void *cls) |
911 | { | 773 | { |
@@ -941,8 +803,7 @@ communicator_start ( | |||
941 | 803 | ||
942 | 804 | ||
943 | binary = GNUNET_OS_get_libexec_binary_path (binary_name); | 805 | binary = GNUNET_OS_get_libexec_binary_path (binary_name); |
944 | tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_USE_PIPE_CONTROL | 806 | tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
945 | | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
946 | NULL, | 807 | NULL, |
947 | loprefix, | 808 | loprefix, |
948 | binary, | 809 | binary, |
@@ -1026,10 +887,8 @@ peerstore_start ( | |||
1026 | { | 887 | { |
1027 | char *binary; | 888 | char *binary; |
1028 | 889 | ||
1029 | LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n"); | ||
1030 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore"); | 890 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore"); |
1031 | tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_USE_PIPE_CONTROL | 891 | tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
1032 | | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
1033 | NULL, | 892 | NULL, |
1034 | NULL, | 893 | NULL, |
1035 | NULL, | 894 | NULL, |
@@ -1047,7 +906,6 @@ peerstore_start ( | |||
1047 | GNUNET_free (binary); | 906 | GNUNET_free (binary); |
1048 | } | 907 | } |
1049 | 908 | ||
1050 | |||
1051 | /** | 909 | /** |
1052 | * @brief Start NAT | 910 | * @brief Start NAT |
1053 | * | 911 | * |
@@ -1208,6 +1066,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( | |||
1208 | memcpy (&msg[1], address, alen); | 1066 | memcpy (&msg[1], address, alen); |
1209 | if (NULL != tc_h->c_mq) | 1067 | if (NULL != tc_h->c_mq) |
1210 | { | 1068 | { |
1069 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1070 | "Sending queue create immediately\n"); | ||
1211 | GNUNET_MQ_send (tc_h->c_mq, env); | 1071 | GNUNET_MQ_send (tc_h->c_mq, env); |
1212 | } | 1072 | } |
1213 | else | 1073 | else |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index b77125e82..04f75fc88 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -29,13 +29,6 @@ | |||
29 | #include "gnunet_ats_transport_service.h" | 29 | #include "gnunet_ats_transport_service.h" |
30 | #include "transport.h" | 30 | #include "transport.h" |
31 | 31 | ||
32 | |||
33 | /** | ||
34 | * @brief Handle to a transport communicator | ||
35 | */ | ||
36 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle; | ||
37 | |||
38 | |||
39 | /** | 32 | /** |
40 | * @brief Queue of a communicator and some context | 33 | * @brief Queue of a communicator and some context |
41 | */ | 34 | */ |
@@ -151,6 +144,143 @@ typedef void | |||
151 | const char*payload, | 144 | const char*payload, |
152 | size_t payload_len); | 145 | size_t payload_len); |
153 | 146 | ||
147 | /** | ||
148 | * @brief Handle to a transport communicator | ||
149 | */ | ||
150 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | ||
151 | { | ||
152 | /** | ||
153 | * Clients | ||
154 | */ | ||
155 | struct MyClient *client_head; | ||
156 | struct MyClient *client_tail; | ||
157 | |||
158 | /** | ||
159 | * @brief Handle to the client | ||
160 | */ | ||
161 | struct GNUNET_MQ_Handle *c_mq; | ||
162 | |||
163 | /** | ||
164 | * @brief Handle to the configuration | ||
165 | */ | ||
166 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
167 | |||
168 | /** | ||
169 | * @brief File name of configuration file | ||
170 | */ | ||
171 | char *cfg_filename; | ||
172 | |||
173 | struct GNUNET_PeerIdentity peer_id; | ||
174 | |||
175 | /** | ||
176 | * @brief Handle to the transport service | ||
177 | */ | ||
178 | struct GNUNET_SERVICE_Handle *tsh; | ||
179 | |||
180 | /** | ||
181 | * @brief Task that will be run on shutdown to stop and clean transport | ||
182 | * service | ||
183 | */ | ||
184 | struct GNUNET_SCHEDULER_Task *ts_shutdown_task; | ||
185 | |||
186 | |||
187 | /** | ||
188 | * @brief Process of the communicator | ||
189 | */ | ||
190 | struct GNUNET_OS_Process *c_proc; | ||
191 | |||
192 | /** | ||
193 | * NAT process | ||
194 | */ | ||
195 | struct GNUNET_OS_Process *nat_proc; | ||
196 | |||
197 | /** | ||
198 | * resolver service process | ||
199 | */ | ||
200 | struct GNUNET_OS_Process *resolver_proc; | ||
201 | |||
202 | /** | ||
203 | * peerstore service process | ||
204 | */ | ||
205 | struct GNUNET_OS_Process *ps_proc; | ||
206 | |||
207 | /** | ||
208 | * @brief Task that will be run on shutdown to stop and clean communicator | ||
209 | */ | ||
210 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; | ||
211 | |||
212 | /** | ||
213 | * @brief Characteristics of the communicator | ||
214 | */ | ||
215 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics; | ||
216 | |||
217 | /** | ||
218 | * @brief Specifies supported addresses | ||
219 | */ | ||
220 | char *c_addr_prefix; | ||
221 | |||
222 | /** | ||
223 | * @brief Specifies supported addresses | ||
224 | */ | ||
225 | char *c_address; | ||
226 | |||
227 | /** | ||
228 | * @brief Head of the DLL of queues associated with this communicator | ||
229 | */ | ||
230 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head; | ||
231 | |||
232 | /** | ||
233 | * @brief Tail of the DLL of queues associated with this communicator | ||
234 | */ | ||
235 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail; | ||
236 | |||
237 | /* Callbacks + Closures */ | ||
238 | /** | ||
239 | * @brief Callback called when a new communicator connects | ||
240 | */ | ||
241 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback | ||
242 | communicator_available_cb; | ||
243 | |||
244 | /** | ||
245 | * @brief Callback called when a new communicator connects | ||
246 | */ | ||
247 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb; | ||
248 | |||
249 | /** | ||
250 | * @brief Callback called when a new communicator connects | ||
251 | */ | ||
252 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb; | ||
253 | |||
254 | /** | ||
255 | * @brief Callback called when a new communicator connects | ||
256 | */ | ||
257 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb; | ||
258 | |||
259 | /** | ||
260 | * @brief Callback called when a new communicator connects | ||
261 | */ | ||
262 | GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb; | ||
263 | |||
264 | /** | ||
265 | * @brief Backchannel callback | ||
266 | */ | ||
267 | GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb; | ||
268 | |||
269 | /** | ||
270 | * Our service handle | ||
271 | */ | ||
272 | struct GNUNET_SERVICE_Handle *sh; | ||
273 | |||
274 | /** | ||
275 | * @brief Closure to the callback | ||
276 | */ | ||
277 | void *cb_cls; | ||
278 | |||
279 | /** | ||
280 | * Backchannel supported | ||
281 | */ | ||
282 | int bc_enabled; | ||
283 | }; | ||
154 | 284 | ||
155 | /** | 285 | /** |
156 | * @brief Start communicator part of transport service and communicator | 286 | * @brief Start communicator part of transport service and communicator |
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index d1e28cc36..b048ad851 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -1081,7 +1081,6 @@ GNUNET_TRANSPORT_communicator_address_add ( | |||
1081 | return ai; | 1081 | return ai; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | |||
1085 | /** | 1084 | /** |
1086 | * Notify transport service about an address that this communicator no | 1085 | * Notify transport service about an address that this communicator no |
1087 | * longer provides for this peer. | 1086 | * longer provides for this peer. |
@@ -1100,6 +1099,20 @@ GNUNET_TRANSPORT_communicator_address_remove ( | |||
1100 | GNUNET_free (ai); | 1099 | GNUNET_free (ai); |
1101 | } | 1100 | } |
1102 | 1101 | ||
1102 | /** | ||
1103 | * Notify transport service that this communicator no longer provides all its addresses for this peer. | ||
1104 | * | ||
1105 | * @param ch The communicator handle. | ||
1106 | */ | ||
1107 | void | ||
1108 | GNUNET_TRANSPORT_communicator_address_remove_all ( | ||
1109 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | ||
1110 | { | ||
1111 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai; | ||
1112 | ai = ai->next) | ||
1113 | GNUNET_TRANSPORT_communicator_address_remove (ai); | ||
1114 | } | ||
1115 | |||
1103 | 1116 | ||
1104 | /* ************************* Backchannel *************************** */ | 1117 | /* ************************* Backchannel *************************** */ |
1105 | 1118 | ||
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 0dbe9dbe8..94b6f5099 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -94,7 +94,7 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, | |||
94 | * @param result where to store the hash code | 94 | * @param result where to store the hash code |
95 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 95 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
96 | */ | 96 | */ |
97 | int | 97 | enum GNUNET_GenericReturnValue |
98 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, | 98 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, |
99 | size_t enclen, | 99 | size_t enclen, |
100 | struct GNUNET_HashCode *result) | 100 | struct GNUNET_HashCode *result) |
diff --git a/src/util/gnunet-qr.c b/src/util/gnunet-qr.c index 83b2af2fc..451d61d40 100644 --- a/src/util/gnunet-qr.c +++ b/src/util/gnunet-qr.c | |||
@@ -36,7 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Video device to capture from. Sane default for GNU/Linux systems. | 37 | * Video device to capture from. Sane default for GNU/Linux systems. |
38 | */ | 38 | */ |
39 | static char *device = "/dev/video0"; | 39 | static char *device; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * --verbose option | 42 | * --verbose option |
@@ -51,7 +51,7 @@ static int silent = false; | |||
51 | /** | 51 | /** |
52 | * Handler exit code | 52 | * Handler exit code |
53 | */ | 53 | */ |
54 | static long unsigned int exit_code = 1; | 54 | static long unsigned int exit_code = 0; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Helper process we started. | 57 | * Helper process we started. |
@@ -228,6 +228,8 @@ get_symbol (zbar_processor_t *proc) | |||
228 | } | 228 | } |
229 | 229 | ||
230 | /* initialize the Processor */ | 230 | /* initialize the Processor */ |
231 | if (NULL == device) | ||
232 | device = GNUNET_strdup ("/dev/video0"); | ||
231 | if (0 != (rc = zbar_processor_init (proc, device, 1))) | 233 | if (0 != (rc = zbar_processor_init (proc, device, 1))) |
232 | { | 234 | { |
233 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -306,6 +308,7 @@ run_zbar () | |||
306 | ret = GNUNET_strdup (data); | 308 | ret = GNUNET_strdup (data); |
307 | /* clean up */ | 309 | /* clean up */ |
308 | zbar_processor_destroy (proc); | 310 | zbar_processor_destroy (proc); |
311 | GNUNET_free (device); | ||
309 | return ret; | 312 | return ret; |
310 | } | 313 | } |
311 | 314 | ||
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c index 9443c9120..de0ff1f92 100644 --- a/src/util/gnunet-uri.c +++ b/src/util/gnunet-uri.c | |||
@@ -29,7 +29,7 @@ | |||
29 | /** | 29 | /** |
30 | * Handler exit code | 30 | * Handler exit code |
31 | */ | 31 | */ |
32 | static long unsigned int exit_code = 1; | 32 | static long unsigned int exit_code = 0; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Helper process we started. | 35 | * Helper process we started. |
diff --git a/src/util/mq.c b/src/util/mq.c index 302b310de..29ead02a4 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -273,7 +273,7 @@ GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, | |||
273 | break; | 273 | break; |
274 | } | 274 | } |
275 | } | 275 | } |
276 | done: | 276 | done: |
277 | if (GNUNET_NO == handled) | 277 | if (GNUNET_NO == handled) |
278 | { | 278 | { |
279 | LOG (GNUNET_ERROR_TYPE_INFO, | 279 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -355,6 +355,10 @@ void | |||
355 | GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | 355 | GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, |
356 | struct GNUNET_MQ_Envelope *ev) | 356 | struct GNUNET_MQ_Envelope *ev) |
357 | { | 357 | { |
358 | if (NULL == mq) | ||
359 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
360 | "mq is NUll when sending message of type %u\n", | ||
361 | (unsigned int) ntohs (ev->mh->type)); | ||
358 | GNUNET_assert (NULL != mq); | 362 | GNUNET_assert (NULL != mq); |
359 | GNUNET_assert (NULL == ev->parent_queue); | 363 | GNUNET_assert (NULL == ev->parent_queue); |
360 | 364 | ||