From 7bdfa2135fd5cb638162dd19356e54ec9702c462 Mon Sep 17 00:00:00 2001 From: Christian Fuchs Date: Mon, 9 Dec 2013 15:48:51 +0000 Subject: towards multipart msging for bloomfilters in set intersection --- src/set/gnunet-service-set_intersection.c | 44 +++++++++++++++++++++++-------- src/set/set_protocol.h | 5 ++++ 2 files changed, 38 insertions(+), 11 deletions(-) (limited to 'src/set') diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 39c94592b..45d670c92 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c @@ -76,6 +76,16 @@ struct OperationState * BF of the set's element. */ struct GNUNET_CONTAINER_BloomFilter *local_bf; + + /** + * for multipart msgs we have to store the bloomfilter-data until we fully sent it. + */ + char * local_bf_data; + + /** + * for multipart msgs we have to store the bloomfilter-data until we fully sent it. + */ + uint32_t local_bf_data_size; /** * Current state of the operation. @@ -351,19 +361,31 @@ send_bloomfilter (struct Operation *op) // send our bloomfilter bf_size = GNUNET_CONTAINER_bloomfilter_get_size (op->state->local_bf); - - ev = GNUNET_MQ_msg_extra (msg, bf_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); - msg->reserved = 0; - msg->sender_element_count = htonl (op->state->my_element_count); - msg->bloomfilter_length = htonl (bf_size); - msg->sender_mutator = htonl (op->spec->salt); - GNUNET_assert (GNUNET_SYSERR != + if ( GNUNET_SERVER_MAX_MESSAGE_SIZE <= bf_size + sizeof(struct BFMessage)) + { + // singlepart + ev = GNUNET_MQ_msg_extra (msg, bf_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); + + GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf); + op->state->local_bf = NULL; + + msg->reserved = 0; + msg->sender_element_count = htonl (op->state->my_element_count); + msg->bloomfilter_length = htonl (bf_size); + msg->bloomfilter_offset = htonl (0); + msg->sender_mutator = htonl (op->spec->salt); + + GNUNET_MQ_send (op->mq, ev); + } + else { + op->state->local_bf_data = (char *)GNUNET_malloc(bf_size); + GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_bloomfilter_get_raw_data (op->state->local_bf, - (char *) &msg[1], + op->state->local_bf_data, bf_size)); - GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf); - op->state->local_bf = NULL; - GNUNET_MQ_send (op->mq, ev); + op->state->local_bf_data_size = bf_size; + send_bloomfilter_multipart (op, 0); + } } diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h index d37551d2e..310cb202c 100644 --- a/src/set/set_protocol.h +++ b/src/set/set_protocol.h @@ -120,6 +120,11 @@ struct BFMessage */ uint32_t bloomfilter_length GNUNET_PACKED; + /** + * offset in the bloolfilter data block, if multipart message + */ + uint32_t bloomfilter_offset GNUNET_PACKED; + /** * rest: the sender's bloomfilter */ -- cgit v1.2.3