diff options
author | t3sserakt <t3ss@posteo.de> | 2019-07-21 20:18:24 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2019-07-21 20:18:24 +0200 |
commit | f096bdce8eaeaabc42f2a015bf29c422b3d25719 (patch) | |
tree | 694c140bd741f7b1c24b5e55e8644002ae53cae4 /src/set | |
parent | dfeef02bf7882cdfb952430cfbdb9793ecd780e2 (diff) | |
parent | 160edc4127f1698cca25d5708157ea3187421596 (diff) | |
download | gnunet-f096bdce8eaeaabc42f2a015bf29c422b3d25719.tar.gz gnunet-f096bdce8eaeaabc42f2a015bf29c422b3d25719.zip |
Merge branch 'cadet-new-options'
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 771 |
1 files changed, 337 insertions, 434 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 71f74594f..5becd7bd9 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -60,7 +60,6 @@ struct LazyCopyRequest | |||
60 | * Cookie identifying the request. | 60 | * Cookie identifying the request. |
61 | */ | 61 | */ |
62 | uint32_t cookie; | 62 | uint32_t cookie; |
63 | |||
64 | }; | 63 | }; |
65 | 64 | ||
66 | 65 | ||
@@ -185,8 +184,7 @@ static uint32_t suggest_id; | |||
185 | static struct Operation * | 184 | static struct Operation * |
186 | get_incoming (uint32_t id) | 185 | get_incoming (uint32_t id) |
187 | { | 186 | { |
188 | for (struct Listener *listener = listener_head; | 187 | for (struct Listener *listener = listener_head; NULL != listener; |
189 | NULL != listener; | ||
190 | listener = listener->next) | 188 | listener = listener->next) |
191 | { | 189 | { |
192 | for (struct Operation *op = listener->op_head; NULL != op; op = op->next) | 190 | for (struct Operation *op = listener->op_head; NULL != op; op = op->next) |
@@ -212,9 +210,7 @@ incoming_destroy (struct Operation *op) | |||
212 | op); | 210 | op); |
213 | if (NULL != (listener = op->listener)) | 211 | if (NULL != (listener = op->listener)) |
214 | { | 212 | { |
215 | GNUNET_CONTAINER_DLL_remove (listener->op_head, | 213 | GNUNET_CONTAINER_DLL_remove (listener->op_head, listener->op_tail, op); |
216 | listener->op_tail, | ||
217 | op); | ||
218 | op->listener = NULL; | 214 | op->listener = NULL; |
219 | } | 215 | } |
220 | if (NULL != op->timeout_task) | 216 | if (NULL != op->timeout_task) |
@@ -246,7 +242,6 @@ struct GarbageContext | |||
246 | * Largest generation for which an operation is still pending. | 242 | * Largest generation for which an operation is still pending. |
247 | */ | 243 | */ |
248 | unsigned int max_op_generation; | 244 | unsigned int max_op_generation; |
249 | |||
250 | }; | 245 | }; |
251 | 246 | ||
252 | 247 | ||
@@ -260,9 +255,7 @@ struct GarbageContext | |||
260 | * @return #GNUNET_OK (continue to iterate) | 255 | * @return #GNUNET_OK (continue to iterate) |
261 | */ | 256 | */ |
262 | static int | 257 | static int |
263 | garbage_collect_cb (void *cls, | 258 | garbage_collect_cb (void *cls, const struct GNUNET_HashCode *key, void *value) |
264 | const struct GNUNET_HashCode *key, | ||
265 | void *value) | ||
266 | { | 259 | { |
267 | //struct GarbageContext *gc = cls; | 260 | //struct GarbageContext *gc = cls; |
268 | //struct ElementEntry *ee = value; | 261 | //struct ElementEntry *ee = value; |
@@ -298,10 +291,10 @@ collect_generation_garbage (struct Set *set) | |||
298 | gc.max_op_generation = 0; | 291 | gc.max_op_generation = 0; |
299 | for (struct Operation *op = set->ops_head; NULL != op; op = op->next) | 292 | for (struct Operation *op = set->ops_head; NULL != op; op = op->next) |
300 | { | 293 | { |
301 | gc.min_op_generation = GNUNET_MIN (gc.min_op_generation, | 294 | gc.min_op_generation = |
302 | op->generation_created); | 295 | GNUNET_MIN (gc.min_op_generation, op->generation_created); |
303 | gc.max_op_generation = GNUNET_MAX (gc.max_op_generation, | 296 | gc.max_op_generation = |
304 | op->generation_created); | 297 | GNUNET_MAX (gc.max_op_generation, op->generation_created); |
305 | } | 298 | } |
306 | gc.map = set->content->elements; | 299 | gc.map = set->content->elements; |
307 | GNUNET_CONTAINER_multihashmap_iterate (set->content->elements, | 300 | GNUNET_CONTAINER_multihashmap_iterate (set->content->elements, |
@@ -324,8 +317,7 @@ is_excluded_generation (unsigned int generation, | |||
324 | unsigned int excluded_size) | 317 | unsigned int excluded_size) |
325 | { | 318 | { |
326 | for (unsigned int i = 0; i < excluded_size; i++) | 319 | for (unsigned int i = 0; i < excluded_size; i++) |
327 | if ( (generation >= excluded[i].start) && | 320 | if ((generation >= excluded[i].start) && (generation < excluded[i].end)) |
328 | (generation < excluded[i].end) ) | ||
329 | return GNUNET_YES; | 321 | return GNUNET_YES; |
330 | return GNUNET_NO; | 322 | return GNUNET_NO; |
331 | } | 323 | } |
@@ -351,9 +343,7 @@ is_element_of_generation (struct ElementEntry *ee, | |||
351 | 343 | ||
352 | GNUNET_assert (NULL != ee->mutations); | 344 | GNUNET_assert (NULL != ee->mutations); |
353 | if (GNUNET_YES == | 345 | if (GNUNET_YES == |
354 | is_excluded_generation (query_generation, | 346 | is_excluded_generation (query_generation, excluded, excluded_size)) |
355 | excluded, | ||
356 | excluded_size)) | ||
357 | { | 347 | { |
358 | GNUNET_break (0); | 348 | GNUNET_break (0); |
359 | return GNUNET_NO; | 349 | return GNUNET_NO; |
@@ -376,9 +366,7 @@ is_element_of_generation (struct ElementEntry *ee, | |||
376 | } | 366 | } |
377 | 367 | ||
378 | if (GNUNET_YES == | 368 | if (GNUNET_YES == |
379 | is_excluded_generation (mut->generation, | 369 | is_excluded_generation (mut->generation, excluded, excluded_size)) |
380 | excluded, | ||
381 | excluded_size)) | ||
382 | { | 370 | { |
383 | /* The generation is excluded (because it belongs to another | 371 | /* The generation is excluded (because it belongs to another |
384 | fork via a lazy copy) and thus mutations aren't considered | 372 | fork via a lazy copy) and thus mutations aren't considered |
@@ -387,12 +375,10 @@ is_element_of_generation (struct ElementEntry *ee, | |||
387 | } | 375 | } |
388 | 376 | ||
389 | /* This would be an inconsistency in how we manage mutations. */ | 377 | /* This would be an inconsistency in how we manage mutations. */ |
390 | if ( (GNUNET_YES == is_present) && | 378 | if ((GNUNET_YES == is_present) && (GNUNET_YES == mut->added)) |
391 | (GNUNET_YES == mut->added) ) | ||
392 | GNUNET_assert (0); | 379 | GNUNET_assert (0); |
393 | /* Likewise. */ | 380 | /* Likewise. */ |
394 | if ( (GNUNET_NO == is_present) && | 381 | if ((GNUNET_NO == is_present) && (GNUNET_NO == mut->added)) |
395 | (GNUNET_NO == mut->added) ) | ||
396 | GNUNET_assert (0); | 382 | GNUNET_assert (0); |
397 | 383 | ||
398 | is_present = mut->added; | 384 | is_present = mut->added; |
@@ -410,8 +396,7 @@ is_element_of_generation (struct ElementEntry *ee, | |||
410 | * @return #GNUNET_YES if the element is in the set, #GNUNET_NO if not | 396 | * @return #GNUNET_YES if the element is in the set, #GNUNET_NO if not |
411 | */ | 397 | */ |
412 | int | 398 | int |
413 | _GSS_is_element_of_operation (struct ElementEntry *ee, | 399 | _GSS_is_element_of_operation (struct ElementEntry *ee, struct Operation *op) |
414 | struct Operation *op) | ||
415 | { | 400 | { |
416 | return is_element_of_generation (ee, | 401 | return is_element_of_generation (ee, |
417 | op->generation_created, | 402 | op->generation_created, |
@@ -434,15 +419,12 @@ _GSS_is_element_of_operation (struct ElementEntry *ee, | |||
434 | * @param gc #GNUNET_YES to perform garbage collection on the set | 419 | * @param gc #GNUNET_YES to perform garbage collection on the set |
435 | */ | 420 | */ |
436 | void | 421 | void |
437 | _GSS_operation_destroy (struct Operation *op, | 422 | _GSS_operation_destroy (struct Operation *op, int gc) |
438 | int gc) | ||
439 | { | 423 | { |
440 | struct Set *set = op->set; | 424 | struct Set *set = op->set; |
441 | struct GNUNET_CADET_Channel *channel; | 425 | struct GNUNET_CADET_Channel *channel; |
442 | 426 | ||
443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying operation %p\n", op); |
444 | "Destroying operation %p\n", | ||
445 | op); | ||
446 | GNUNET_assert (NULL == op->listener); | 428 | GNUNET_assert (NULL == op->listener); |
447 | if (NULL != op->state) | 429 | if (NULL != op->state) |
448 | { | 430 | { |
@@ -451,9 +433,7 @@ _GSS_operation_destroy (struct Operation *op, | |||
451 | } | 433 | } |
452 | if (NULL != set) | 434 | if (NULL != set) |
453 | { | 435 | { |
454 | GNUNET_CONTAINER_DLL_remove (set->ops_head, | 436 | GNUNET_CONTAINER_DLL_remove (set->ops_head, set->ops_tail, op); |
455 | set->ops_tail, | ||
456 | op); | ||
457 | op->set = NULL; | 437 | op->set = NULL; |
458 | } | 438 | } |
459 | if (NULL != op->context_msg) | 439 | if (NULL != op->context_msg) |
@@ -468,8 +448,7 @@ _GSS_operation_destroy (struct Operation *op, | |||
468 | op->channel = NULL; | 448 | op->channel = NULL; |
469 | GNUNET_CADET_channel_destroy (channel); | 449 | GNUNET_CADET_channel_destroy (channel); |
470 | } | 450 | } |
471 | if ( (NULL != set) && | 451 | if ((NULL != set) && (GNUNET_YES == gc)) |
472 | (GNUNET_YES == gc) ) | ||
473 | collect_generation_garbage (set); | 452 | collect_generation_garbage (set); |
474 | /* We rely on the channel end handler to free 'op'. When 'op->channel' was NULL, | 453 | /* We rely on the channel end handler to free 'op'. When 'op->channel' was NULL, |
475 | * there was a channel end handler that will free 'op' on the call stack. */ | 454 | * there was a channel end handler that will free 'op' on the call stack. */ |
@@ -486,8 +465,8 @@ _GSS_operation_destroy (struct Operation *op, | |||
486 | */ | 465 | */ |
487 | static void * | 466 | static void * |
488 | client_connect_cb (void *cls, | 467 | client_connect_cb (void *cls, |
489 | struct GNUNET_SERVICE_Client *c, | 468 | struct GNUNET_SERVICE_Client *c, |
490 | struct GNUNET_MQ_Handle *mq) | 469 | struct GNUNET_MQ_Handle *mq) |
491 | { | 470 | { |
492 | struct ClientState *cs; | 471 | struct ClientState *cs; |
493 | 472 | ||
@@ -537,8 +516,7 @@ client_disconnect_cb (void *cls, | |||
537 | struct Listener *listener; | 516 | struct Listener *listener; |
538 | struct Set *set; | 517 | struct Set *set; |
539 | 518 | ||
540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected, cleaning up\n"); |
541 | "Client disconnected, cleaning up\n"); | ||
542 | if (NULL != (set = cs->set)) | 520 | if (NULL != (set = cs->set)) |
543 | { | 521 | { |
544 | struct SetContent *content = set->content; | 522 | struct SetContent *content = set->content; |
@@ -546,12 +524,10 @@ client_disconnect_cb (void *cls, | |||
546 | struct PendingMutation *pm_current; | 524 | struct PendingMutation *pm_current; |
547 | struct LazyCopyRequest *lcr; | 525 | struct LazyCopyRequest *lcr; |
548 | 526 | ||
549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying client's set\n"); |
550 | "Destroying client's set\n"); | ||
551 | /* Destroy pending set operations */ | 528 | /* Destroy pending set operations */ |
552 | while (NULL != set->ops_head) | 529 | while (NULL != set->ops_head) |
553 | _GSS_operation_destroy (set->ops_head, | 530 | _GSS_operation_destroy (set->ops_head, GNUNET_NO); |
554 | GNUNET_NO); | ||
555 | 531 | ||
556 | /* Destroy operation-specific state */ | 532 | /* Destroy operation-specific state */ |
557 | GNUNET_assert (NULL != set->state); | 533 | GNUNET_assert (NULL != set->state); |
@@ -618,8 +594,7 @@ client_disconnect_cb (void *cls, | |||
618 | 594 | ||
619 | if (NULL != (listener = cs->listener)) | 595 | if (NULL != (listener = cs->listener)) |
620 | { | 596 | { |
621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying client's listener\n"); |
622 | "Destroying client's listener\n"); | ||
623 | GNUNET_CADET_close_port (listener->open_port); | 598 | GNUNET_CADET_close_port (listener->open_port); |
624 | listener->open_port = NULL; | 599 | listener->open_port = NULL; |
625 | while (NULL != (op = listener->op_head)) | 600 | while (NULL != (op = listener->op_head)) |
@@ -630,15 +605,12 @@ client_disconnect_cb (void *cls, | |||
630 | GNUNET_i2s (&op->peer)); | 605 | GNUNET_i2s (&op->peer)); |
631 | incoming_destroy (op); | 606 | incoming_destroy (op); |
632 | } | 607 | } |
633 | GNUNET_CONTAINER_DLL_remove (listener_head, | 608 | GNUNET_CONTAINER_DLL_remove (listener_head, listener_tail, listener); |
634 | listener_tail, | ||
635 | listener); | ||
636 | GNUNET_free (listener); | 609 | GNUNET_free (listener); |
637 | } | 610 | } |
638 | GNUNET_free (cs); | 611 | GNUNET_free (cs); |
639 | num_clients--; | 612 | num_clients--; |
640 | if ( (GNUNET_YES == in_shutdown) && | 613 | if ((GNUNET_YES == in_shutdown) && (0 == num_clients)) |
641 | (0 == num_clients) ) | ||
642 | { | 614 | { |
643 | if (NULL != cadet) | 615 | if (NULL != cadet) |
644 | { | 616 | { |
@@ -658,8 +630,7 @@ client_disconnect_cb (void *cls, | |||
658 | * #GNUNET_SYSERR to destroy the channel | 630 | * #GNUNET_SYSERR to destroy the channel |
659 | */ | 631 | */ |
660 | static int | 632 | static int |
661 | check_incoming_msg (void *cls, | 633 | check_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
662 | const struct OperationRequestMessage *msg) | ||
663 | { | 634 | { |
664 | struct Operation *op = cls; | 635 | struct Operation *op = cls; |
665 | struct Listener *listener = op->listener; | 636 | struct Listener *listener = op->listener; |
@@ -677,14 +648,15 @@ check_incoming_msg (void *cls, | |||
677 | GNUNET_break (0); | 648 | GNUNET_break (0); |
678 | return GNUNET_SYSERR; | 649 | return GNUNET_SYSERR; |
679 | } | 650 | } |
680 | if (listener->operation != (enum GNUNET_SET_OperationType) ntohl (msg->operation)) | 651 | if (listener->operation != |
652 | (enum GNUNET_SET_OperationType) ntohl (msg->operation)) | ||
681 | { | 653 | { |
682 | GNUNET_break_op (0); | 654 | GNUNET_break_op (0); |
683 | return GNUNET_SYSERR; | 655 | return GNUNET_SYSERR; |
684 | } | 656 | } |
685 | nested_context = GNUNET_MQ_extract_nested_mh (msg); | 657 | nested_context = GNUNET_MQ_extract_nested_mh (msg); |
686 | if ( (NULL != nested_context) && | 658 | if ((NULL != nested_context) && |
687 | (ntohs (nested_context->size) > GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE) ) | 659 | (ntohs (nested_context->size) > GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE)) |
688 | { | 660 | { |
689 | GNUNET_break_op (0); | 661 | GNUNET_break_op (0); |
690 | return GNUNET_SYSERR; | 662 | return GNUNET_SYSERR; |
@@ -711,8 +683,7 @@ check_incoming_msg (void *cls, | |||
711 | * #GNUNET_SYSERR to destroy the channel | 683 | * #GNUNET_SYSERR to destroy the channel |
712 | */ | 684 | */ |
713 | static void | 685 | static void |
714 | handle_incoming_msg (void *cls, | 686 | handle_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
715 | const struct OperationRequestMessage *msg) | ||
716 | { | 687 | { |
717 | struct Operation *op = cls; | 688 | struct Operation *op = cls; |
718 | struct Listener *listener = op->listener; | 689 | struct Listener *listener = op->listener; |
@@ -727,10 +698,11 @@ handle_incoming_msg (void *cls, | |||
727 | if (NULL != nested_context) | 698 | if (NULL != nested_context) |
728 | op->context_msg = GNUNET_copy_message (nested_context); | 699 | op->context_msg = GNUNET_copy_message (nested_context); |
729 | op->remote_element_count = ntohl (msg->element_count); | 700 | op->remote_element_count = ntohl (msg->element_count); |
730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 701 | GNUNET_log ( |
731 | "Received P2P operation request (op %u, port %s) for active listener\n", | 702 | GNUNET_ERROR_TYPE_DEBUG, |
732 | (uint32_t) ntohl (msg->operation), | 703 | "Received P2P operation request (op %u, port %s) for active listener\n", |
733 | GNUNET_h2s (&op->listener->app_id)); | 704 | (uint32_t) ntohl (msg->operation), |
705 | GNUNET_h2s (&op->listener->app_id)); | ||
734 | GNUNET_assert (0 == op->suggest_id); | 706 | GNUNET_assert (0 == op->suggest_id); |
735 | if (0 == suggest_id) | 707 | if (0 == suggest_id) |
736 | suggest_id++; | 708 | suggest_id++; |
@@ -741,15 +713,15 @@ handle_incoming_msg (void *cls, | |||
741 | env = GNUNET_MQ_msg_nested_mh (cmsg, | 713 | env = GNUNET_MQ_msg_nested_mh (cmsg, |
742 | GNUNET_MESSAGE_TYPE_SET_REQUEST, | 714 | GNUNET_MESSAGE_TYPE_SET_REQUEST, |
743 | op->context_msg); | 715 | op->context_msg); |
744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 716 | GNUNET_log ( |
745 | "Suggesting incoming request with accept id %u to listener %p of client %p\n", | 717 | GNUNET_ERROR_TYPE_DEBUG, |
746 | op->suggest_id, | 718 | "Suggesting incoming request with accept id %u to listener %p of client %p\n", |
747 | listener, | 719 | op->suggest_id, |
748 | listener->cs); | 720 | listener, |
721 | listener->cs); | ||
749 | cmsg->accept_id = htonl (op->suggest_id); | 722 | cmsg->accept_id = htonl (op->suggest_id); |
750 | cmsg->peer_id = op->peer; | 723 | cmsg->peer_id = op->peer; |
751 | GNUNET_MQ_send (listener->cs->mq, | 724 | GNUNET_MQ_send (listener->cs->mq, env); |
752 | env); | ||
753 | /* NOTE: GNUNET_CADET_receive_done() will be called in | 725 | /* NOTE: GNUNET_CADET_receive_done() will be called in |
754 | #handle_client_accept() */ | 726 | #handle_client_accept() */ |
755 | } | 727 | } |
@@ -762,8 +734,7 @@ handle_incoming_msg (void *cls, | |||
762 | * @param msg message specifying the change | 734 | * @param msg message specifying the change |
763 | */ | 735 | */ |
764 | static void | 736 | static void |
765 | execute_add (struct Set *set, | 737 | execute_add (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
766 | const struct GNUNET_SET_ElementMessage *msg) | ||
767 | { | 738 | { |
768 | struct GNUNET_SET_Element el; | 739 | struct GNUNET_SET_Element el; |
769 | struct ElementEntry *ee; | 740 | struct ElementEntry *ee; |
@@ -773,10 +744,8 @@ execute_add (struct Set *set, | |||
773 | el.size = ntohs (msg->header.size) - sizeof (*msg); | 744 | el.size = ntohs (msg->header.size) - sizeof (*msg); |
774 | el.data = &msg[1]; | 745 | el.data = &msg[1]; |
775 | el.element_type = ntohs (msg->element_type); | 746 | el.element_type = ntohs (msg->element_type); |
776 | GNUNET_SET_element_hash (&el, | 747 | GNUNET_SET_element_hash (&el, &hash); |
777 | &hash); | 748 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, &hash); |
778 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, | ||
779 | &hash); | ||
780 | if (NULL == ee) | 749 | if (NULL == ee) |
781 | { | 750 | { |
782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -785,9 +754,7 @@ execute_add (struct Set *set, | |||
785 | el.size); | 754 | el.size); |
786 | ee = GNUNET_malloc (el.size + sizeof (*ee)); | 755 | ee = GNUNET_malloc (el.size + sizeof (*ee)); |
787 | ee->element.size = el.size; | 756 | ee->element.size = el.size; |
788 | GNUNET_memcpy (&ee[1], | 757 | GNUNET_memcpy (&ee[1], el.data, el.size); |
789 | el.data, | ||
790 | el.size); | ||
791 | ee->element.data = &ee[1]; | 758 | ee->element.data = &ee[1]; |
792 | ee->element.element_type = el.element_type; | 759 | ee->element.element_type = el.element_type; |
793 | ee->remote = GNUNET_NO; | 760 | ee->remote = GNUNET_NO; |
@@ -795,10 +762,11 @@ execute_add (struct Set *set, | |||
795 | ee->mutations_size = 0; | 762 | ee->mutations_size = 0; |
796 | ee->element_hash = hash; | 763 | ee->element_hash = hash; |
797 | GNUNET_break (GNUNET_YES == | 764 | GNUNET_break (GNUNET_YES == |
798 | GNUNET_CONTAINER_multihashmap_put (set->content->elements, | 765 | GNUNET_CONTAINER_multihashmap_put ( |
799 | &ee->element_hash, | 766 | set->content->elements, |
800 | ee, | 767 | &ee->element_hash, |
801 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 768 | ee, |
769 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
802 | } | 770 | } |
803 | else if (GNUNET_YES == | 771 | else if (GNUNET_YES == |
804 | is_element_of_generation (ee, | 772 | is_element_of_generation (ee, |
@@ -816,16 +784,11 @@ execute_add (struct Set *set, | |||
816 | } | 784 | } |
817 | 785 | ||
818 | { | 786 | { |
819 | struct MutationEvent mut = { | 787 | struct MutationEvent mut = {.generation = set->current_generation, |
820 | .generation = set->current_generation, | 788 | .added = GNUNET_YES}; |
821 | .added = GNUNET_YES | 789 | GNUNET_array_append (ee->mutations, ee->mutations_size, mut); |
822 | }; | ||
823 | GNUNET_array_append (ee->mutations, | ||
824 | ee->mutations_size, | ||
825 | mut); | ||
826 | } | 790 | } |
827 | set->vt->add (set->state, | 791 | set->vt->add (set->state, ee); |
828 | ee); | ||
829 | } | 792 | } |
830 | 793 | ||
831 | 794 | ||
@@ -836,8 +799,7 @@ execute_add (struct Set *set, | |||
836 | * @param msg message specifying the change | 799 | * @param msg message specifying the change |
837 | */ | 800 | */ |
838 | static void | 801 | static void |
839 | execute_remove (struct Set *set, | 802 | execute_remove (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
840 | const struct GNUNET_SET_ElementMessage *msg) | ||
841 | { | 803 | { |
842 | struct GNUNET_SET_Element el; | 804 | struct GNUNET_SET_Element el; |
843 | struct ElementEntry *ee; | 805 | struct ElementEntry *ee; |
@@ -848,8 +810,7 @@ execute_remove (struct Set *set, | |||
848 | el.data = &msg[1]; | 810 | el.data = &msg[1]; |
849 | el.element_type = ntohs (msg->element_type); | 811 | el.element_type = ntohs (msg->element_type); |
850 | GNUNET_SET_element_hash (&el, &hash); | 812 | GNUNET_SET_element_hash (&el, &hash); |
851 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, | 813 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, &hash); |
852 | &hash); | ||
853 | if (NULL == ee) | 814 | if (NULL == ee) |
854 | { | 815 | { |
855 | /* Client tried to remove non-existing element. */ | 816 | /* Client tried to remove non-existing element. */ |
@@ -858,11 +819,10 @@ execute_remove (struct Set *set, | |||
858 | el.size); | 819 | el.size); |
859 | return; | 820 | return; |
860 | } | 821 | } |
861 | if (GNUNET_NO == | 822 | if (GNUNET_NO == is_element_of_generation (ee, |
862 | is_element_of_generation (ee, | 823 | set->current_generation, |
863 | set->current_generation, | 824 | set->excluded_generations, |
864 | set->excluded_generations, | 825 | set->excluded_generations_size)) |
865 | set->excluded_generations_size)) | ||
866 | { | 826 | { |
867 | /* Client tried to remove element twice */ | 827 | /* Client tried to remove element twice */ |
868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -872,21 +832,16 @@ execute_remove (struct Set *set, | |||
872 | } | 832 | } |
873 | else | 833 | else |
874 | { | 834 | { |
875 | struct MutationEvent mut = { | 835 | struct MutationEvent mut = {.generation = set->current_generation, |
876 | .generation = set->current_generation, | 836 | .added = GNUNET_NO}; |
877 | .added = GNUNET_NO | ||
878 | }; | ||
879 | 837 | ||
880 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
881 | "Client removes element of size %u\n", | 839 | "Client removes element of size %u\n", |
882 | el.size); | 840 | el.size); |
883 | 841 | ||
884 | GNUNET_array_append (ee->mutations, | 842 | GNUNET_array_append (ee->mutations, ee->mutations_size, mut); |
885 | ee->mutations_size, | ||
886 | mut); | ||
887 | } | 843 | } |
888 | set->vt->remove (set->state, | 844 | set->vt->remove (set->state, ee); |
889 | ee); | ||
890 | } | 845 | } |
891 | 846 | ||
892 | 847 | ||
@@ -897,19 +852,18 @@ execute_remove (struct Set *set, | |||
897 | * @param msg specification of what to change | 852 | * @param msg specification of what to change |
898 | */ | 853 | */ |
899 | static void | 854 | static void |
900 | execute_mutation (struct Set *set, | 855 | execute_mutation (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
901 | const struct GNUNET_SET_ElementMessage *msg) | ||
902 | { | 856 | { |
903 | switch (ntohs (msg->header.type)) | 857 | switch (ntohs (msg->header.type)) |
904 | { | 858 | { |
905 | case GNUNET_MESSAGE_TYPE_SET_ADD: | 859 | case GNUNET_MESSAGE_TYPE_SET_ADD: |
906 | execute_add (set, msg); | 860 | execute_add (set, msg); |
907 | break; | 861 | break; |
908 | case GNUNET_MESSAGE_TYPE_SET_REMOVE: | 862 | case GNUNET_MESSAGE_TYPE_SET_REMOVE: |
909 | execute_remove (set, msg); | 863 | execute_remove (set, msg); |
910 | break; | 864 | break; |
911 | default: | 865 | default: |
912 | GNUNET_break (0); | 866 | GNUNET_break (0); |
913 | } | 867 | } |
914 | } | 868 | } |
915 | 869 | ||
@@ -935,8 +889,7 @@ execute_delayed_mutations (struct Set *set) | |||
935 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 889 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
936 | "Executing pending mutation on %p.\n", | 890 | "Executing pending mutation on %p.\n", |
937 | pm->set); | 891 | pm->set); |
938 | execute_mutation (pm->set, | 892 | execute_mutation (pm->set, pm->msg); |
939 | pm->msg); | ||
940 | GNUNET_free (pm->msg); | 893 | GNUNET_free (pm->msg); |
941 | GNUNET_free (pm); | 894 | GNUNET_free (pm); |
942 | } | 895 | } |
@@ -965,15 +918,14 @@ send_client_element (struct Set *set) | |||
965 | struct GNUNET_SET_IterResponseMessage *msg; | 918 | struct GNUNET_SET_IterResponseMessage *msg; |
966 | 919 | ||
967 | GNUNET_assert (NULL != set->iter); | 920 | GNUNET_assert (NULL != set->iter); |
968 | do { | 921 | do |
922 | { | ||
969 | ret = GNUNET_CONTAINER_multihashmap_iterator_next (set->iter, | 923 | ret = GNUNET_CONTAINER_multihashmap_iterator_next (set->iter, |
970 | NULL, | 924 | NULL, |
971 | (const void **) &ee); | 925 | (const void **) &ee); |
972 | if (GNUNET_NO == ret) | 926 | if (GNUNET_NO == ret) |
973 | { | 927 | { |
974 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 928 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration on %p done.\n", set); |
975 | "Iteration on %p done.\n", | ||
976 | set); | ||
977 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ITER_DONE); | 929 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ITER_DONE); |
978 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); | 930 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); |
979 | set->iter = NULL; | 931 | set->iter = NULL; |
@@ -981,8 +933,7 @@ send_client_element (struct Set *set) | |||
981 | GNUNET_assert (set->content->iterator_count > 0); | 933 | GNUNET_assert (set->content->iterator_count > 0); |
982 | set->content->iterator_count--; | 934 | set->content->iterator_count--; |
983 | execute_delayed_mutations (set); | 935 | execute_delayed_mutations (set); |
984 | GNUNET_MQ_send (set->cs->mq, | 936 | GNUNET_MQ_send (set->cs->mq, ev); |
985 | ev); | ||
986 | return; | 937 | return; |
987 | } | 938 | } |
988 | GNUNET_assert (NULL != ee); | 939 | GNUNET_assert (NULL != ee); |
@@ -997,13 +948,10 @@ send_client_element (struct Set *set) | |||
997 | ev = GNUNET_MQ_msg_extra (msg, | 948 | ev = GNUNET_MQ_msg_extra (msg, |
998 | ee->element.size, | 949 | ee->element.size, |
999 | GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT); | 950 | GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT); |
1000 | GNUNET_memcpy (&msg[1], | 951 | GNUNET_memcpy (&msg[1], ee->element.data, ee->element.size); |
1001 | ee->element.data, | ||
1002 | ee->element.size); | ||
1003 | msg->element_type = htons (ee->element.element_type); | 952 | msg->element_type = htons (ee->element.element_type); |
1004 | msg->iteration_id = htons (set->iteration_id); | 953 | msg->iteration_id = htons (set->iteration_id); |
1005 | GNUNET_MQ_send (set->cs->mq, | 954 | GNUNET_MQ_send (set->cs->mq, ev); |
1006 | ev); | ||
1007 | } | 955 | } |
1008 | 956 | ||
1009 | 957 | ||
@@ -1017,8 +965,7 @@ send_client_element (struct Set *set) | |||
1017 | * @param m message sent by the client | 965 | * @param m message sent by the client |
1018 | */ | 966 | */ |
1019 | static void | 967 | static void |
1020 | handle_client_iterate (void *cls, | 968 | handle_client_iterate (void *cls, const struct GNUNET_MessageHeader *m) |
1021 | const struct GNUNET_MessageHeader *m) | ||
1022 | { | 969 | { |
1023 | struct ClientState *cs = cls; | 970 | struct ClientState *cs = cls; |
1024 | struct Set *set; | 971 | struct Set *set; |
@@ -1044,7 +991,8 @@ handle_client_iterate (void *cls, | |||
1044 | GNUNET_CONTAINER_multihashmap_size (set->content->elements)); | 991 | GNUNET_CONTAINER_multihashmap_size (set->content->elements)); |
1045 | GNUNET_SERVICE_client_continue (cs->client); | 992 | GNUNET_SERVICE_client_continue (cs->client); |
1046 | set->content->iterator_count++; | 993 | set->content->iterator_count++; |
1047 | set->iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->content->elements); | 994 | set->iter = |
995 | GNUNET_CONTAINER_multihashmap_iterator_create (set->content->elements); | ||
1048 | set->iter_generation = set->current_generation; | 996 | set->iter_generation = set->current_generation; |
1049 | send_client_element (set); | 997 | send_client_element (set); |
1050 | } | 998 | } |
@@ -1059,8 +1007,7 @@ handle_client_iterate (void *cls, | |||
1059 | * @param m message sent by the client | 1007 | * @param m message sent by the client |
1060 | */ | 1008 | */ |
1061 | static void | 1009 | static void |
1062 | handle_client_create_set (void *cls, | 1010 | handle_client_create_set (void *cls, const struct GNUNET_SET_CreateMessage *msg) |
1063 | const struct GNUNET_SET_CreateMessage *msg) | ||
1064 | { | 1011 | { |
1065 | struct ClientState *cs = cls; | 1012 | struct ClientState *cs = cls; |
1066 | struct Set *set; | 1013 | struct Set *set; |
@@ -1101,8 +1048,7 @@ handle_client_create_set (void *cls, | |||
1101 | } | 1048 | } |
1102 | set->content = GNUNET_new (struct SetContent); | 1049 | set->content = GNUNET_new (struct SetContent); |
1103 | set->content->refcount = 1; | 1050 | set->content->refcount = 1; |
1104 | set->content->elements = GNUNET_CONTAINER_multihashmap_create (1, | 1051 | set->content->elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
1105 | GNUNET_YES); | ||
1106 | set->cs = cs; | 1052 | set->cs = cs; |
1107 | cs->set = set; | 1053 | cs->set = set; |
1108 | GNUNET_SERVICE_client_continue (cs->client); | 1054 | GNUNET_SERVICE_client_continue (cs->client); |
@@ -1154,22 +1100,17 @@ channel_new_cb (void *cls, | |||
1154 | struct Listener *listener = cls; | 1100 | struct Listener *listener = cls; |
1155 | struct Operation *op; | 1101 | struct Operation *op; |
1156 | 1102 | ||
1157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New incoming channel\n"); |
1158 | "New incoming channel\n"); | ||
1159 | op = GNUNET_new (struct Operation); | 1104 | op = GNUNET_new (struct Operation); |
1160 | op->listener = listener; | 1105 | op->listener = listener; |
1161 | op->peer = *source; | 1106 | op->peer = *source; |
1162 | op->channel = channel; | 1107 | op->channel = channel; |
1163 | op->mq = GNUNET_CADET_get_mq (op->channel); | 1108 | op->mq = GNUNET_CADET_get_mq (op->channel); |
1164 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 1109 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
1165 | UINT32_MAX); | 1110 | op->timeout_task = GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT, |
1166 | op->timeout_task | 1111 | &incoming_timeout_cb, |
1167 | = GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT, | 1112 | op); |
1168 | &incoming_timeout_cb, | 1113 | GNUNET_CONTAINER_DLL_insert (listener->op_head, listener->op_tail, op); |
1169 | op); | ||
1170 | GNUNET_CONTAINER_DLL_insert (listener->op_head, | ||
1171 | listener->op_tail, | ||
1172 | op); | ||
1173 | return op; | 1114 | return op; |
1174 | } | 1115 | } |
1175 | 1116 | ||
@@ -1191,8 +1132,7 @@ channel_new_cb (void *cls, | |||
1191 | * @param channel connection to the other end (henceforth invalid) | 1132 | * @param channel connection to the other end (henceforth invalid) |
1192 | */ | 1133 | */ |
1193 | static void | 1134 | static void |
1194 | channel_end_cb (void *channel_ctx, | 1135 | channel_end_cb (void *channel_ctx, const struct GNUNET_CADET_Channel *channel) |
1195 | const struct GNUNET_CADET_Channel *channel) | ||
1196 | { | 1136 | { |
1197 | struct Operation *op = channel_ctx; | 1137 | struct Operation *op = channel_ctx; |
1198 | 1138 | ||
@@ -1211,8 +1151,7 @@ _GSS_operation_destroy2 (struct Operation *op) | |||
1211 | { | 1151 | { |
1212 | struct GNUNET_CADET_Channel *channel; | 1152 | struct GNUNET_CADET_Channel *channel; |
1213 | 1153 | ||
1214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel_end_cb called\n"); |
1215 | "channel_end_cb called\n"); | ||
1216 | if (NULL != (channel = op->channel)) | 1155 | if (NULL != (channel = op->channel)) |
1217 | { | 1156 | { |
1218 | /* This will free op; called conditionally as this helper function | 1157 | /* This will free op; called conditionally as this helper function |
@@ -1228,8 +1167,7 @@ _GSS_operation_destroy2 (struct Operation *op) | |||
1228 | if (NULL != op->set) | 1167 | if (NULL != op->set) |
1229 | op->set->vt->channel_death (op); | 1168 | op->set->vt->channel_death (op); |
1230 | else | 1169 | else |
1231 | _GSS_operation_destroy (op, | 1170 | _GSS_operation_destroy (op, GNUNET_YES); |
1232 | GNUNET_YES); | ||
1233 | GNUNET_free (op); | 1171 | GNUNET_free (op); |
1234 | } | 1172 | } |
1235 | 1173 | ||
@@ -1264,77 +1202,75 @@ channel_window_cb (void *cls, | |||
1264 | * @param msg message sent by the client | 1202 | * @param msg message sent by the client |
1265 | */ | 1203 | */ |
1266 | static void | 1204 | static void |
1267 | handle_client_listen (void *cls, | 1205 | handle_client_listen (void *cls, const struct GNUNET_SET_ListenMessage *msg) |
1268 | const struct GNUNET_SET_ListenMessage *msg) | ||
1269 | { | 1206 | { |
1270 | struct ClientState *cs = cls; | 1207 | struct ClientState *cs = cls; |
1271 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = { | 1208 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1272 | GNUNET_MQ_hd_var_size (incoming_msg, | 1209 | {GNUNET_MQ_hd_var_size (incoming_msg, |
1273 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, | 1210 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, |
1274 | struct OperationRequestMessage, | 1211 | struct OperationRequestMessage, |
1275 | NULL), | 1212 | NULL), |
1276 | GNUNET_MQ_hd_var_size (union_p2p_ibf, | 1213 | GNUNET_MQ_hd_var_size (union_p2p_ibf, |
1277 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, | 1214 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, |
1278 | struct IBFMessage, | 1215 | struct IBFMessage, |
1279 | NULL), | 1216 | NULL), |
1280 | GNUNET_MQ_hd_var_size (union_p2p_elements, | 1217 | GNUNET_MQ_hd_var_size (union_p2p_elements, |
1281 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, | 1218 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, |
1282 | struct GNUNET_SET_ElementMessage, | 1219 | struct GNUNET_SET_ElementMessage, |
1283 | NULL), | 1220 | NULL), |
1284 | GNUNET_MQ_hd_var_size (union_p2p_offer, | 1221 | GNUNET_MQ_hd_var_size (union_p2p_offer, |
1285 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, | 1222 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, |
1286 | struct GNUNET_MessageHeader, | 1223 | struct GNUNET_MessageHeader, |
1287 | NULL), | 1224 | NULL), |
1288 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, | 1225 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, |
1289 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, | 1226 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, |
1290 | struct InquiryMessage, | 1227 | struct InquiryMessage, |
1291 | NULL), | 1228 | NULL), |
1292 | GNUNET_MQ_hd_var_size (union_p2p_demand, | 1229 | GNUNET_MQ_hd_var_size (union_p2p_demand, |
1293 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, | 1230 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, |
1294 | struct GNUNET_MessageHeader, | 1231 | struct GNUNET_MessageHeader, |
1295 | NULL), | 1232 | NULL), |
1296 | GNUNET_MQ_hd_fixed_size (union_p2p_done, | 1233 | GNUNET_MQ_hd_fixed_size (union_p2p_done, |
1297 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, | 1234 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, |
1298 | struct GNUNET_MessageHeader, | 1235 | struct GNUNET_MessageHeader, |
1299 | NULL), | 1236 | NULL), |
1300 | GNUNET_MQ_hd_fixed_size (union_p2p_over, | 1237 | GNUNET_MQ_hd_fixed_size (union_p2p_over, |
1301 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, | 1238 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, |
1302 | struct GNUNET_MessageHeader, | 1239 | struct GNUNET_MessageHeader, |
1303 | NULL), | 1240 | NULL), |
1304 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, | 1241 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, |
1305 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, | 1242 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, |
1306 | struct GNUNET_MessageHeader, | 1243 | struct GNUNET_MessageHeader, |
1307 | NULL), | 1244 | NULL), |
1308 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, | 1245 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, |
1309 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, | 1246 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, |
1310 | struct GNUNET_MessageHeader, | 1247 | struct GNUNET_MessageHeader, |
1311 | NULL), | 1248 | NULL), |
1312 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1249 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1313 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, | 1250 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, |
1314 | struct StrataEstimatorMessage, | 1251 | struct StrataEstimatorMessage, |
1315 | NULL), | 1252 | NULL), |
1316 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1253 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1317 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, | 1254 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, |
1318 | struct StrataEstimatorMessage, | 1255 | struct StrataEstimatorMessage, |
1319 | NULL), | 1256 | NULL), |
1320 | GNUNET_MQ_hd_var_size (union_p2p_full_element, | 1257 | GNUNET_MQ_hd_var_size (union_p2p_full_element, |
1321 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, | 1258 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, |
1322 | struct GNUNET_SET_ElementMessage, | 1259 | struct GNUNET_SET_ElementMessage, |
1323 | NULL), | 1260 | NULL), |
1324 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, | 1261 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, |
1325 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, | 1262 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, |
1326 | struct IntersectionElementInfoMessage, | 1263 | struct IntersectionElementInfoMessage, |
1327 | NULL), | 1264 | NULL), |
1328 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, | 1265 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, |
1329 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, | 1266 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, |
1330 | struct BFMessage, | 1267 | struct BFMessage, |
1331 | NULL), | 1268 | NULL), |
1332 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, | 1269 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, |
1333 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, | 1270 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, |
1334 | struct IntersectionDoneMessage, | 1271 | struct IntersectionDoneMessage, |
1335 | NULL), | 1272 | NULL), |
1336 | GNUNET_MQ_handler_end () | 1273 | GNUNET_MQ_handler_end ()}; |
1337 | }; | ||
1338 | struct Listener *listener; | 1274 | struct Listener *listener; |
1339 | 1275 | ||
1340 | if (NULL != cs->listener) | 1276 | if (NULL != cs->listener) |
@@ -1349,21 +1285,18 @@ handle_client_listen (void *cls, | |||
1349 | cs->listener = listener; | 1285 | cs->listener = listener; |
1350 | listener->app_id = msg->app_id; | 1286 | listener->app_id = msg->app_id; |
1351 | listener->operation = (enum GNUNET_SET_OperationType) ntohl (msg->operation); | 1287 | listener->operation = (enum GNUNET_SET_OperationType) ntohl (msg->operation); |
1352 | GNUNET_CONTAINER_DLL_insert (listener_head, | 1288 | GNUNET_CONTAINER_DLL_insert (listener_head, listener_tail, listener); |
1353 | listener_tail, | ||
1354 | listener); | ||
1355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1356 | "New listener created (op %u, port %s)\n", | 1290 | "New listener created (op %u, port %s)\n", |
1357 | listener->operation, | 1291 | listener->operation, |
1358 | GNUNET_h2s (&listener->app_id)); | 1292 | GNUNET_h2s (&listener->app_id)); |
1359 | listener->open_port | 1293 | listener->open_port = GNUNET_CADET_open_port (cadet, |
1360 | = GNUNET_CADET_open_port (cadet, | 1294 | &msg->app_id, |
1361 | &msg->app_id, | 1295 | &channel_new_cb, |
1362 | &channel_new_cb, | 1296 | listener, |
1363 | listener, | 1297 | &channel_window_cb, |
1364 | &channel_window_cb, | 1298 | &channel_end_cb, |
1365 | &channel_end_cb, | 1299 | cadet_handlers); |
1366 | cadet_handlers); | ||
1367 | GNUNET_SERVICE_client_continue (cs->client); | 1300 | GNUNET_SERVICE_client_continue (cs->client); |
1368 | } | 1301 | } |
1369 | 1302 | ||
@@ -1376,8 +1309,7 @@ handle_client_listen (void *cls, | |||
1376 | * @param msg message sent by the client | 1309 | * @param msg message sent by the client |
1377 | */ | 1310 | */ |
1378 | static void | 1311 | static void |
1379 | handle_client_reject (void *cls, | 1312 | handle_client_reject (void *cls, const struct GNUNET_SET_RejectMessage *msg) |
1380 | const struct GNUNET_SET_RejectMessage *msg) | ||
1381 | { | 1313 | { |
1382 | struct ClientState *cs = cls; | 1314 | struct ClientState *cs = cls; |
1383 | struct Operation *op; | 1315 | struct Operation *op; |
@@ -1409,8 +1341,7 @@ handle_client_reject (void *cls, | |||
1409 | * @param msg message sent by the client | 1341 | * @param msg message sent by the client |
1410 | */ | 1342 | */ |
1411 | static int | 1343 | static int |
1412 | check_client_mutation (void *cls, | 1344 | check_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
1413 | const struct GNUNET_SET_ElementMessage *msg) | ||
1414 | { | 1345 | { |
1415 | /* NOTE: Technically, we should probably check with the | 1346 | /* NOTE: Technically, we should probably check with the |
1416 | block library whether the element we are given is well-formed */ | 1347 | block library whether the element we are given is well-formed */ |
@@ -1425,8 +1356,7 @@ check_client_mutation (void *cls, | |||
1425 | * @param msg message sent by the client | 1356 | * @param msg message sent by the client |
1426 | */ | 1357 | */ |
1427 | static void | 1358 | static void |
1428 | handle_client_mutation (void *cls, | 1359 | handle_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
1429 | const struct GNUNET_SET_ElementMessage *msg) | ||
1430 | { | 1360 | { |
1431 | struct ClientState *cs = cls; | 1361 | struct ClientState *cs = cls; |
1432 | struct Set *set; | 1362 | struct Set *set; |
@@ -1444,20 +1374,18 @@ handle_client_mutation (void *cls, | |||
1444 | { | 1374 | { |
1445 | struct PendingMutation *pm; | 1375 | struct PendingMutation *pm; |
1446 | 1376 | ||
1447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling mutation on set\n"); |
1448 | "Scheduling mutation on set\n"); | ||
1449 | pm = GNUNET_new (struct PendingMutation); | 1378 | pm = GNUNET_new (struct PendingMutation); |
1450 | pm->msg = (struct GNUNET_SET_ElementMessage *) GNUNET_copy_message (&msg->header); | 1379 | pm->msg = |
1380 | (struct GNUNET_SET_ElementMessage *) GNUNET_copy_message (&msg->header); | ||
1451 | pm->set = set; | 1381 | pm->set = set; |
1452 | GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head, | 1382 | GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head, |
1453 | set->content->pending_mutations_tail, | 1383 | set->content->pending_mutations_tail, |
1454 | pm); | 1384 | pm); |
1455 | return; | 1385 | return; |
1456 | } | 1386 | } |
1457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing mutation on set\n"); |
1458 | "Executing mutation on set\n"); | 1388 | execute_mutation (set, msg); |
1459 | execute_mutation (set, | ||
1460 | msg); | ||
1461 | } | 1389 | } |
1462 | 1390 | ||
1463 | 1391 | ||
@@ -1501,8 +1429,7 @@ advance_generation (struct Set *set) | |||
1501 | * @return #GNUNET_OK if the message is well-formed | 1429 | * @return #GNUNET_OK if the message is well-formed |
1502 | */ | 1430 | */ |
1503 | static int | 1431 | static int |
1504 | check_client_evaluate (void *cls, | 1432 | check_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
1505 | const struct GNUNET_SET_EvaluateMessage *msg) | ||
1506 | { | 1433 | { |
1507 | /* FIXME: suboptimal, even if the context below could be NULL, | 1434 | /* FIXME: suboptimal, even if the context below could be NULL, |
1508 | there are malformed messages this does not check for... */ | 1435 | there are malformed messages this does not check for... */ |
@@ -1519,78 +1446,76 @@ check_client_evaluate (void *cls, | |||
1519 | * @param msg message sent by the client | 1446 | * @param msg message sent by the client |
1520 | */ | 1447 | */ |
1521 | static void | 1448 | static void |
1522 | handle_client_evaluate (void *cls, | 1449 | handle_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
1523 | const struct GNUNET_SET_EvaluateMessage *msg) | ||
1524 | { | 1450 | { |
1525 | struct ClientState *cs = cls; | 1451 | struct ClientState *cs = cls; |
1526 | struct Operation *op = GNUNET_new (struct Operation); | 1452 | struct Operation *op = GNUNET_new (struct Operation); |
1527 | const struct GNUNET_MQ_MessageHandler cadet_handlers[] = { | 1453 | const struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1528 | GNUNET_MQ_hd_var_size (incoming_msg, | 1454 | {GNUNET_MQ_hd_var_size (incoming_msg, |
1529 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, | 1455 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, |
1530 | struct OperationRequestMessage, | 1456 | struct OperationRequestMessage, |
1531 | op), | 1457 | op), |
1532 | GNUNET_MQ_hd_var_size (union_p2p_ibf, | 1458 | GNUNET_MQ_hd_var_size (union_p2p_ibf, |
1533 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, | 1459 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, |
1534 | struct IBFMessage, | 1460 | struct IBFMessage, |
1535 | op), | 1461 | op), |
1536 | GNUNET_MQ_hd_var_size (union_p2p_elements, | 1462 | GNUNET_MQ_hd_var_size (union_p2p_elements, |
1537 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, | 1463 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, |
1538 | struct GNUNET_SET_ElementMessage, | 1464 | struct GNUNET_SET_ElementMessage, |
1539 | op), | 1465 | op), |
1540 | GNUNET_MQ_hd_var_size (union_p2p_offer, | 1466 | GNUNET_MQ_hd_var_size (union_p2p_offer, |
1541 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, | 1467 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, |
1542 | struct GNUNET_MessageHeader, | 1468 | struct GNUNET_MessageHeader, |
1543 | op), | 1469 | op), |
1544 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, | 1470 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, |
1545 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, | 1471 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, |
1546 | struct InquiryMessage, | 1472 | struct InquiryMessage, |
1547 | op), | 1473 | op), |
1548 | GNUNET_MQ_hd_var_size (union_p2p_demand, | 1474 | GNUNET_MQ_hd_var_size (union_p2p_demand, |
1549 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, | 1475 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, |
1550 | struct GNUNET_MessageHeader, | 1476 | struct GNUNET_MessageHeader, |
1551 | op), | 1477 | op), |
1552 | GNUNET_MQ_hd_fixed_size (union_p2p_done, | 1478 | GNUNET_MQ_hd_fixed_size (union_p2p_done, |
1553 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, | 1479 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, |
1554 | struct GNUNET_MessageHeader, | 1480 | struct GNUNET_MessageHeader, |
1555 | op), | 1481 | op), |
1556 | GNUNET_MQ_hd_fixed_size (union_p2p_over, | 1482 | GNUNET_MQ_hd_fixed_size (union_p2p_over, |
1557 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, | 1483 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, |
1558 | struct GNUNET_MessageHeader, | 1484 | struct GNUNET_MessageHeader, |
1559 | op), | 1485 | op), |
1560 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, | 1486 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, |
1561 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, | 1487 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, |
1562 | struct GNUNET_MessageHeader, | 1488 | struct GNUNET_MessageHeader, |
1563 | op), | 1489 | op), |
1564 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, | 1490 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, |
1565 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, | 1491 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, |
1566 | struct GNUNET_MessageHeader, | 1492 | struct GNUNET_MessageHeader, |
1567 | op), | 1493 | op), |
1568 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1494 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1569 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, | 1495 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, |
1570 | struct StrataEstimatorMessage, | 1496 | struct StrataEstimatorMessage, |
1571 | op), | 1497 | op), |
1572 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1498 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1573 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, | 1499 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, |
1574 | struct StrataEstimatorMessage, | 1500 | struct StrataEstimatorMessage, |
1575 | op), | 1501 | op), |
1576 | GNUNET_MQ_hd_var_size (union_p2p_full_element, | 1502 | GNUNET_MQ_hd_var_size (union_p2p_full_element, |
1577 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, | 1503 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, |
1578 | struct GNUNET_SET_ElementMessage, | 1504 | struct GNUNET_SET_ElementMessage, |
1579 | op), | 1505 | op), |
1580 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, | 1506 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, |
1581 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, | 1507 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, |
1582 | struct IntersectionElementInfoMessage, | 1508 | struct IntersectionElementInfoMessage, |
1583 | op), | 1509 | op), |
1584 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, | 1510 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, |
1585 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, | 1511 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, |
1586 | struct BFMessage, | 1512 | struct BFMessage, |
1587 | op), | 1513 | op), |
1588 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, | 1514 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, |
1589 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, | 1515 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, |
1590 | struct IntersectionDoneMessage, | 1516 | struct IntersectionDoneMessage, |
1591 | op), | 1517 | op), |
1592 | GNUNET_MQ_handler_end () | 1518 | GNUNET_MQ_handler_end ()}; |
1593 | }; | ||
1594 | struct Set *set; | 1519 | struct Set *set; |
1595 | const struct GNUNET_MessageHeader *context; | 1520 | const struct GNUNET_MessageHeader *context; |
1596 | 1521 | ||
@@ -1601,8 +1526,7 @@ handle_client_evaluate (void *cls, | |||
1601 | GNUNET_SERVICE_client_drop (cs->client); | 1526 | GNUNET_SERVICE_client_drop (cs->client); |
1602 | return; | 1527 | return; |
1603 | } | 1528 | } |
1604 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 1529 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
1605 | UINT32_MAX); | ||
1606 | op->peer = msg->target_peer; | 1530 | op->peer = msg->target_peer; |
1607 | op->result_mode = ntohl (msg->result_mode); | 1531 | op->result_mode = ntohl (msg->result_mode); |
1608 | op->client_request_id = ntohl (msg->request_id); | 1532 | op->client_request_id = ntohl (msg->request_id); |
@@ -1617,9 +1541,7 @@ handle_client_evaluate (void *cls, | |||
1617 | op->set = set; | 1541 | op->set = set; |
1618 | op->generation_created = set->current_generation; | 1542 | op->generation_created = set->current_generation; |
1619 | advance_generation (set); | 1543 | advance_generation (set); |
1620 | GNUNET_CONTAINER_DLL_insert (set->ops_head, | 1544 | GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); |
1621 | set->ops_tail, | ||
1622 | op); | ||
1623 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1624 | "Creating new CADET channel to port %s for set operation type %u\n", | 1546 | "Creating new CADET channel to port %s for set operation type %u\n", |
1625 | GNUNET_h2s (&msg->app_id), | 1547 | GNUNET_h2s (&msg->app_id), |
@@ -1628,13 +1550,11 @@ handle_client_evaluate (void *cls, | |||
1628 | op, | 1550 | op, |
1629 | &msg->target_peer, | 1551 | &msg->target_peer, |
1630 | &msg->app_id, | 1552 | &msg->app_id, |
1631 | GNUNET_CADET_OPTION_RELIABLE, | ||
1632 | &channel_window_cb, | 1553 | &channel_window_cb, |
1633 | &channel_end_cb, | 1554 | &channel_end_cb, |
1634 | cadet_handlers); | 1555 | cadet_handlers); |
1635 | op->mq = GNUNET_CADET_get_mq (op->channel); | 1556 | op->mq = GNUNET_CADET_get_mq (op->channel); |
1636 | op->state = set->vt->evaluate (op, | 1557 | op->state = set->vt->evaluate (op, context); |
1637 | context); | ||
1638 | if (NULL == op->state) | 1558 | if (NULL == op->state) |
1639 | { | 1559 | { |
1640 | GNUNET_break (0); | 1560 | GNUNET_break (0); |
@@ -1654,8 +1574,7 @@ handle_client_evaluate (void *cls, | |||
1654 | * @param ack the message | 1574 | * @param ack the message |
1655 | */ | 1575 | */ |
1656 | static void | 1576 | static void |
1657 | handle_client_iter_ack (void *cls, | 1577 | handle_client_iter_ack (void *cls, const struct GNUNET_SET_IterAckMessage *ack) |
1658 | const struct GNUNET_SET_IterAckMessage *ack) | ||
1659 | { | 1578 | { |
1660 | struct ClientState *cs = cls; | 1579 | struct ClientState *cs = cls; |
1661 | struct Set *set; | 1580 | struct Set *set; |
@@ -1717,14 +1636,10 @@ handle_client_copy_lazy_prepare (void *cls, | |||
1717 | cr = GNUNET_new (struct LazyCopyRequest); | 1636 | cr = GNUNET_new (struct LazyCopyRequest); |
1718 | cr->cookie = ++lazy_copy_cookie; | 1637 | cr->cookie = ++lazy_copy_cookie; |
1719 | cr->source_set = set; | 1638 | cr->source_set = set; |
1720 | GNUNET_CONTAINER_DLL_insert (lazy_copy_head, | 1639 | GNUNET_CONTAINER_DLL_insert (lazy_copy_head, lazy_copy_tail, cr); |
1721 | lazy_copy_tail, | 1640 | ev = GNUNET_MQ_msg (resp_msg, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE); |
1722 | cr); | ||
1723 | ev = GNUNET_MQ_msg (resp_msg, | ||
1724 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE); | ||
1725 | resp_msg->cookie = cr->cookie; | 1641 | resp_msg->cookie = cr->cookie; |
1726 | GNUNET_MQ_send (set->cs->mq, | 1642 | GNUNET_MQ_send (set->cs->mq, ev); |
1727 | ev); | ||
1728 | GNUNET_SERVICE_client_continue (cs->client); | 1643 | GNUNET_SERVICE_client_continue (cs->client); |
1729 | } | 1644 | } |
1730 | 1645 | ||
@@ -1736,8 +1651,9 @@ handle_client_copy_lazy_prepare (void *cls, | |||
1736 | * @param msg the message | 1651 | * @param msg the message |
1737 | */ | 1652 | */ |
1738 | static void | 1653 | static void |
1739 | handle_client_copy_lazy_connect (void *cls, | 1654 | handle_client_copy_lazy_connect ( |
1740 | const struct GNUNET_SET_CopyLazyConnectMessage *msg) | 1655 | void *cls, |
1656 | const struct GNUNET_SET_CopyLazyConnectMessage *msg) | ||
1741 | { | 1657 | { |
1742 | struct ClientState *cs = cls; | 1658 | struct ClientState *cs = cls; |
1743 | struct LazyCopyRequest *cr; | 1659 | struct LazyCopyRequest *cr; |
@@ -1767,9 +1683,7 @@ handle_client_copy_lazy_connect (void *cls, | |||
1767 | GNUNET_SERVICE_client_drop (cs->client); | 1683 | GNUNET_SERVICE_client_drop (cs->client); |
1768 | return; | 1684 | return; |
1769 | } | 1685 | } |
1770 | GNUNET_CONTAINER_DLL_remove (lazy_copy_head, | 1686 | GNUNET_CONTAINER_DLL_remove (lazy_copy_head, lazy_copy_tail, cr); |
1771 | lazy_copy_tail, | ||
1772 | cr); | ||
1773 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1774 | "Client %p requested use of lazy copy\n", | 1688 | "Client %p requested use of lazy copy\n", |
1775 | cs); | 1689 | cs); |
@@ -1804,9 +1718,10 @@ handle_client_copy_lazy_connect (void *cls, | |||
1804 | 1718 | ||
1805 | set->current_generation = cr->source_set->current_generation; | 1719 | set->current_generation = cr->source_set->current_generation; |
1806 | set->excluded_generations_size = cr->source_set->excluded_generations_size; | 1720 | set->excluded_generations_size = cr->source_set->excluded_generations_size; |
1807 | set->excluded_generations | 1721 | set->excluded_generations = |
1808 | = GNUNET_memdup (cr->source_set->excluded_generations, | 1722 | GNUNET_memdup (cr->source_set->excluded_generations, |
1809 | set->excluded_generations_size * sizeof (struct GenerationRange)); | 1723 | set->excluded_generations_size * |
1724 | sizeof (struct GenerationRange)); | ||
1810 | 1725 | ||
1811 | /* Advance the generation of the new set, so that mutations to the | 1726 | /* Advance the generation of the new set, so that mutations to the |
1812 | of the cloned set and the source set are independent. */ | 1727 | of the cloned set and the source set are independent. */ |
@@ -1825,8 +1740,7 @@ handle_client_copy_lazy_connect (void *cls, | |||
1825 | * @param msg the message | 1740 | * @param msg the message |
1826 | */ | 1741 | */ |
1827 | static void | 1742 | static void |
1828 | handle_client_cancel (void *cls, | 1743 | handle_client_cancel (void *cls, const struct GNUNET_SET_CancelMessage *msg) |
1829 | const struct GNUNET_SET_CancelMessage *msg) | ||
1830 | { | 1744 | { |
1831 | struct ClientState *cs = cls; | 1745 | struct ClientState *cs = cls; |
1832 | struct Set *set; | 1746 | struct Set *set; |
@@ -1865,8 +1779,7 @@ handle_client_cancel (void *cls, | |||
1865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1779 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1866 | "Client requested cancel for op %u\n", | 1780 | "Client requested cancel for op %u\n", |
1867 | (uint32_t) ntohl (msg->request_id)); | 1781 | (uint32_t) ntohl (msg->request_id)); |
1868 | _GSS_operation_destroy (op, | 1782 | _GSS_operation_destroy (op, GNUNET_YES); |
1869 | GNUNET_YES); | ||
1870 | } | 1783 | } |
1871 | GNUNET_SERVICE_client_continue (cs->client); | 1784 | GNUNET_SERVICE_client_continue (cs->client); |
1872 | } | 1785 | } |
@@ -1881,8 +1794,7 @@ handle_client_cancel (void *cls, | |||
1881 | * @param msg the message | 1794 | * @param msg the message |
1882 | */ | 1795 | */ |
1883 | static void | 1796 | static void |
1884 | handle_client_accept (void *cls, | 1797 | handle_client_accept (void *cls, const struct GNUNET_SET_AcceptMessage *msg) |
1885 | const struct GNUNET_SET_AcceptMessage *msg) | ||
1886 | { | 1798 | { |
1887 | struct ClientState *cs = cls; | 1799 | struct ClientState *cs = cls; |
1888 | struct Set *set; | 1800 | struct Set *set; |
@@ -1903,17 +1815,16 @@ handle_client_accept (void *cls, | |||
1903 | { | 1815 | { |
1904 | /* It is not an error if the set op does not exist -- it may | 1816 | /* It is not an error if the set op does not exist -- it may |
1905 | * have been destroyed when the partner peer disconnected. */ | 1817 | * have been destroyed when the partner peer disconnected. */ |
1906 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1818 | GNUNET_log ( |
1907 | "Client %p accepted request %u of listener %p that is no longer active\n", | 1819 | GNUNET_ERROR_TYPE_INFO, |
1908 | cs, | 1820 | "Client %p accepted request %u of listener %p that is no longer active\n", |
1909 | ntohl (msg->accept_reject_id), | 1821 | cs, |
1910 | cs->listener); | 1822 | ntohl (msg->accept_reject_id), |
1911 | ev = GNUNET_MQ_msg (result_message, | 1823 | cs->listener); |
1912 | GNUNET_MESSAGE_TYPE_SET_RESULT); | 1824 | ev = GNUNET_MQ_msg (result_message, GNUNET_MESSAGE_TYPE_SET_RESULT); |
1913 | result_message->request_id = msg->request_id; | 1825 | result_message->request_id = msg->request_id; |
1914 | result_message->result_status = htons (GNUNET_SET_STATUS_FAILURE); | 1826 | result_message->result_status = htons (GNUNET_SET_STATUS_FAILURE); |
1915 | GNUNET_MQ_send (set->cs->mq, | 1827 | GNUNET_MQ_send (set->cs->mq, ev); |
1916 | ev); | ||
1917 | GNUNET_SERVICE_client_continue (cs->client); | 1828 | GNUNET_SERVICE_client_continue (cs->client); |
1918 | return; | 1829 | return; |
1919 | } | 1830 | } |
@@ -1922,13 +1833,9 @@ handle_client_accept (void *cls, | |||
1922 | (uint32_t) ntohl (msg->accept_reject_id)); | 1833 | (uint32_t) ntohl (msg->accept_reject_id)); |
1923 | listener = op->listener; | 1834 | listener = op->listener; |
1924 | op->listener = NULL; | 1835 | op->listener = NULL; |
1925 | GNUNET_CONTAINER_DLL_remove (listener->op_head, | 1836 | GNUNET_CONTAINER_DLL_remove (listener->op_head, listener->op_tail, op); |
1926 | listener->op_tail, | ||
1927 | op); | ||
1928 | op->set = set; | 1837 | op->set = set; |
1929 | GNUNET_CONTAINER_DLL_insert (set->ops_head, | 1838 | GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); |
1930 | set->ops_tail, | ||
1931 | op); | ||
1932 | op->client_request_id = ntohl (msg->request_id); | 1839 | op->client_request_id = ntohl (msg->request_id); |
1933 | op->result_mode = ntohl (msg->result_mode); | 1840 | op->result_mode = ntohl (msg->result_mode); |
1934 | op->byzantine = msg->byzantine; | 1841 | op->byzantine = msg->byzantine; |
@@ -1974,10 +1881,8 @@ shutdown_task (void *cls) | |||
1974 | cadet = NULL; | 1881 | cadet = NULL; |
1975 | } | 1882 | } |
1976 | } | 1883 | } |
1977 | GNUNET_STATISTICS_destroy (_GSS_statistics, | 1884 | GNUNET_STATISTICS_destroy (_GSS_statistics, GNUNET_YES); |
1978 | GNUNET_YES); | 1885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); |
1979 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1980 | "handled shutdown request\n"); | ||
1981 | } | 1886 | } |
1982 | 1887 | ||
1983 | 1888 | ||
@@ -1997,15 +1902,13 @@ run (void *cls, | |||
1997 | /* FIXME: need to modify SERVICE (!) API to allow | 1902 | /* FIXME: need to modify SERVICE (!) API to allow |
1998 | us to run a shutdown task *after* clients were | 1903 | us to run a shutdown task *after* clients were |
1999 | forcefully disconnected! */ | 1904 | forcefully disconnected! */ |
2000 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1905 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2001 | NULL); | 1906 | _GSS_statistics = GNUNET_STATISTICS_create ("set", cfg); |
2002 | _GSS_statistics = GNUNET_STATISTICS_create ("set", | ||
2003 | cfg); | ||
2004 | cadet = GNUNET_CADET_connect (cfg); | 1907 | cadet = GNUNET_CADET_connect (cfg); |
2005 | if (NULL == cadet) | 1908 | if (NULL == cadet) |
2006 | { | 1909 | { |
2007 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1910 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2008 | _("Could not connect to CADET service\n")); | 1911 | _ ("Could not connect to CADET service\n")); |
2009 | GNUNET_SCHEDULER_shutdown (); | 1912 | GNUNET_SCHEDULER_shutdown (); |
2010 | return; | 1913 | return; |
2011 | } | 1914 | } |
@@ -2015,62 +1918,62 @@ run (void *cls, | |||
2015 | /** | 1918 | /** |
2016 | * Define "main" method using service macro. | 1919 | * Define "main" method using service macro. |
2017 | */ | 1920 | */ |
2018 | GNUNET_SERVICE_MAIN | 1921 | GNUNET_SERVICE_MAIN ( |
2019 | ("set", | 1922 | "set", |
2020 | GNUNET_SERVICE_OPTION_NONE, | 1923 | GNUNET_SERVICE_OPTION_NONE, |
2021 | &run, | 1924 | &run, |
2022 | &client_connect_cb, | 1925 | &client_connect_cb, |
2023 | &client_disconnect_cb, | 1926 | &client_disconnect_cb, |
2024 | NULL, | 1927 | NULL, |
2025 | GNUNET_MQ_hd_fixed_size (client_accept, | 1928 | GNUNET_MQ_hd_fixed_size (client_accept, |
2026 | GNUNET_MESSAGE_TYPE_SET_ACCEPT, | 1929 | GNUNET_MESSAGE_TYPE_SET_ACCEPT, |
2027 | struct GNUNET_SET_AcceptMessage, | 1930 | struct GNUNET_SET_AcceptMessage, |
2028 | NULL), | 1931 | NULL), |
2029 | GNUNET_MQ_hd_fixed_size (client_iter_ack, | 1932 | GNUNET_MQ_hd_fixed_size (client_iter_ack, |
2030 | GNUNET_MESSAGE_TYPE_SET_ITER_ACK, | 1933 | GNUNET_MESSAGE_TYPE_SET_ITER_ACK, |
2031 | struct GNUNET_SET_IterAckMessage, | 1934 | struct GNUNET_SET_IterAckMessage, |
2032 | NULL), | 1935 | NULL), |
2033 | GNUNET_MQ_hd_var_size (client_mutation, | 1936 | GNUNET_MQ_hd_var_size (client_mutation, |
2034 | GNUNET_MESSAGE_TYPE_SET_ADD, | 1937 | GNUNET_MESSAGE_TYPE_SET_ADD, |
2035 | struct GNUNET_SET_ElementMessage, | 1938 | struct GNUNET_SET_ElementMessage, |
2036 | NULL), | 1939 | NULL), |
2037 | GNUNET_MQ_hd_fixed_size (client_create_set, | 1940 | GNUNET_MQ_hd_fixed_size (client_create_set, |
2038 | GNUNET_MESSAGE_TYPE_SET_CREATE, | 1941 | GNUNET_MESSAGE_TYPE_SET_CREATE, |
2039 | struct GNUNET_SET_CreateMessage, | 1942 | struct GNUNET_SET_CreateMessage, |
2040 | NULL), | 1943 | NULL), |
2041 | GNUNET_MQ_hd_fixed_size (client_iterate, | 1944 | GNUNET_MQ_hd_fixed_size (client_iterate, |
2042 | GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, | 1945 | GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, |
2043 | struct GNUNET_MessageHeader, | 1946 | struct GNUNET_MessageHeader, |
2044 | NULL), | 1947 | NULL), |
2045 | GNUNET_MQ_hd_var_size (client_evaluate, | 1948 | GNUNET_MQ_hd_var_size (client_evaluate, |
2046 | GNUNET_MESSAGE_TYPE_SET_EVALUATE, | 1949 | GNUNET_MESSAGE_TYPE_SET_EVALUATE, |
2047 | struct GNUNET_SET_EvaluateMessage, | 1950 | struct GNUNET_SET_EvaluateMessage, |
2048 | NULL), | 1951 | NULL), |
2049 | GNUNET_MQ_hd_fixed_size (client_listen, | 1952 | GNUNET_MQ_hd_fixed_size (client_listen, |
2050 | GNUNET_MESSAGE_TYPE_SET_LISTEN, | 1953 | GNUNET_MESSAGE_TYPE_SET_LISTEN, |
2051 | struct GNUNET_SET_ListenMessage, | 1954 | struct GNUNET_SET_ListenMessage, |
2052 | NULL), | 1955 | NULL), |
2053 | GNUNET_MQ_hd_fixed_size (client_reject, | 1956 | GNUNET_MQ_hd_fixed_size (client_reject, |
2054 | GNUNET_MESSAGE_TYPE_SET_REJECT, | 1957 | GNUNET_MESSAGE_TYPE_SET_REJECT, |
2055 | struct GNUNET_SET_RejectMessage, | 1958 | struct GNUNET_SET_RejectMessage, |
2056 | NULL), | 1959 | NULL), |
2057 | GNUNET_MQ_hd_var_size (client_mutation, | 1960 | GNUNET_MQ_hd_var_size (client_mutation, |
2058 | GNUNET_MESSAGE_TYPE_SET_REMOVE, | 1961 | GNUNET_MESSAGE_TYPE_SET_REMOVE, |
2059 | struct GNUNET_SET_ElementMessage, | 1962 | struct GNUNET_SET_ElementMessage, |
2060 | NULL), | 1963 | NULL), |
2061 | GNUNET_MQ_hd_fixed_size (client_cancel, | 1964 | GNUNET_MQ_hd_fixed_size (client_cancel, |
2062 | GNUNET_MESSAGE_TYPE_SET_CANCEL, | 1965 | GNUNET_MESSAGE_TYPE_SET_CANCEL, |
2063 | struct GNUNET_SET_CancelMessage, | 1966 | struct GNUNET_SET_CancelMessage, |
2064 | NULL), | 1967 | NULL), |
2065 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_prepare, | 1968 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_prepare, |
2066 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, | 1969 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, |
2067 | struct GNUNET_MessageHeader, | 1970 | struct GNUNET_MessageHeader, |
2068 | NULL), | 1971 | NULL), |
2069 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_connect, | 1972 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_connect, |
2070 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, | 1973 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, |
2071 | struct GNUNET_SET_CopyLazyConnectMessage, | 1974 | struct GNUNET_SET_CopyLazyConnectMessage, |
2072 | NULL), | 1975 | NULL), |
2073 | GNUNET_MQ_handler_end ()); | 1976 | GNUNET_MQ_handler_end ()); |
2074 | 1977 | ||
2075 | 1978 | ||
2076 | /* end of gnunet-service-set.c */ | 1979 | /* end of gnunet-service-set.c */ |