aboutsummaryrefslogtreecommitdiff
path: root/src/set/set_api.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-09-27 04:32:52 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-09-27 04:32:52 +0000
commit9aceae8a9f91642665fa28730c961c9f90360bc1 (patch)
tree5390aca855b836d17720a65671f994089cb93196 /src/set/set_api.c
parent55ad4fa34348aaa05fadedeb830ea72cea5d7cc4 (diff)
downloadgnunet-9aceae8a9f91642665fa28730c961c9f90360bc1.tar.gz
gnunet-9aceae8a9f91642665fa28730c961c9f90360bc1.zip
SET service: accurate results for symmetric mode
Diffstat (limited to 'src/set/set_api.c')
-rw-r--r--src/set/set_api.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c
index 51a494d7f..16aa87cd0 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -398,40 +398,49 @@ handle_result (void *cls,
398 "Ignoring result from canceled operation\n"); 398 "Ignoring result from canceled operation\n");
399 return; 399 return;
400 } 400 }
401 if (GNUNET_SET_STATUS_OK != result_status) 401
402 switch (result_status)
402 { 403 {
403 /* status is not #GNUNET_SET_STATUS_OK => there's no attached element,
404 * and this is the last result message we get */
405 GNUNET_MQ_assoc_remove (set->mq,
406 ntohl (msg->request_id));
407 GNUNET_CONTAINER_DLL_remove (set->ops_head,
408 set->ops_tail,
409 oh);
410 if ( (GNUNET_YES == set->destroy_requested) &&
411 (NULL == set->ops_head) )
412 GNUNET_SET_destroy (set);
413 if (NULL != oh->result_cb)
414 oh->result_cb (oh->result_cls,
415 NULL,
416 result_status);
417 switch (result_status)
418 {
419 case GNUNET_SET_STATUS_OK: 404 case GNUNET_SET_STATUS_OK:
420 case GNUNET_SET_STATUS_ADD_LOCAL: 405 case GNUNET_SET_STATUS_ADD_LOCAL:
421 case GNUNET_SET_STATUS_ADD_REMOTE: 406 case GNUNET_SET_STATUS_ADD_REMOTE:
422 break; 407 goto do_element;
423 case GNUNET_SET_STATUS_FAILURE: 408 case GNUNET_SET_STATUS_FAILURE:
424 oh->result_cb = NULL;
425 break;
426 case GNUNET_SET_STATUS_HALF_DONE:
427 break;
428 case GNUNET_SET_STATUS_DONE: 409 case GNUNET_SET_STATUS_DONE:
429 oh->result_cb = NULL; 410 goto do_final;
430 break; 411 case GNUNET_SET_STATUS_HALF_DONE:
431 } 412 /* not used anymore */
432 GNUNET_free (oh); 413 GNUNET_assert (0);
433 return; 414 }
415
416do_final:
417 LOG (GNUNET_ERROR_TYPE_DEBUG,
418 "Treating result as final status\n");
419 GNUNET_MQ_assoc_remove (set->mq,
420 ntohl (msg->request_id));
421 GNUNET_CONTAINER_DLL_remove (set->ops_head,
422 set->ops_tail,
423 oh);
424 if (NULL != oh->result_cb)
425 {
426 oh->result_cb (oh->result_cls,
427 NULL,
428 result_status);
434 } 429 }
430 else
431 {
432 LOG (GNUNET_ERROR_TYPE_DEBUG,
433 "No callback for final status\n");
434 }
435 if ( (GNUNET_YES == set->destroy_requested) &&
436 (NULL == set->ops_head) )
437 GNUNET_SET_destroy (set);
438 GNUNET_free (oh);
439 return;
440
441do_element:
442 LOG (GNUNET_ERROR_TYPE_DEBUG,
443 "Treating result as element\n");
435 e.data = &msg[1]; 444 e.data = &msg[1];
436 e.size = ntohs (mh->size) - sizeof (struct GNUNET_SET_ResultMessage); 445 e.size = ntohs (mh->size) - sizeof (struct GNUNET_SET_ResultMessage);
437 e.element_type = msg->element_type; 446 e.element_type = msg->element_type;