diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-05 21:30:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-05 21:30:45 +0000 |
commit | 4a96bc0ef1d6b8771772a08f4702cbfb061679c8 (patch) | |
tree | 00798e6344d887ae8444bda8fd63a2f3e59bcad8 /src/set | |
parent | 4989f1f56b69db11da245ec92a981f1ee4c67a0b (diff) | |
download | gnunet-4a96bc0ef1d6b8771772a08f4702cbfb061679c8.tar.gz gnunet-4a96bc0ef1d6b8771772a08f4702cbfb061679c8.zip |
-check return values of hashmap operations
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 191 |
1 files changed, 104 insertions, 87 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index ce0e5c612..39c94592b 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -37,7 +37,7 @@ | |||
37 | enum IntersectionOperationPhase | 37 | enum IntersectionOperationPhase |
38 | { | 38 | { |
39 | /** | 39 | /** |
40 | * Alices has suggested an operation to bob, | 40 | * Alices has suggested an operation to bob, |
41 | * and is waiting for a bf or session end. | 41 | * and is waiting for a bf or session end. |
42 | */ | 42 | */ |
43 | PHASE_INITIAL, | 43 | PHASE_INITIAL, |
@@ -47,9 +47,9 @@ enum IntersectionOperationPhase | |||
47 | */ | 47 | */ |
48 | PHASE_BF_EXCHANGE, | 48 | PHASE_BF_EXCHANGE, |
49 | /** | 49 | /** |
50 | * if both peers have an equal peercount, they enter this state for | 50 | * if both peers have an equal peercount, they enter this state for |
51 | * one more turn, to see if they actually have agreed on a correct set. | 51 | * one more turn, to see if they actually have agreed on a correct set. |
52 | * if a peer finds the same element count after the next iteration, | 52 | * if a peer finds the same element count after the next iteration, |
53 | * it ends the the session | 53 | * it ends the the session |
54 | */ | 54 | */ |
55 | PHASE_MAYBE_FINISHED, | 55 | PHASE_MAYBE_FINISHED, |
@@ -87,12 +87,12 @@ struct OperationState | |||
87 | * was created. | 87 | * was created. |
88 | */ | 88 | */ |
89 | unsigned int generation_created; | 89 | unsigned int generation_created; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Maps element-id-hashes to 'elements in our set'. | 92 | * Maps element-id-hashes to 'elements in our set'. |
93 | */ | 93 | */ |
94 | struct GNUNET_CONTAINER_MultiHashMap *my_elements; | 94 | struct GNUNET_CONTAINER_MultiHashMap *my_elements; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * Current element count contained within contained_elements | 97 | * Current element count contained within contained_elements |
98 | */ | 98 | */ |
@@ -102,7 +102,7 @@ struct OperationState | |||
102 | * Iterator for sending elements on the key to element mapping to the client. | 102 | * Iterator for sending elements on the key to element mapping to the client. |
103 | */ | 103 | */ |
104 | struct GNUNET_CONTAINER_MultiHashMapIterator *full_result_iter; | 104 | struct GNUNET_CONTAINER_MultiHashMapIterator *full_result_iter; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Evaluate operations are held in | 107 | * Evaluate operations are held in |
108 | * a linked list. | 108 | * a linked list. |
@@ -136,10 +136,10 @@ struct SetState | |||
136 | 136 | ||
137 | /** | 137 | /** |
138 | * Alice's version: | 138 | * Alice's version: |
139 | * | 139 | * |
140 | * fills the contained-elements hashmap with all relevant | 140 | * fills the contained-elements hashmap with all relevant |
141 | * elements and adds their mutated hashes to our local bloomfilter with mutator+1 | 141 | * elements and adds their mutated hashes to our local bloomfilter with mutator+1 |
142 | * | 142 | * |
143 | * @param cls closure | 143 | * @param cls closure |
144 | * @param key current key code | 144 | * @param key current key code |
145 | * @param value value in the hash map | 145 | * @param value value in the hash map |
@@ -147,42 +147,48 @@ struct SetState | |||
147 | * iterate, | 147 | * iterate, |
148 | * #GNUNET_NO if not. | 148 | * #GNUNET_NO if not. |
149 | */ | 149 | */ |
150 | static int | 150 | static int |
151 | iterator_initialization_by_alice (void *cls, | 151 | iterator_initialization_by_alice (void *cls, |
152 | const struct GNUNET_HashCode *key, | 152 | const struct GNUNET_HashCode *key, |
153 | void *value){ | 153 | void *value) |
154 | { | ||
154 | struct ElementEntry *ee = value; | 155 | struct ElementEntry *ee = value; |
155 | struct Operation *op = cls; | 156 | struct Operation *op = cls; |
156 | struct GNUNET_HashCode mutated_hash; | 157 | struct GNUNET_HashCode mutated_hash; |
157 | 158 | ||
158 | //only consider this element, if it is valid for us | 159 | //only consider this element, if it is valid for us |
159 | if ((op->generation_created >= ee->generation_removed) | 160 | if ((op->generation_created >= ee->generation_removed) |
160 | || (op->generation_created < ee->generation_added)) | 161 | || (op->generation_created < ee->generation_added)) |
161 | return GNUNET_YES; | 162 | return GNUNET_YES; |
162 | 163 | ||
163 | // not contained according to bob's bloomfilter | 164 | // not contained according to bob's bloomfilter |
164 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt, &mutated_hash); | 165 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, |
165 | if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, | 166 | op->spec->salt, |
167 | &mutated_hash); | ||
168 | if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, | ||
166 | &mutated_hash)) | 169 | &mutated_hash)) |
167 | return GNUNET_YES; | 170 | return GNUNET_YES; |
168 | 171 | ||
169 | op->state->my_element_count++; | 172 | op->state->my_element_count++; |
170 | GNUNET_CONTAINER_multihashmap_put (op->state->my_elements, | 173 | GNUNET_assert (GNUNET_YES == |
171 | &ee->element_hash, ee, | 174 | GNUNET_CONTAINER_multihashmap_put (op->state->my_elements, |
172 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 175 | &ee->element_hash, ee, |
173 | 176 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | |
174 | // create our own bloomfilter with salt+1 | 177 | |
175 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt+1, &mutated_hash); | 178 | /* create our own bloomfilter with salt+1 */ |
176 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, | 179 | GNUNET_BLOCK_mingle_hash (&ee->element_hash, |
180 | op->spec->salt + 1, | ||
181 | &mutated_hash); | ||
182 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, | ||
177 | &mutated_hash); | 183 | &mutated_hash); |
178 | 184 | ||
179 | return GNUNET_YES; | 185 | return GNUNET_YES; |
180 | } | 186 | } |
181 | 187 | ||
182 | /** | 188 | /** |
183 | * fills the contained-elements hashmap with all relevant | 189 | * fills the contained-elements hashmap with all relevant |
184 | * elements and adds their mutated hashes to our local bloomfilter | 190 | * elements and adds their mutated hashes to our local bloomfilter |
185 | * | 191 | * |
186 | * @param cls closure | 192 | * @param cls closure |
187 | * @param key current key code | 193 | * @param key current key code |
188 | * @param value value in the hash map | 194 | * @param value value in the hash map |
@@ -190,28 +196,29 @@ iterator_initialization_by_alice (void *cls, | |||
190 | * iterate, | 196 | * iterate, |
191 | * #GNUNET_NO if not. | 197 | * #GNUNET_NO if not. |
192 | */ | 198 | */ |
193 | static int | 199 | static int |
194 | iterator_initialization (void *cls, | 200 | iterator_initialization (void *cls, |
195 | const struct GNUNET_HashCode *key, | 201 | const struct GNUNET_HashCode *key, |
196 | void *value){ | 202 | void *value) |
203 | { | ||
197 | struct ElementEntry *ee = value; | 204 | struct ElementEntry *ee = value; |
198 | struct Operation *op = cls; | 205 | struct Operation *op = cls; |
199 | struct GNUNET_HashCode mutated_hash; | 206 | struct GNUNET_HashCode mutated_hash; |
200 | 207 | ||
201 | //only consider this element, if it is valid for us | 208 | //only consider this element, if it is valid for us |
202 | if ((op->generation_created >= ee->generation_removed) | 209 | if ((op->generation_created >= ee->generation_removed) |
203 | || (op->generation_created < ee->generation_added)) | 210 | || (op->generation_created < ee->generation_added)) |
204 | return GNUNET_YES; | 211 | return GNUNET_YES; |
205 | 212 | ||
206 | GNUNET_CONTAINER_multihashmap_put (op->state->my_elements, | 213 | GNUNET_assert (GNUNET_YES == |
207 | &ee->element_hash, ee, | 214 | GNUNET_CONTAINER_multihashmap_put (op->state->my_elements, |
208 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 215 | &ee->element_hash, ee, |
209 | 216 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | |
210 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt, &mutated_hash); | 217 | GNUNET_BLOCK_mingle_hash (&ee->element_hash, |
211 | 218 | op->spec->salt, | |
212 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, | 219 | &mutated_hash); |
220 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, | ||
213 | &mutated_hash); | 221 | &mutated_hash); |
214 | |||
215 | return GNUNET_YES; | 222 | return GNUNET_YES; |
216 | } | 223 | } |
217 | 224 | ||
@@ -219,7 +226,7 @@ iterator_initialization (void *cls, | |||
219 | /** | 226 | /** |
220 | * removes element from a hashmap if it is not contained within the | 227 | * removes element from a hashmap if it is not contained within the |
221 | * provided remote bloomfilter. Then, fill our new bloomfilter. | 228 | * provided remote bloomfilter. Then, fill our new bloomfilter. |
222 | * | 229 | * |
223 | * @param cls closure | 230 | * @param cls closure |
224 | * @param key current key code | 231 | * @param key current key code |
225 | * @param value value in the hash map | 232 | * @param value value in the hash map |
@@ -229,31 +236,35 @@ iterator_initialization (void *cls, | |||
229 | */ | 236 | */ |
230 | static int | 237 | static int |
231 | iterator_bf_round (void *cls, | 238 | iterator_bf_round (void *cls, |
232 | const struct GNUNET_HashCode *key, | 239 | const struct GNUNET_HashCode *key, |
233 | void *value){ | 240 | void *value) |
241 | { | ||
234 | struct ElementEntry *ee = value; | 242 | struct ElementEntry *ee = value; |
235 | struct Operation *op = cls; | 243 | struct Operation *op = cls; |
236 | struct GNUNET_HashCode mutated_hash; | 244 | struct GNUNET_HashCode mutated_hash; |
237 | 245 | ||
238 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt, &mutated_hash); | 246 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt, &mutated_hash); |
239 | 247 | ||
240 | if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, | 248 | if (GNUNET_NO == |
241 | &mutated_hash)){ | 249 | GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, |
250 | &mutated_hash)) | ||
251 | { | ||
242 | op->state->my_element_count--; | 252 | op->state->my_element_count--; |
243 | GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements, | 253 | GNUNET_assert (GNUNET_YES == |
244 | &ee->element_hash, | 254 | GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements, |
245 | ee); | 255 | &ee->element_hash, |
256 | ee)); | ||
246 | return GNUNET_YES; | 257 | return GNUNET_YES; |
247 | } | 258 | } |
248 | 259 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, | |
249 | GNUNET_BLOCK_mingle_hash(&ee->element_hash, op->spec->salt+1, &mutated_hash); | 260 | op->spec->salt+1, |
250 | 261 | &mutated_hash); | |
251 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, | 262 | GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf, |
252 | &mutated_hash); | 263 | &mutated_hash); |
253 | |||
254 | return GNUNET_YES; | 264 | return GNUNET_YES; |
255 | } | 265 | } |
256 | 266 | ||
267 | |||
257 | /** | 268 | /** |
258 | * Inform the client that the union operation has failed, | 269 | * Inform the client that the union operation has failed, |
259 | * and proceed to destroy the evaluate operation. | 270 | * and proceed to destroy the evaluate operation. |
@@ -268,7 +279,7 @@ fail_intersection_operation (struct Operation *op) | |||
268 | 279 | ||
269 | if (op->state->my_elements) | 280 | if (op->state->my_elements) |
270 | GNUNET_CONTAINER_multihashmap_destroy(op->state->my_elements); | 281 | GNUNET_CONTAINER_multihashmap_destroy(op->state->my_elements); |
271 | 282 | ||
272 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "intersection operation failed\n"); | 283 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "intersection operation failed\n"); |
273 | 284 | ||
274 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_RESULT); | 285 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_RESULT); |
@@ -305,7 +316,7 @@ send_operation_request (struct Operation *op) | |||
305 | msg->app_id = op->spec->app_id; | 316 | msg->app_id = op->spec->app_id; |
306 | msg->salt = htonl (op->spec->salt); | 317 | msg->salt = htonl (op->spec->salt); |
307 | msg->element_count = htonl(op->state->my_element_count); | 318 | msg->element_count = htonl(op->state->my_element_count); |
308 | 319 | ||
309 | GNUNET_MQ_send (op->mq, ev); | 320 | GNUNET_MQ_send (op->mq, ev); |
310 | 321 | ||
311 | if (NULL != op->spec->context_msg) | 322 | if (NULL != op->spec->context_msg) |
@@ -318,9 +329,9 @@ send_operation_request (struct Operation *op) | |||
318 | GNUNET_free (op->spec->context_msg); | 329 | GNUNET_free (op->spec->context_msg); |
319 | op->spec->context_msg = NULL; | 330 | op->spec->context_msg = NULL; |
320 | } | 331 | } |
321 | |||
322 | } | 332 | } |
323 | 333 | ||
334 | |||
324 | /** | 335 | /** |
325 | * Send a bloomfilter to our peer. | 336 | * Send a bloomfilter to our peer. |
326 | * that the operation is over. | 337 | * that the operation is over. |
@@ -398,14 +409,14 @@ send_remaining_elements (void *cls) | |||
398 | send_client_done_and_destroy (op); | 409 | send_client_done_and_destroy (op); |
399 | return; | 410 | return; |
400 | } | 411 | } |
401 | 412 | ||
402 | element = &remaining->element; | 413 | element = &remaining->element; |
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client (full set)\n", element->size); | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client (full set)\n", element->size); |
404 | GNUNET_assert (0 != op->spec->client_request_id); | 415 | GNUNET_assert (0 != op->spec->client_request_id); |
405 | 416 | ||
406 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); | 417 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); |
407 | GNUNET_assert (NULL != ev); | 418 | GNUNET_assert (NULL != ev); |
408 | 419 | ||
409 | rm->result_status = htons (GNUNET_SET_STATUS_OK); | 420 | rm->result_status = htons (GNUNET_SET_STATUS_OK); |
410 | rm->request_id = htonl (op->spec->client_request_id); | 421 | rm->request_id = htonl (op->spec->client_request_id); |
411 | rm->element_type = element->type; | 422 | rm->element_type = element->type; |
@@ -452,7 +463,7 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
452 | 463 | ||
453 | old_elements = op->state->my_element_count; | 464 | old_elements = op->state->my_element_count; |
454 | op->spec->salt = ntohl (msg->sender_mutator); | 465 | op->spec->salt = ntohl (msg->sender_mutator); |
455 | 466 | ||
456 | op->state->remote_bf = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1], | 467 | op->state->remote_bf = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1], |
457 | BLOOMFILTER_SIZE, | 468 | BLOOMFILTER_SIZE, |
458 | ntohl (msg->bloomfilter_length)); | 469 | ntohl (msg->bloomfilter_length)); |
@@ -484,19 +495,19 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
484 | // the peer needs this information for decoding the next BF | 495 | // the peer needs this information for decoding the next BF |
485 | // this behavior can be modified at will later on. | 496 | // this behavior can be modified at will later on. |
486 | op->spec->salt++; | 497 | op->spec->salt++; |
487 | 498 | ||
488 | GNUNET_CONTAINER_bloomfilter_free (op->state->remote_bf); | 499 | GNUNET_CONTAINER_bloomfilter_free (op->state->remote_bf); |
489 | op->state->remote_bf = NULL; | 500 | op->state->remote_bf = NULL; |
490 | 501 | ||
491 | peer_elements = ntohl(msg->sender_element_count); | 502 | peer_elements = ntohl(msg->sender_element_count); |
492 | if ((op->state->phase == PHASE_MAYBE_FINISHED) | 503 | if ((op->state->phase == PHASE_MAYBE_FINISHED) |
493 | && (old_elements == op->state->my_element_count) | 504 | && (old_elements == op->state->my_element_count) |
494 | && (op->state->my_element_count == peer_elements)){ | 505 | && (op->state->my_element_count == peer_elements)){ |
495 | // In the last round we though we were finished, we now know this is correct | 506 | // In the last round we though we were finished, we now know this is correct |
496 | send_peer_done(op); | 507 | send_peer_done(op); |
497 | return; | 508 | return; |
498 | } | 509 | } |
499 | 510 | ||
500 | op->state->phase = PHASE_BF_EXCHANGE; | 511 | op->state->phase = PHASE_BF_EXCHANGE; |
501 | // maybe we are finished, but we do one more round to make certain | 512 | // maybe we are finished, but we do one more round to make certain |
502 | // we don't have false positives ... | 513 | // we don't have false positives ... |
@@ -569,6 +580,7 @@ send_element_count (struct Operation *op) | |||
569 | GNUNET_MQ_send (op->mq, ev); | 580 | GNUNET_MQ_send (op->mq, ev); |
570 | } | 581 | } |
571 | 582 | ||
583 | |||
572 | /** | 584 | /** |
573 | * Send a result message to the client indicating | 585 | * Send a result message to the client indicating |
574 | * that the operation is over. | 586 | * that the operation is over. |
@@ -593,6 +605,7 @@ finish_and_destroy (struct Operation *op) | |||
593 | send_client_done_and_destroy (op); | 605 | send_client_done_and_destroy (op); |
594 | } | 606 | } |
595 | 607 | ||
608 | |||
596 | /** | 609 | /** |
597 | * Handle a done message from a remote peer | 610 | * Handle a done message from a remote peer |
598 | * | 611 | * |
@@ -600,17 +613,18 @@ finish_and_destroy (struct Operation *op) | |||
600 | * @param mh the message | 613 | * @param mh the message |
601 | */ | 614 | */ |
602 | static void | 615 | static void |
603 | handle_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh) | 616 | handle_p2p_done (void *cls, |
617 | const struct GNUNET_MessageHeader *mh) | ||
604 | { | 618 | { |
605 | struct Operation *op = cls; | 619 | struct Operation *op = cls; |
606 | 620 | ||
607 | if ((op->state->phase = PHASE_FINISHED) || (op->state->phase = PHASE_MAYBE_FINISHED)){ | 621 | if ((op->state->phase = PHASE_FINISHED) || (op->state->phase = PHASE_MAYBE_FINISHED)){ |
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got final DONE\n"); | 622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got final DONE\n"); |
609 | 623 | ||
610 | finish_and_destroy (op); | 624 | finish_and_destroy (op); |
611 | return; | 625 | return; |
612 | } | 626 | } |
613 | 627 | ||
614 | GNUNET_break_op (0); | 628 | GNUNET_break_op (0); |
615 | fail_intersection_operation (op); | 629 | fail_intersection_operation (op); |
616 | } | 630 | } |
@@ -630,11 +644,13 @@ intersection_evaluate (struct Operation *op) | |||
630 | op->state->phase = PHASE_INITIAL; | 644 | op->state->phase = PHASE_INITIAL; |
631 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES); | 645 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES); |
632 | op->state->my_element_count = op->spec->set->state->current_set_element_count; | 646 | op->state->my_element_count = op->spec->set->state->current_set_element_count; |
633 | 647 | ||
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "evaluating intersection operation"); | 648 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
649 | "evaluating intersection operation"); | ||
635 | send_operation_request (op); | 650 | send_operation_request (op); |
636 | } | 651 | } |
637 | 652 | ||
653 | |||
638 | /** | 654 | /** |
639 | * Accept an union operation request from a remote peer. | 655 | * Accept an union operation request from a remote peer. |
640 | * Only initializes the private operation state. | 656 | * Only initializes the private operation state. |
@@ -648,7 +664,7 @@ intersection_accept (struct Operation *op) | |||
648 | op->state = GNUNET_new (struct OperationState); | 664 | op->state = GNUNET_new (struct OperationState); |
649 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES); | 665 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES); |
650 | op->state->my_element_count = op->spec->set->state->current_set_element_count; | 666 | op->state->my_element_count = op->spec->set->state->current_set_element_count; |
651 | 667 | ||
652 | // if Alice (the peer) has more elements than Bob (us), she should start | 668 | // if Alice (the peer) has more elements than Bob (us), she should start |
653 | if (op->spec->remote_element_count < op->state->my_element_count){ | 669 | if (op->spec->remote_element_count < op->state->my_element_count){ |
654 | op->state->phase = PHASE_INITIAL; | 670 | op->state->phase = PHASE_INITIAL; |
@@ -673,15 +689,15 @@ intersection_accept (struct Operation *op) | |||
673 | * @return the newly created set | 689 | * @return the newly created set |
674 | */ | 690 | */ |
675 | static struct SetState * | 691 | static struct SetState * |
676 | intersection_set_create (void) | 692 | intersection_set_create () |
677 | { | 693 | { |
678 | struct SetState *set_state; | 694 | struct SetState *set_state; |
679 | 695 | ||
680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "intersection set created\n"); | 696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
681 | 697 | "intersection set created\n"); | |
682 | set_state = GNUNET_new (struct SetState); | 698 | set_state = GNUNET_new (struct SetState); |
683 | set_state->current_set_element_count = 0; | 699 | set_state->current_set_element_count = 0; |
684 | 700 | ||
685 | return set_state; | 701 | return set_state; |
686 | } | 702 | } |
687 | 703 | ||
@@ -693,7 +709,8 @@ intersection_set_create (void) | |||
693 | * @param ee the element to add to the set | 709 | * @param ee the element to add to the set |
694 | */ | 710 | */ |
695 | static void | 711 | static void |
696 | intersection_add (struct SetState *set_state, struct ElementEntry *ee) | 712 | intersection_add (struct SetState *set_state, |
713 | struct ElementEntry *ee) | ||
697 | { | 714 | { |
698 | GNUNET_assert(0 < set_state->current_set_element_count); | 715 | GNUNET_assert(0 < set_state->current_set_element_count); |
699 | set_state->current_set_element_count++; | 716 | set_state->current_set_element_count++; |
@@ -719,11 +736,11 @@ intersection_set_destroy (struct SetState *set_state) | |||
719 | * @param element set element to remove | 736 | * @param element set element to remove |
720 | */ | 737 | */ |
721 | static void | 738 | static void |
722 | intersection_remove (struct SetState *set_state, struct ElementEntry *element) | 739 | intersection_remove (struct SetState *set_state, |
740 | struct ElementEntry *element) | ||
723 | { | 741 | { |
724 | GNUNET_assert(0 < set_state->current_set_element_count); | 742 | GNUNET_assert(0 < set_state->current_set_element_count); |
725 | set_state->current_set_element_count--; | 743 | set_state->current_set_element_count--; |
726 | //nothing to do here | ||
727 | } | 744 | } |
728 | 745 | ||
729 | 746 | ||
@@ -732,10 +749,10 @@ intersection_remove (struct SetState *set_state, struct ElementEntry *element) | |||
732 | * | 749 | * |
733 | * @param eo the state of the intersection evaluate operation | 750 | * @param eo the state of the intersection evaluate operation |
734 | * @param mh the received message | 751 | * @param mh the received message |
735 | * @return GNUNET_SYSERR if the tunnel should be disconnected, | 752 | * @return #GNUNET_SYSERR if the tunnel should be disconnected, |
736 | * GNUNET_OK otherwise | 753 | * #GNUNET_OK otherwise |
737 | */ | 754 | */ |
738 | int | 755 | static int |
739 | intersection_handle_p2p_message (struct Operation *op, | 756 | intersection_handle_p2p_message (struct Operation *op, |
740 | const struct GNUNET_MessageHeader *mh) | 757 | const struct GNUNET_MessageHeader *mh) |
741 | { | 758 | { |
@@ -765,7 +782,7 @@ intersection_handle_p2p_message (struct Operation *op, | |||
765 | 782 | ||
766 | /** | 783 | /** |
767 | * handler for peer-disconnects, notifies the client about the aborted operation | 784 | * handler for peer-disconnects, notifies the client about the aborted operation |
768 | * | 785 | * |
769 | * @param op the destroyed operation | 786 | * @param op the destroyed operation |
770 | */ | 787 | */ |
771 | static void | 788 | static void |
@@ -794,7 +811,7 @@ intersection_peer_disconnect (struct Operation *op) | |||
794 | 811 | ||
795 | /** | 812 | /** |
796 | * Destroy the union operation. Only things specific to the union operation are destroyed. | 813 | * Destroy the union operation. Only things specific to the union operation are destroyed. |
797 | * | 814 | * |
798 | * @param op union operation to destroy | 815 | * @param op union operation to destroy |
799 | */ | 816 | */ |
800 | static void | 817 | static void |