aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-18 16:24:35 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-18 16:24:35 +0000
commita4ae4a97527fc6532aa9b7a0f20d1a2f5d7b73ba (patch)
tree775ece9e1f44a2caf3e39301ca57ee9235d18a46
parent7b62c2bc0012700c43b94e6ec17b5325e84f6961 (diff)
downloadgnunet-a4ae4a97527fc6532aa9b7a0f20d1a2f5d7b73ba.tar.gz
gnunet-a4ae4a97527fc6532aa9b7a0f20d1a2f5d7b73ba.zip
- implemented output mode GNUNET_SET_RESULT_REMOVED in intersection
-rw-r--r--src/set/gnunet-service-set_intersection.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index a12b30c86..1bfda430a 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -157,6 +157,37 @@ struct SetState
157 157
158 158
159/** 159/**
160 * Send a result message to the client indicating
161 * we removed an element
162 *
163 * @param op union operation
164 * @param element element to send
165 */
166static void
167send_client_element (struct Operation *op,
168 struct GNUNET_SET_Element *element)
169{
170 struct GNUNET_MQ_Envelope *ev;
171 struct GNUNET_SET_ResultMessage *rm;
172
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending removed element (size %u) to client\n", element->size);
174 GNUNET_assert (0 != op->spec->client_request_id);
175 ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT);
176 if (NULL == ev)
177 {
178 GNUNET_MQ_discard (ev);
179 GNUNET_break (0);
180 return;
181 }
182 rm->result_status = htons (GNUNET_SET_STATUS_OK);
183 rm->request_id = htonl (op->spec->client_request_id);
184 rm->element_type = element->type;
185 memcpy (&rm[1], element->data, element->size);
186 GNUNET_MQ_send (op->spec->set->client_mq, ev);
187}
188
189
190/**
160 * Alice's version: 191 * Alice's version:
161 * 192 *
162 * fills the contained-elements hashmap with all relevant 193 * fills the contained-elements hashmap with all relevant
@@ -188,8 +219,11 @@ iterator_initialization_by_alice (void *cls,
188 op->spec->salt, 219 op->spec->salt,
189 &mutated_hash); 220 &mutated_hash);
190 if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, 221 if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf,
191 &mutated_hash)) 222 &mutated_hash)){
223 if (GNUNET_SET_RESULT_REMOVED == op->spec->result_mode)
224 send_client_element (op, &ee->element);
192 return GNUNET_YES; 225 return GNUNET_YES;
226 }
193 227
194 op->state->my_element_count++; 228 op->state->my_element_count++;
195 GNUNET_assert (GNUNET_YES == 229 GNUNET_assert (GNUNET_YES ==
@@ -263,6 +297,8 @@ iterator_bf_reduce (void *cls,
263 GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements, 297 GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements,
264 &ee->element_hash, 298 &ee->element_hash,
265 ee)); 299 ee));
300 if (GNUNET_SET_RESULT_REMOVED == op->spec->result_mode)
301 send_client_element (op, &ee->element);
266 } 302 }
267 303
268 return GNUNET_YES; 304 return GNUNET_YES;