aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-service-set_intersection.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-11-27 11:56:28 +0000
committerChristian Grothoff <christian@grothoff.org>2014-11-27 11:56:28 +0000
commitce9b32618b6ee488352ef0eb506c744868145f82 (patch)
treedde0f1de9dfec7d3814a29cfb5b252a79a64d726 /src/set/gnunet-service-set_intersection.c
parent2b0e3f9ba871095d003fc078eee75b5eda6fc8b8 (diff)
downloadgnunet-ce9b32618b6ee488352ef0eb506c744868145f82.tar.gz
gnunet-ce9b32618b6ee488352ef0eb506c744868145f82.zip
clean up internal set API, avoid copying context message needlessly
Diffstat (limited to 'src/set/gnunet-service-set_intersection.c')
-rw-r--r--src/set/gnunet-service-set_intersection.c81
1 files changed, 32 insertions, 49 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index 70c3fb450..734783137 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -362,49 +362,6 @@ fail_intersection_operation (struct Operation *op)
362} 362}
363 363
364 364
365/**
366 * Send a request for the evaluate operation to a remote peer
367 *
368 * @param op operation with the other peer
369 */
370static void
371send_operation_request (struct Operation *op)
372{
373 struct GNUNET_MQ_Envelope *ev;
374 struct OperationRequestMessage *msg;
375
376 ev = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
377 op->spec->context_msg);
378
379 if (NULL == ev)
380 {
381 /* the context message is too large */
382 GNUNET_break (0);
383 GNUNET_SERVER_client_disconnect (op->spec->set->client);
384 return;
385 }
386 msg->operation = htonl (GNUNET_SET_OPERATION_INTERSECTION);
387 msg->app_id = op->spec->app_id;
388 msg->salt = htonl (op->spec->salt);
389 msg->element_count = htonl(op->state->my_element_count);
390
391 GNUNET_MQ_send (op->mq, ev);
392
393 if (NULL != op->spec->context_msg)
394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
395 "sent op request with context message\n");
396 else
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
398 "sent op request without context message\n");
399
400 if (NULL != op->spec->context_msg)
401 {
402 GNUNET_free (op->spec->context_msg);
403 op->spec->context_msg = NULL;
404 }
405}
406
407
408static void 365static void
409send_bloomfilter_multipart (struct Operation *op, 366send_bloomfilter_multipart (struct Operation *op,
410 uint32_t offset) 367 uint32_t offset)
@@ -877,14 +834,20 @@ handle_p2p_done (void *cls,
877 834
878 835
879/** 836/**
880 * Evaluate a union operation with 837 * Initiate a set union operation with a remote peer.
881 * a remote peer.
882 * 838 *
883 * @param op operation to evaluate 839 * @param op operation that is created, should be initialized to
840 * begin the evaluation
841 * @param opaque_context message to be transmitted to the listener
842 * to convince him to accept, may be NULL
884 */ 843 */
885static void 844static void
886intersection_evaluate (struct Operation *op) 845intersection_evaluate (struct Operation *op,
846 const struct GNUNET_MessageHeader *opaque_context)
887{ 847{
848 struct GNUNET_MQ_Envelope *ev;
849 struct OperationRequestMessage *msg;
850
888 op->state = GNUNET_new (struct OperationState); 851 op->state = GNUNET_new (struct OperationState);
889 /* we started the operation, thus we have to send the operation request */ 852 /* we started the operation, thus we have to send the operation request */
890 op->state->phase = PHASE_INITIAL; 853 op->state->phase = PHASE_INITIAL;
@@ -892,8 +855,28 @@ intersection_evaluate (struct Operation *op)
892 op->state->my_element_count = op->spec->set->state->current_set_element_count; 855 op->state->my_element_count = op->spec->set->state->current_set_element_count;
893 856
894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 857 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
895 "evaluating intersection operation"); 858 "Initiating intersection operation evaluation");
896 send_operation_request (op); 859 ev = GNUNET_MQ_msg_nested_mh (msg,
860 GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
861 opaque_context);
862 if (NULL == ev)
863 {
864 /* the context message is too large */
865 GNUNET_break (0);
866 GNUNET_SERVER_client_disconnect (op->spec->set->client);
867 return;
868 }
869 msg->operation = htonl (GNUNET_SET_OPERATION_INTERSECTION);
870 msg->app_id = op->spec->app_id;
871 msg->salt = htonl (op->spec->salt);
872 msg->element_count = htonl(op->state->my_element_count);
873 GNUNET_MQ_send (op->mq, ev);
874 if (NULL != opaque_context)
875 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
876 "sent op request with context message\n");
877 else
878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
879 "sent op request without context message\n");
897} 880}
898 881
899 882