diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-11-18 18:07:56 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-11-18 18:07:56 +0000 |
commit | 97d762c63bd0c844a015c6804603a3302766095e (patch) | |
tree | f5dcf288d37a84966daa5ecbfa3879069b2c200f /src/set | |
parent | ce25faf22dabe2ba33ed8bd8bea4d0ed6cd7acf8 (diff) | |
download | gnunet-97d762c63bd0c844a015c6804603a3302766095e.tar.gz gnunet-97d762c63bd0c844a015c6804603a3302766095e.zip |
work work
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 879f65809..3fa2a5289 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -313,33 +313,39 @@ intersection_operation_destroy (struct OperationState *eo) | |||
313 | 313 | ||
314 | 314 | ||
315 | /** | 315 | /** |
316 | * Inform the client that the intersection operation has failed, | 316 | * Inform the client that the union operation has failed, |
317 | * and proceed to destroy the evaluate operation. | 317 | * and proceed to destroy the evaluate operation. |
318 | * | 318 | * |
319 | * @param eo the intersection operation to fail | 319 | * @param op the intersection operation to fail |
320 | */ | 320 | */ |
321 | static void | 321 | static void |
322 | fail_intersection_operation (struct OperationState *eo) | 322 | fail_intersection_operation (struct Operation *op) |
323 | { | 323 | { |
324 | struct GNUNET_MQ_Envelope *ev; | 324 | struct GNUNET_MQ_Envelope *ev; |
325 | struct GNUNET_SET_ResultMessage *msg; | 325 | struct GNUNET_SET_ResultMessage *msg; |
326 | 326 | ||
327 | if (op->state->my_elements) | ||
328 | GNUNET_CONTAINER_multihashmap_destroy(op->state->my_elements); | ||
329 | |||
330 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "intersection operation failed\n"); | ||
331 | |||
327 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_RESULT); | 332 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_RESULT); |
328 | msg->result_status = htons (GNUNET_SET_STATUS_FAILURE); | 333 | msg->result_status = htons (GNUNET_SET_STATUS_FAILURE); |
329 | msg->request_id = htonl (eo->spec->client_request_id); | 334 | msg->request_id = htonl (op->spec->client_request_id); |
330 | msg->element_type = htons (0); | 335 | msg->element_type = htons (0); |
331 | GNUNET_MQ_send (eo->spec->set->client_mq, ev); | 336 | GNUNET_MQ_send (op->spec->set->client_mq, ev); |
332 | intersection_operation_destroy (eo); | 337 | _GSS_operation_destroy (op); |
333 | } | 338 | } |
334 | 339 | ||
335 | 340 | ||
341 | |||
336 | /** | 342 | /** |
337 | * Inform the peer that this operation is complete. | 343 | * Inform the peer that this operation is complete. |
338 | * | 344 | * |
339 | * @param eo the intersection operation to fail | 345 | * @param eo the intersection operation to fail |
340 | */ | 346 | */ |
341 | static void | 347 | static void |
342 | finalize_intersection_operation (struct Operation *op) | 348 | send_peer_done (struct Operation *op) |
343 | { | 349 | { |
344 | struct GNUNET_MQ_Envelope *ev; | 350 | struct GNUNET_MQ_Envelope *ev; |
345 | 351 | ||
@@ -418,7 +424,7 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
418 | switch (op->state->phase) | 424 | switch (op->state->phase) |
419 | { | 425 | { |
420 | case PHASE_INITIAL: | 426 | case PHASE_INITIAL: |
421 | // If we are alice and got our first msg | 427 | // If we are ot our first msg |
422 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create (op->state->my_elements_count, GNUNET_YES); | 428 | op->state->my_elements = GNUNET_CONTAINER_multihashmap_create (op->state->my_elements_count, GNUNET_YES); |
423 | 429 | ||
424 | GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->elements, | 430 | GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->elements, |
@@ -447,7 +453,7 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
447 | if ((op->state->phase == PHASE_MAYBE_FINISHED) | 453 | if ((op->state->phase == PHASE_MAYBE_FINISHED) |
448 | && (old_count == op->state->my_elements_count)){ | 454 | && (old_count == op->state->my_elements_count)){ |
449 | // In the last round we though we were finished, we now know this is correct | 455 | // In the last round we though we were finished, we now know this is correct |
450 | finalize_intersection_operation(op); | 456 | send_peer_done(op); |
451 | return; | 457 | return; |
452 | } | 458 | } |
453 | 459 | ||
@@ -579,7 +585,7 @@ finish_and_destroy (struct Operation *op) | |||
579 | send_remaining_elements (op); | 585 | send_remaining_elements (op); |
580 | return; | 586 | return; |
581 | } | 587 | } |
582 | send_done_and_destroy (op); | 588 | send_client_done_and_destroy (op); |
583 | } | 589 | } |
584 | 590 | ||
585 | /** | 591 | /** |
@@ -765,7 +771,7 @@ intersection_handle_p2p_message (struct Operation *op, | |||
765 | * @param cls operation to destroy | 771 | * @param cls operation to destroy |
766 | */ | 772 | */ |
767 | static void | 773 | static void |
768 | send_done_and_destroy (void *cls) | 774 | send_client_done_and_destroy (void *cls) |
769 | { | 775 | { |
770 | struct Operation *op = cls; | 776 | struct Operation *op = cls; |
771 | struct GNUNET_MQ_Envelope *ev; | 777 | struct GNUNET_MQ_Envelope *ev; |
@@ -787,15 +793,15 @@ static void | |||
787 | send_remaining_elements (void *cls) | 793 | send_remaining_elements (void *cls) |
788 | { | 794 | { |
789 | struct Operation *op = cls; | 795 | struct Operation *op = cls; |
790 | struct KeyEntry *ke; | 796 | struct KeyEntry *remaining; //TODO rework this, key entry does not exist here |
791 | int res; | 797 | int res; |
792 | 798 | ||
793 | res = GNUNET_CONTAINER_multihashmap32_iterator_next (op->state->full_result_iter, NULL, (const void **) &ke); | 799 | res = GNUNET_CONTAINER_multihashmap32_iterator_next (op->state->full_result_iter, NULL, (const void **) &remaining); |
794 | res = GNUNET_NO; | 800 | res = GNUNET_NO; |
795 | if (GNUNET_NO == res) | 801 | if (GNUNET_NO == res) |
796 | { | 802 | { |
797 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending done and destroy because iterator ran out\n"); | 803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending done and destroy because iterator ran out\n"); |
798 | send_done_and_destroy (op); | 804 | send_client_done_and_destroy (op); |
799 | return; | 805 | return; |
800 | } | 806 | } |
801 | 807 | ||
@@ -806,7 +812,7 @@ send_remaining_elements (void *cls) | |||
806 | struct GNUNET_MQ_Envelope *ev; | 812 | struct GNUNET_MQ_Envelope *ev; |
807 | struct GNUNET_SET_ResultMessage *rm; | 813 | struct GNUNET_SET_ResultMessage *rm; |
808 | struct GNUNET_SET_Element *element; | 814 | struct GNUNET_SET_Element *element; |
809 | element = &ke->element->element; | 815 | element = &remaining->element->element; |
810 | 816 | ||
811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client (full set)\n", element->size); | 817 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client (full set)\n", element->size); |
812 | GNUNET_assert (0 != op->spec->client_request_id); | 818 | GNUNET_assert (0 != op->spec->client_request_id); |
@@ -821,14 +827,14 @@ send_remaining_elements (void *cls) | |||
821 | rm->request_id = htonl (op->spec->client_request_id); | 827 | rm->request_id = htonl (op->spec->client_request_id); |
822 | rm->element_type = element->type; | 828 | rm->element_type = element->type; |
823 | memcpy (&rm[1], element->data, element->size); | 829 | memcpy (&rm[1], element->data, element->size); |
824 | if (ke->next_colliding == NULL) | 830 | if (remaining->next_colliding == NULL) |
825 | { | 831 | { |
826 | GNUNET_MQ_notify_sent (ev, send_remaining_elements, op); | 832 | GNUNET_MQ_notify_sent (ev, send_remaining_elements, op); |
827 | GNUNET_MQ_send (op->spec->set->client_mq, ev); | 833 | GNUNET_MQ_send (op->spec->set->client_mq, ev); |
828 | break; | 834 | break; |
829 | } | 835 | } |
830 | GNUNET_MQ_send (op->spec->set->client_mq, ev); | 836 | GNUNET_MQ_send (op->spec->set->client_mq, ev); |
831 | ke = ke->next_colliding; | 837 | remaining = remaining->next_colliding; |
832 | } | 838 | } |
833 | } | 839 | } |
834 | 840 | ||