aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-09-27 04:41:31 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-09-27 04:41:31 +0000
commit092ff3f1611ffda53469a8cfa7f2cb188aa03417 (patch)
treebdd9e1202091fc9faed82cfe9a623e9a6a22bc69 /src/set
parent9aceae8a9f91642665fa28730c961c9f90360bc1 (diff)
downloadgnunet-092ff3f1611ffda53469a8cfa7f2cb188aa03417.tar.gz
gnunet-092ff3f1611ffda53469a8cfa7f2cb188aa03417.zip
remove macro, fix indentation
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set_union.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 47abeaac8..c32acc1e6 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -33,8 +33,6 @@
33 33
34#define LOG(kind,...) GNUNET_log_from (kind, "set-union",__VA_ARGS__) 34#define LOG(kind,...) GNUNET_log_from (kind, "set-union",__VA_ARGS__)
35 35
36#define LOG_OP(kind,msg,op,...) GNUNET_log_from (kind, "set-union","[OP %x] " msg,((void *)op),__VA_ARGS__)
37
38 36
39/** 37/**
40 * Number of IBFs in a strata estimator. 38 * Number of IBFs in a strata estimator.
@@ -564,10 +562,10 @@ send_ibf (struct Operation *op,
564 buckets_in_message, &msg[1]); 562 buckets_in_message, &msg[1]);
565 buckets_sent += buckets_in_message; 563 buckets_sent += buckets_in_message;
566 LOG (GNUNET_ERROR_TYPE_DEBUG, 564 LOG (GNUNET_ERROR_TYPE_DEBUG,
567 "ibf chunk size %u, %u/%u sent\n", 565 "ibf chunk size %u, %u/%u sent\n",
568 buckets_in_message, 566 buckets_in_message,
569 buckets_sent, 567 buckets_sent,
570 1<<ibf_order); 568 1<<ibf_order);
571 GNUNET_MQ_send (op->mq, ev); 569 GNUNET_MQ_send (op->mq, ev);
572 } 570 }
573 571
@@ -596,7 +594,7 @@ send_strata_estimator (struct Operation *op)
596 ev); 594 ev);
597 op->state->phase = PHASE_EXPECT_IBF; 595 op->state->phase = PHASE_EXPECT_IBF;
598 LOG (GNUNET_ERROR_TYPE_DEBUG, 596 LOG (GNUNET_ERROR_TYPE_DEBUG,
599 "sent SE, expecting IBF\n"); 597 "sent SE, expecting IBF\n");
600} 598}
601 599
602 600
@@ -663,9 +661,9 @@ handle_p2p_strata_estimator (void *cls,
663 strata_estimator_destroy (op->state->se); 661 strata_estimator_destroy (op->state->se);
664 op->state->se = NULL; 662 op->state->se = NULL;
665 LOG (GNUNET_ERROR_TYPE_DEBUG, 663 LOG (GNUNET_ERROR_TYPE_DEBUG,
666 "got se diff=%d, using ibf size %d\n", 664 "got se diff=%d, using ibf size %d\n",
667 diff, 665 diff,
668 1<<get_order_from_difference (diff)); 666 1<<get_order_from_difference (diff));
669 send_ibf (op, 667 send_ibf (op,
670 get_order_from_difference (diff)); 668 get_order_from_difference (diff));
671 return GNUNET_OK; 669 return GNUNET_OK;
@@ -701,9 +699,9 @@ send_offers_iterator (void *cls,
701 GNUNET_assert (NULL != ev); 699 GNUNET_assert (NULL != ev);
702 *(struct GNUNET_HashCode *) &mh[1] = ke->element->element_hash; 700 *(struct GNUNET_HashCode *) &mh[1] = ke->element->element_hash;
703 LOG (GNUNET_ERROR_TYPE_DEBUG, 701 LOG (GNUNET_ERROR_TYPE_DEBUG,
704 "[OP %x] sending element offer (%s) to peer\n", 702 "[OP %x] sending element offer (%s) to peer\n",
705 (void *) op, 703 (void *) op,
706 GNUNET_h2s (&ke->element->element_hash)); 704 GNUNET_h2s (&ke->element->element_hash));
707 GNUNET_MQ_send (op->mq, ev); 705 GNUNET_MQ_send (op->mq, ev);
708 return GNUNET_YES; 706 return GNUNET_YES;
709} 707}
@@ -755,8 +753,8 @@ decode_and_send (struct Operation *op)
755 op->state->remote_ibf = NULL; 753 op->state->remote_ibf = NULL;
756 754
757 LOG (GNUNET_ERROR_TYPE_DEBUG, 755 LOG (GNUNET_ERROR_TYPE_DEBUG,
758 "decoding IBF (size=%u)\n", 756 "decoding IBF (size=%u)\n",
759 diff_ibf->size); 757 diff_ibf->size);
760 758
761 num_decoded = 0; 759 num_decoded = 0;
762 last_key.key_val = 0; 760 last_key.key_val = 0;
@@ -772,16 +770,16 @@ decode_and_send (struct Operation *op)
772 if (res == GNUNET_OK) 770 if (res == GNUNET_OK)
773 { 771 {
774 LOG (GNUNET_ERROR_TYPE_DEBUG, 772 LOG (GNUNET_ERROR_TYPE_DEBUG,
775 "decoded ibf key %lx\n", 773 "decoded ibf key %lx\n",
776 (unsigned long) key.key_val); 774 (unsigned long) key.key_val);
777 num_decoded += 1; 775 num_decoded += 1;
778 if ( (num_decoded > diff_ibf->size) || 776 if ( (num_decoded > diff_ibf->size) ||
779 (num_decoded > 1 && last_key.key_val == key.key_val) ) 777 (num_decoded > 1 && last_key.key_val == key.key_val) )
780 { 778 {
781 LOG (GNUNET_ERROR_TYPE_DEBUG, 779 LOG (GNUNET_ERROR_TYPE_DEBUG,
782 "detected cyclic ibf (decoded %u/%u)\n", 780 "detected cyclic ibf (decoded %u/%u)\n",
783 num_decoded, 781 num_decoded,
784 diff_ibf->size); 782 diff_ibf->size);
785 cycle_detected = GNUNET_YES; 783 cycle_detected = GNUNET_YES;
786 } 784 }
787 } 785 }
@@ -795,17 +793,16 @@ decode_and_send (struct Operation *op)
795 next_order++; 793 next_order++;
796 if (next_order <= MAX_IBF_ORDER) 794 if (next_order <= MAX_IBF_ORDER)
797 { 795 {
798 LOG_OP (GNUNET_ERROR_TYPE_DEBUG, 796 LOG (GNUNET_ERROR_TYPE_DEBUG,
799 "decoding failed, sending larger ibf (size %u)\n", 797 "decoding failed, sending larger ibf (size %u)\n",
800 op, 798 1<<next_order);
801 1<<next_order);
802 send_ibf (op, next_order); 799 send_ibf (op, next_order);
803 } 800 }
804 else 801 else
805 { 802 {
806 // XXX: Send the whole set, element-by-element 803 // XXX: Send the whole set, element-by-element
807 LOG (GNUNET_ERROR_TYPE_ERROR, 804 LOG (GNUNET_ERROR_TYPE_ERROR,
808 "set union failed: reached ibf limit\n"); 805 "set union failed: reached ibf limit\n");
809 } 806 }
810 break; 807 break;
811 } 808 }
@@ -814,7 +811,7 @@ decode_and_send (struct Operation *op)
814 struct GNUNET_MQ_Envelope *ev; 811 struct GNUNET_MQ_Envelope *ev;
815 812
816 LOG (GNUNET_ERROR_TYPE_DEBUG, 813 LOG (GNUNET_ERROR_TYPE_DEBUG,
817 "transmitted all values, sending DONE\n"); 814 "transmitted all values, sending DONE\n");
818 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE); 815 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE);
819 GNUNET_MQ_send (op->mq, ev); 816 GNUNET_MQ_send (op->mq, ev);
820 /* We now wait until we get a DONE message back 817 /* We now wait until we get a DONE message back
@@ -841,8 +838,8 @@ decode_and_send (struct Operation *op)
841 &key, 838 &key,
842 sizeof (struct IBF_Key)); 839 sizeof (struct IBF_Key));
843 LOG (GNUNET_ERROR_TYPE_DEBUG, 840 LOG (GNUNET_ERROR_TYPE_DEBUG,
844 "sending element inquiry for IBF key %lx\n", 841 "sending element inquiry for IBF key %lx\n",
845 (unsigned long) key.key_val); 842 (unsigned long) key.key_val);
846 GNUNET_MQ_send (op->mq, ev); 843 GNUNET_MQ_send (op->mq, ev);
847 } 844 }
848 else 845 else
@@ -886,8 +883,8 @@ handle_p2p_ibf (void *cls,
886 op->state->phase = PHASE_EXPECT_IBF_CONT; 883 op->state->phase = PHASE_EXPECT_IBF_CONT;
887 GNUNET_assert (NULL == op->state->remote_ibf); 884 GNUNET_assert (NULL == op->state->remote_ibf);
888 LOG (GNUNET_ERROR_TYPE_DEBUG, 885 LOG (GNUNET_ERROR_TYPE_DEBUG,
889 "Creating new ibf of size %u\n", 886 "Creating new ibf of size %u\n",
890 1 << msg->order); 887 1 << msg->order);
891 op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); 888 op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM);
892 op->state->ibf_buckets_received = 0; 889 op->state->ibf_buckets_received = 0;
893 if (0 != ntohs (msg->offset)) 890 if (0 != ntohs (msg->offset))
@@ -909,9 +906,6 @@ handle_p2p_ibf (void *cls,
909 } 906 }
910 else 907 else
911 { 908 {
912 LOG_OP (GNUNET_ERROR_TYPE_DEBUG,
913 "wrong phase\n",
914 op, NULL);
915 GNUNET_assert (0); 909 GNUNET_assert (0);
916 } 910 }
917 911
@@ -942,7 +936,7 @@ handle_p2p_ibf (void *cls,
942 if (op->state->ibf_buckets_received == op->state->remote_ibf->size) 936 if (op->state->ibf_buckets_received == op->state->remote_ibf->size)
943 { 937 {
944 LOG (GNUNET_ERROR_TYPE_DEBUG, 938 LOG (GNUNET_ERROR_TYPE_DEBUG,
945 "received full ibf\n"); 939 "received full ibf\n");
946 op->state->phase = PHASE_INVENTORY_ACTIVE; 940 op->state->phase = PHASE_INVENTORY_ACTIVE;
947 decode_and_send (op); 941 decode_and_send (op);
948 } 942 }
@@ -967,8 +961,8 @@ send_client_element (struct Operation *op,
967 struct GNUNET_SET_ResultMessage *rm; 961 struct GNUNET_SET_ResultMessage *rm;
968 962
969 LOG (GNUNET_ERROR_TYPE_DEBUG, 963 LOG (GNUNET_ERROR_TYPE_DEBUG,
970 "sending element (size %u) to client\n", 964 "sending element (size %u) to client\n",
971 element->size); 965 element->size);
972 GNUNET_assert (0 != op->spec->client_request_id); 966 GNUNET_assert (0 != op->spec->client_request_id);
973 ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); 967 ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT);
974 if (NULL == ev) 968 if (NULL == ev)
@@ -1098,9 +1092,9 @@ handle_p2p_elements (void *cls,
1098 } 1092 }
1099 1093
1100 LOG (GNUNET_ERROR_TYPE_DEBUG, 1094 LOG (GNUNET_ERROR_TYPE_DEBUG,
1101 "Got element (size %u, hash %s) from peer\n", 1095 "Got element (size %u, hash %s) from peer\n",
1102 (unsigned int) element_size, 1096 (unsigned int) element_size,
1103 GNUNET_h2s (&ee->element_hash)); 1097 GNUNET_h2s (&ee->element_hash));
1104 1098
1105 if (GNUNET_YES == op_has_element (op, &ee->element_hash)) 1099 if (GNUNET_YES == op_has_element (op, &ee->element_hash))
1106 { 1100 {
@@ -1331,7 +1325,7 @@ handle_p2p_done (void *cls,
1331 op->state->phase = PHASE_FINISH_WAITING; 1325 op->state->phase = PHASE_FINISH_WAITING;
1332 1326
1333 LOG (GNUNET_ERROR_TYPE_DEBUG, 1327 LOG (GNUNET_ERROR_TYPE_DEBUG,
1334 "got DONE (as passive partner), waiting for our demands to be satisfied\n"); 1328 "got DONE (as passive partner), waiting for our demands to be satisfied\n");
1335 /* The active peer is done sending offers 1329 /* The active peer is done sending offers
1336 * and inquiries. This means that all 1330 * and inquiries. This means that all
1337 * our responses to that (demands and offers) 1331 * our responses to that (demands and offers)
@@ -1347,7 +1341,7 @@ handle_p2p_done (void *cls,
1347 if (op->state->phase == PHASE_INVENTORY_ACTIVE) 1341 if (op->state->phase == PHASE_INVENTORY_ACTIVE)
1348 { 1342 {
1349 LOG (GNUNET_ERROR_TYPE_DEBUG, 1343 LOG (GNUNET_ERROR_TYPE_DEBUG,
1350 "got DONE (as active partner), waiting to finish\n"); 1344 "got DONE (as active partner), waiting to finish\n");
1351 /* All demands of the other peer are satisfied, 1345 /* All demands of the other peer are satisfied,
1352 * and we processed all offers, thus we know 1346 * and we processed all offers, thus we know
1353 * exactly what our demands must be. 1347 * exactly what our demands must be.
@@ -1386,7 +1380,7 @@ union_evaluate (struct Operation *op,
1386 /* we started the operation, thus we have to send the operation request */ 1380 /* we started the operation, thus we have to send the operation request */
1387 op->state->phase = PHASE_EXPECT_SE; 1381 op->state->phase = PHASE_EXPECT_SE;
1388 LOG (GNUNET_ERROR_TYPE_DEBUG, 1382 LOG (GNUNET_ERROR_TYPE_DEBUG,
1389 "Initiating union operation evaluation\n"); 1383 "Initiating union operation evaluation\n");
1390 ev = GNUNET_MQ_msg_nested_mh (msg, 1384 ev = GNUNET_MQ_msg_nested_mh (msg,
1391 GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, 1385 GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
1392 opaque_context); 1386 opaque_context);
@@ -1404,10 +1398,10 @@ union_evaluate (struct Operation *op,
1404 1398
1405 if (NULL != opaque_context) 1399 if (NULL != opaque_context)
1406 LOG (GNUNET_ERROR_TYPE_DEBUG, 1400 LOG (GNUNET_ERROR_TYPE_DEBUG,
1407 "sent op request with context message\n"); 1401 "sent op request with context message\n");
1408 else 1402 else
1409 LOG (GNUNET_ERROR_TYPE_DEBUG, 1403 LOG (GNUNET_ERROR_TYPE_DEBUG,
1410 "sent op request without context message\n"); 1404 "sent op request without context message\n");
1411} 1405}
1412 1406
1413 1407
@@ -1421,7 +1415,7 @@ static void
1421union_accept (struct Operation *op) 1415union_accept (struct Operation *op)
1422{ 1416{
1423 LOG (GNUNET_ERROR_TYPE_DEBUG, 1417 LOG (GNUNET_ERROR_TYPE_DEBUG,
1424 "accepting set union operation\n"); 1418 "accepting set union operation\n");
1425 GNUNET_assert (NULL == op->state); 1419 GNUNET_assert (NULL == op->state);
1426 op->state = GNUNET_new (struct OperationState); 1420 op->state = GNUNET_new (struct OperationState);
1427 op->state->se = strata_estimator_dup (op->spec->set->state->se); 1421 op->state->se = strata_estimator_dup (op->spec->set->state->se);
@@ -1445,7 +1439,7 @@ union_set_create (void)
1445 struct SetState *set_state; 1439 struct SetState *set_state;
1446 1440
1447 LOG (GNUNET_ERROR_TYPE_DEBUG, 1441 LOG (GNUNET_ERROR_TYPE_DEBUG,
1448 "union set created\n"); 1442 "union set created\n");
1449 set_state = GNUNET_new (struct SetState); 1443 set_state = GNUNET_new (struct SetState);
1450 set_state->se = strata_estimator_create (SE_STRATA_COUNT, 1444 set_state->se = strata_estimator_create (SE_STRATA_COUNT,
1451 SE_IBF_SIZE, SE_IBF_HASH_NUM); 1445 SE_IBF_SIZE, SE_IBF_HASH_NUM);
@@ -1566,15 +1560,15 @@ union_peer_disconnect (struct Operation *op)
1566 GNUNET_MQ_send (op->spec->set->client_mq, 1560 GNUNET_MQ_send (op->spec->set->client_mq,
1567 ev); 1561 ev);
1568 LOG (GNUNET_ERROR_TYPE_WARNING, 1562 LOG (GNUNET_ERROR_TYPE_WARNING,
1569 "other peer disconnected prematurely, phase %u\n", 1563 "other peer disconnected prematurely, phase %u\n",
1570 op->state->phase); 1564 op->state->phase);
1571 _GSS_operation_destroy (op, 1565 _GSS_operation_destroy (op,
1572 GNUNET_YES); 1566 GNUNET_YES);
1573 return; 1567 return;
1574 } 1568 }
1575 // else: the session has already been concluded 1569 // else: the session has already been concluded
1576 LOG (GNUNET_ERROR_TYPE_DEBUG, 1570 LOG (GNUNET_ERROR_TYPE_DEBUG,
1577 "other peer disconnected (finished)\n"); 1571 "other peer disconnected (finished)\n");
1578 if (GNUNET_NO == op->state->client_done_sent) 1572 if (GNUNET_NO == op->state->client_done_sent)
1579 send_done_and_destroy (op); 1573 send_done_and_destroy (op);
1580} 1574}