diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-17 10:50:45 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-17 10:50:45 +0200 |
commit | a7ccf828ae4f7e306ffe3e7efebc0e678615f6c5 (patch) | |
tree | 71489a2649bb3c9100fccc19d135d832d3cbea05 /src/set | |
parent | 963c4fe2e94208a251b269e3a6918a71e8de1939 (diff) | |
download | gnunet-a7ccf828ae4f7e306ffe3e7efebc0e678615f6c5.tar.gz gnunet-a7ccf828ae4f7e306ffe3e7efebc0e678615f6c5.zip |
remove duplication MQ options, make conversation build
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 772 |
1 files changed, 337 insertions, 435 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index f1d94bef7..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,17 +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_MQ_env_set_options(env, | 716 | GNUNET_log ( |
745 | GNUNET_MQ_PREF_RELIABLE); | 717 | GNUNET_ERROR_TYPE_DEBUG, |
746 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 718 | "Suggesting incoming request with accept id %u to listener %p of client %p\n", |
747 | "Suggesting incoming request with accept id %u to listener %p of client %p\n", | 719 | op->suggest_id, |
748 | op->suggest_id, | 720 | listener, |
749 | listener, | 721 | listener->cs); |
750 | listener->cs); | ||
751 | cmsg->accept_id = htonl (op->suggest_id); | 722 | cmsg->accept_id = htonl (op->suggest_id); |
752 | cmsg->peer_id = op->peer; | 723 | cmsg->peer_id = op->peer; |
753 | GNUNET_MQ_send (listener->cs->mq, | 724 | GNUNET_MQ_send (listener->cs->mq, env); |
754 | env); | ||
755 | /* NOTE: GNUNET_CADET_receive_done() will be called in | 725 | /* NOTE: GNUNET_CADET_receive_done() will be called in |
756 | #handle_client_accept() */ | 726 | #handle_client_accept() */ |
757 | } | 727 | } |
@@ -764,8 +734,7 @@ handle_incoming_msg (void *cls, | |||
764 | * @param msg message specifying the change | 734 | * @param msg message specifying the change |
765 | */ | 735 | */ |
766 | static void | 736 | static void |
767 | execute_add (struct Set *set, | 737 | execute_add (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
768 | const struct GNUNET_SET_ElementMessage *msg) | ||
769 | { | 738 | { |
770 | struct GNUNET_SET_Element el; | 739 | struct GNUNET_SET_Element el; |
771 | struct ElementEntry *ee; | 740 | struct ElementEntry *ee; |
@@ -775,10 +744,8 @@ execute_add (struct Set *set, | |||
775 | el.size = ntohs (msg->header.size) - sizeof (*msg); | 744 | el.size = ntohs (msg->header.size) - sizeof (*msg); |
776 | el.data = &msg[1]; | 745 | el.data = &msg[1]; |
777 | el.element_type = ntohs (msg->element_type); | 746 | el.element_type = ntohs (msg->element_type); |
778 | GNUNET_SET_element_hash (&el, | 747 | GNUNET_SET_element_hash (&el, &hash); |
779 | &hash); | 748 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, &hash); |
780 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, | ||
781 | &hash); | ||
782 | if (NULL == ee) | 749 | if (NULL == ee) |
783 | { | 750 | { |
784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -787,9 +754,7 @@ execute_add (struct Set *set, | |||
787 | el.size); | 754 | el.size); |
788 | ee = GNUNET_malloc (el.size + sizeof (*ee)); | 755 | ee = GNUNET_malloc (el.size + sizeof (*ee)); |
789 | ee->element.size = el.size; | 756 | ee->element.size = el.size; |
790 | GNUNET_memcpy (&ee[1], | 757 | GNUNET_memcpy (&ee[1], el.data, el.size); |
791 | el.data, | ||
792 | el.size); | ||
793 | ee->element.data = &ee[1]; | 758 | ee->element.data = &ee[1]; |
794 | ee->element.element_type = el.element_type; | 759 | ee->element.element_type = el.element_type; |
795 | ee->remote = GNUNET_NO; | 760 | ee->remote = GNUNET_NO; |
@@ -797,10 +762,11 @@ execute_add (struct Set *set, | |||
797 | ee->mutations_size = 0; | 762 | ee->mutations_size = 0; |
798 | ee->element_hash = hash; | 763 | ee->element_hash = hash; |
799 | GNUNET_break (GNUNET_YES == | 764 | GNUNET_break (GNUNET_YES == |
800 | GNUNET_CONTAINER_multihashmap_put (set->content->elements, | 765 | GNUNET_CONTAINER_multihashmap_put ( |
801 | &ee->element_hash, | 766 | set->content->elements, |
802 | ee, | 767 | &ee->element_hash, |
803 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 768 | ee, |
769 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
804 | } | 770 | } |
805 | else if (GNUNET_YES == | 771 | else if (GNUNET_YES == |
806 | is_element_of_generation (ee, | 772 | is_element_of_generation (ee, |
@@ -818,16 +784,11 @@ execute_add (struct Set *set, | |||
818 | } | 784 | } |
819 | 785 | ||
820 | { | 786 | { |
821 | struct MutationEvent mut = { | 787 | struct MutationEvent mut = {.generation = set->current_generation, |
822 | .generation = set->current_generation, | 788 | .added = GNUNET_YES}; |
823 | .added = GNUNET_YES | 789 | GNUNET_array_append (ee->mutations, ee->mutations_size, mut); |
824 | }; | ||
825 | GNUNET_array_append (ee->mutations, | ||
826 | ee->mutations_size, | ||
827 | mut); | ||
828 | } | 790 | } |
829 | set->vt->add (set->state, | 791 | set->vt->add (set->state, ee); |
830 | ee); | ||
831 | } | 792 | } |
832 | 793 | ||
833 | 794 | ||
@@ -838,8 +799,7 @@ execute_add (struct Set *set, | |||
838 | * @param msg message specifying the change | 799 | * @param msg message specifying the change |
839 | */ | 800 | */ |
840 | static void | 801 | static void |
841 | execute_remove (struct Set *set, | 802 | execute_remove (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
842 | const struct GNUNET_SET_ElementMessage *msg) | ||
843 | { | 803 | { |
844 | struct GNUNET_SET_Element el; | 804 | struct GNUNET_SET_Element el; |
845 | struct ElementEntry *ee; | 805 | struct ElementEntry *ee; |
@@ -850,8 +810,7 @@ execute_remove (struct Set *set, | |||
850 | el.data = &msg[1]; | 810 | el.data = &msg[1]; |
851 | el.element_type = ntohs (msg->element_type); | 811 | el.element_type = ntohs (msg->element_type); |
852 | GNUNET_SET_element_hash (&el, &hash); | 812 | GNUNET_SET_element_hash (&el, &hash); |
853 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, | 813 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, &hash); |
854 | &hash); | ||
855 | if (NULL == ee) | 814 | if (NULL == ee) |
856 | { | 815 | { |
857 | /* Client tried to remove non-existing element. */ | 816 | /* Client tried to remove non-existing element. */ |
@@ -860,11 +819,10 @@ execute_remove (struct Set *set, | |||
860 | el.size); | 819 | el.size); |
861 | return; | 820 | return; |
862 | } | 821 | } |
863 | if (GNUNET_NO == | 822 | if (GNUNET_NO == is_element_of_generation (ee, |
864 | is_element_of_generation (ee, | 823 | set->current_generation, |
865 | set->current_generation, | 824 | set->excluded_generations, |
866 | set->excluded_generations, | 825 | set->excluded_generations_size)) |
867 | set->excluded_generations_size)) | ||
868 | { | 826 | { |
869 | /* Client tried to remove element twice */ | 827 | /* Client tried to remove element twice */ |
870 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -874,21 +832,16 @@ execute_remove (struct Set *set, | |||
874 | } | 832 | } |
875 | else | 833 | else |
876 | { | 834 | { |
877 | struct MutationEvent mut = { | 835 | struct MutationEvent mut = {.generation = set->current_generation, |
878 | .generation = set->current_generation, | 836 | .added = GNUNET_NO}; |
879 | .added = GNUNET_NO | ||
880 | }; | ||
881 | 837 | ||
882 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
883 | "Client removes element of size %u\n", | 839 | "Client removes element of size %u\n", |
884 | el.size); | 840 | el.size); |
885 | 841 | ||
886 | GNUNET_array_append (ee->mutations, | 842 | GNUNET_array_append (ee->mutations, ee->mutations_size, mut); |
887 | ee->mutations_size, | ||
888 | mut); | ||
889 | } | 843 | } |
890 | set->vt->remove (set->state, | 844 | set->vt->remove (set->state, ee); |
891 | ee); | ||
892 | } | 845 | } |
893 | 846 | ||
894 | 847 | ||
@@ -899,19 +852,18 @@ execute_remove (struct Set *set, | |||
899 | * @param msg specification of what to change | 852 | * @param msg specification of what to change |
900 | */ | 853 | */ |
901 | static void | 854 | static void |
902 | execute_mutation (struct Set *set, | 855 | execute_mutation (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
903 | const struct GNUNET_SET_ElementMessage *msg) | ||
904 | { | 856 | { |
905 | switch (ntohs (msg->header.type)) | 857 | switch (ntohs (msg->header.type)) |
906 | { | 858 | { |
907 | case GNUNET_MESSAGE_TYPE_SET_ADD: | 859 | case GNUNET_MESSAGE_TYPE_SET_ADD: |
908 | execute_add (set, msg); | 860 | execute_add (set, msg); |
909 | break; | 861 | break; |
910 | case GNUNET_MESSAGE_TYPE_SET_REMOVE: | 862 | case GNUNET_MESSAGE_TYPE_SET_REMOVE: |
911 | execute_remove (set, msg); | 863 | execute_remove (set, msg); |
912 | break; | 864 | break; |
913 | default: | 865 | default: |
914 | GNUNET_break (0); | 866 | GNUNET_break (0); |
915 | } | 867 | } |
916 | } | 868 | } |
917 | 869 | ||
@@ -937,8 +889,7 @@ execute_delayed_mutations (struct Set *set) | |||
937 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 889 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
938 | "Executing pending mutation on %p.\n", | 890 | "Executing pending mutation on %p.\n", |
939 | pm->set); | 891 | pm->set); |
940 | execute_mutation (pm->set, | 892 | execute_mutation (pm->set, pm->msg); |
941 | pm->msg); | ||
942 | GNUNET_free (pm->msg); | 893 | GNUNET_free (pm->msg); |
943 | GNUNET_free (pm); | 894 | GNUNET_free (pm); |
944 | } | 895 | } |
@@ -967,15 +918,14 @@ send_client_element (struct Set *set) | |||
967 | struct GNUNET_SET_IterResponseMessage *msg; | 918 | struct GNUNET_SET_IterResponseMessage *msg; |
968 | 919 | ||
969 | GNUNET_assert (NULL != set->iter); | 920 | GNUNET_assert (NULL != set->iter); |
970 | do { | 921 | do |
922 | { | ||
971 | ret = GNUNET_CONTAINER_multihashmap_iterator_next (set->iter, | 923 | ret = GNUNET_CONTAINER_multihashmap_iterator_next (set->iter, |
972 | NULL, | 924 | NULL, |
973 | (const void **) &ee); | 925 | (const void **) &ee); |
974 | if (GNUNET_NO == ret) | 926 | if (GNUNET_NO == ret) |
975 | { | 927 | { |
976 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 928 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration on %p done.\n", set); |
977 | "Iteration on %p done.\n", | ||
978 | set); | ||
979 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ITER_DONE); | 929 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ITER_DONE); |
980 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); | 930 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); |
981 | set->iter = NULL; | 931 | set->iter = NULL; |
@@ -983,8 +933,7 @@ send_client_element (struct Set *set) | |||
983 | GNUNET_assert (set->content->iterator_count > 0); | 933 | GNUNET_assert (set->content->iterator_count > 0); |
984 | set->content->iterator_count--; | 934 | set->content->iterator_count--; |
985 | execute_delayed_mutations (set); | 935 | execute_delayed_mutations (set); |
986 | GNUNET_MQ_send (set->cs->mq, | 936 | GNUNET_MQ_send (set->cs->mq, ev); |
987 | ev); | ||
988 | return; | 937 | return; |
989 | } | 938 | } |
990 | GNUNET_assert (NULL != ee); | 939 | GNUNET_assert (NULL != ee); |
@@ -999,13 +948,10 @@ send_client_element (struct Set *set) | |||
999 | ev = GNUNET_MQ_msg_extra (msg, | 948 | ev = GNUNET_MQ_msg_extra (msg, |
1000 | ee->element.size, | 949 | ee->element.size, |
1001 | GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT); | 950 | GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT); |
1002 | GNUNET_memcpy (&msg[1], | 951 | GNUNET_memcpy (&msg[1], ee->element.data, ee->element.size); |
1003 | ee->element.data, | ||
1004 | ee->element.size); | ||
1005 | msg->element_type = htons (ee->element.element_type); | 952 | msg->element_type = htons (ee->element.element_type); |
1006 | msg->iteration_id = htons (set->iteration_id); | 953 | msg->iteration_id = htons (set->iteration_id); |
1007 | GNUNET_MQ_send (set->cs->mq, | 954 | GNUNET_MQ_send (set->cs->mq, ev); |
1008 | ev); | ||
1009 | } | 955 | } |
1010 | 956 | ||
1011 | 957 | ||
@@ -1019,8 +965,7 @@ send_client_element (struct Set *set) | |||
1019 | * @param m message sent by the client | 965 | * @param m message sent by the client |
1020 | */ | 966 | */ |
1021 | static void | 967 | static void |
1022 | handle_client_iterate (void *cls, | 968 | handle_client_iterate (void *cls, const struct GNUNET_MessageHeader *m) |
1023 | const struct GNUNET_MessageHeader *m) | ||
1024 | { | 969 | { |
1025 | struct ClientState *cs = cls; | 970 | struct ClientState *cs = cls; |
1026 | struct Set *set; | 971 | struct Set *set; |
@@ -1046,7 +991,8 @@ handle_client_iterate (void *cls, | |||
1046 | GNUNET_CONTAINER_multihashmap_size (set->content->elements)); | 991 | GNUNET_CONTAINER_multihashmap_size (set->content->elements)); |
1047 | GNUNET_SERVICE_client_continue (cs->client); | 992 | GNUNET_SERVICE_client_continue (cs->client); |
1048 | set->content->iterator_count++; | 993 | set->content->iterator_count++; |
1049 | set->iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->content->elements); | 994 | set->iter = |
995 | GNUNET_CONTAINER_multihashmap_iterator_create (set->content->elements); | ||
1050 | set->iter_generation = set->current_generation; | 996 | set->iter_generation = set->current_generation; |
1051 | send_client_element (set); | 997 | send_client_element (set); |
1052 | } | 998 | } |
@@ -1061,8 +1007,7 @@ handle_client_iterate (void *cls, | |||
1061 | * @param m message sent by the client | 1007 | * @param m message sent by the client |
1062 | */ | 1008 | */ |
1063 | static void | 1009 | static void |
1064 | handle_client_create_set (void *cls, | 1010 | handle_client_create_set (void *cls, const struct GNUNET_SET_CreateMessage *msg) |
1065 | const struct GNUNET_SET_CreateMessage *msg) | ||
1066 | { | 1011 | { |
1067 | struct ClientState *cs = cls; | 1012 | struct ClientState *cs = cls; |
1068 | struct Set *set; | 1013 | struct Set *set; |
@@ -1103,8 +1048,7 @@ handle_client_create_set (void *cls, | |||
1103 | } | 1048 | } |
1104 | set->content = GNUNET_new (struct SetContent); | 1049 | set->content = GNUNET_new (struct SetContent); |
1105 | set->content->refcount = 1; | 1050 | set->content->refcount = 1; |
1106 | set->content->elements = GNUNET_CONTAINER_multihashmap_create (1, | 1051 | set->content->elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
1107 | GNUNET_YES); | ||
1108 | set->cs = cs; | 1052 | set->cs = cs; |
1109 | cs->set = set; | 1053 | cs->set = set; |
1110 | GNUNET_SERVICE_client_continue (cs->client); | 1054 | GNUNET_SERVICE_client_continue (cs->client); |
@@ -1156,22 +1100,17 @@ channel_new_cb (void *cls, | |||
1156 | struct Listener *listener = cls; | 1100 | struct Listener *listener = cls; |
1157 | struct Operation *op; | 1101 | struct Operation *op; |
1158 | 1102 | ||
1159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New incoming channel\n"); |
1160 | "New incoming channel\n"); | ||
1161 | op = GNUNET_new (struct Operation); | 1104 | op = GNUNET_new (struct Operation); |
1162 | op->listener = listener; | 1105 | op->listener = listener; |
1163 | op->peer = *source; | 1106 | op->peer = *source; |
1164 | op->channel = channel; | 1107 | op->channel = channel; |
1165 | op->mq = GNUNET_CADET_get_mq (op->channel); | 1108 | op->mq = GNUNET_CADET_get_mq (op->channel); |
1166 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 1109 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
1167 | UINT32_MAX); | 1110 | op->timeout_task = GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT, |
1168 | op->timeout_task | 1111 | &incoming_timeout_cb, |
1169 | = GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT, | 1112 | op); |
1170 | &incoming_timeout_cb, | 1113 | GNUNET_CONTAINER_DLL_insert (listener->op_head, listener->op_tail, op); |
1171 | op); | ||
1172 | GNUNET_CONTAINER_DLL_insert (listener->op_head, | ||
1173 | listener->op_tail, | ||
1174 | op); | ||
1175 | return op; | 1114 | return op; |
1176 | } | 1115 | } |
1177 | 1116 | ||
@@ -1193,8 +1132,7 @@ channel_new_cb (void *cls, | |||
1193 | * @param channel connection to the other end (henceforth invalid) | 1132 | * @param channel connection to the other end (henceforth invalid) |
1194 | */ | 1133 | */ |
1195 | static void | 1134 | static void |
1196 | channel_end_cb (void *channel_ctx, | 1135 | channel_end_cb (void *channel_ctx, const struct GNUNET_CADET_Channel *channel) |
1197 | const struct GNUNET_CADET_Channel *channel) | ||
1198 | { | 1136 | { |
1199 | struct Operation *op = channel_ctx; | 1137 | struct Operation *op = channel_ctx; |
1200 | 1138 | ||
@@ -1213,8 +1151,7 @@ _GSS_operation_destroy2 (struct Operation *op) | |||
1213 | { | 1151 | { |
1214 | struct GNUNET_CADET_Channel *channel; | 1152 | struct GNUNET_CADET_Channel *channel; |
1215 | 1153 | ||
1216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel_end_cb called\n"); |
1217 | "channel_end_cb called\n"); | ||
1218 | if (NULL != (channel = op->channel)) | 1155 | if (NULL != (channel = op->channel)) |
1219 | { | 1156 | { |
1220 | /* This will free op; called conditionally as this helper function | 1157 | /* This will free op; called conditionally as this helper function |
@@ -1230,8 +1167,7 @@ _GSS_operation_destroy2 (struct Operation *op) | |||
1230 | if (NULL != op->set) | 1167 | if (NULL != op->set) |
1231 | op->set->vt->channel_death (op); | 1168 | op->set->vt->channel_death (op); |
1232 | else | 1169 | else |
1233 | _GSS_operation_destroy (op, | 1170 | _GSS_operation_destroy (op, GNUNET_YES); |
1234 | GNUNET_YES); | ||
1235 | GNUNET_free (op); | 1171 | GNUNET_free (op); |
1236 | } | 1172 | } |
1237 | 1173 | ||
@@ -1266,77 +1202,75 @@ channel_window_cb (void *cls, | |||
1266 | * @param msg message sent by the client | 1202 | * @param msg message sent by the client |
1267 | */ | 1203 | */ |
1268 | static void | 1204 | static void |
1269 | handle_client_listen (void *cls, | 1205 | handle_client_listen (void *cls, const struct GNUNET_SET_ListenMessage *msg) |
1270 | const struct GNUNET_SET_ListenMessage *msg) | ||
1271 | { | 1206 | { |
1272 | struct ClientState *cs = cls; | 1207 | struct ClientState *cs = cls; |
1273 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = { | 1208 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1274 | GNUNET_MQ_hd_var_size (incoming_msg, | 1209 | {GNUNET_MQ_hd_var_size (incoming_msg, |
1275 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, | 1210 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, |
1276 | struct OperationRequestMessage, | 1211 | struct OperationRequestMessage, |
1277 | NULL), | 1212 | NULL), |
1278 | GNUNET_MQ_hd_var_size (union_p2p_ibf, | 1213 | GNUNET_MQ_hd_var_size (union_p2p_ibf, |
1279 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, | 1214 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, |
1280 | struct IBFMessage, | 1215 | struct IBFMessage, |
1281 | NULL), | 1216 | NULL), |
1282 | GNUNET_MQ_hd_var_size (union_p2p_elements, | 1217 | GNUNET_MQ_hd_var_size (union_p2p_elements, |
1283 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, | 1218 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, |
1284 | struct GNUNET_SET_ElementMessage, | 1219 | struct GNUNET_SET_ElementMessage, |
1285 | NULL), | 1220 | NULL), |
1286 | GNUNET_MQ_hd_var_size (union_p2p_offer, | 1221 | GNUNET_MQ_hd_var_size (union_p2p_offer, |
1287 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, | 1222 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, |
1288 | struct GNUNET_MessageHeader, | 1223 | struct GNUNET_MessageHeader, |
1289 | NULL), | 1224 | NULL), |
1290 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, | 1225 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, |
1291 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, | 1226 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, |
1292 | struct InquiryMessage, | 1227 | struct InquiryMessage, |
1293 | NULL), | 1228 | NULL), |
1294 | GNUNET_MQ_hd_var_size (union_p2p_demand, | 1229 | GNUNET_MQ_hd_var_size (union_p2p_demand, |
1295 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, | 1230 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, |
1296 | struct GNUNET_MessageHeader, | 1231 | struct GNUNET_MessageHeader, |
1297 | NULL), | 1232 | NULL), |
1298 | GNUNET_MQ_hd_fixed_size (union_p2p_done, | 1233 | GNUNET_MQ_hd_fixed_size (union_p2p_done, |
1299 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, | 1234 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, |
1300 | struct GNUNET_MessageHeader, | 1235 | struct GNUNET_MessageHeader, |
1301 | NULL), | 1236 | NULL), |
1302 | GNUNET_MQ_hd_fixed_size (union_p2p_over, | 1237 | GNUNET_MQ_hd_fixed_size (union_p2p_over, |
1303 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, | 1238 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, |
1304 | struct GNUNET_MessageHeader, | 1239 | struct GNUNET_MessageHeader, |
1305 | NULL), | 1240 | NULL), |
1306 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, | 1241 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, |
1307 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, | 1242 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, |
1308 | struct GNUNET_MessageHeader, | 1243 | struct GNUNET_MessageHeader, |
1309 | NULL), | 1244 | NULL), |
1310 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, | 1245 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, |
1311 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, | 1246 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, |
1312 | struct GNUNET_MessageHeader, | 1247 | struct GNUNET_MessageHeader, |
1313 | NULL), | 1248 | NULL), |
1314 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1249 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1315 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, | 1250 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, |
1316 | struct StrataEstimatorMessage, | 1251 | struct StrataEstimatorMessage, |
1317 | NULL), | 1252 | NULL), |
1318 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1253 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1319 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, | 1254 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, |
1320 | struct StrataEstimatorMessage, | 1255 | struct StrataEstimatorMessage, |
1321 | NULL), | 1256 | NULL), |
1322 | GNUNET_MQ_hd_var_size (union_p2p_full_element, | 1257 | GNUNET_MQ_hd_var_size (union_p2p_full_element, |
1323 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, | 1258 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, |
1324 | struct GNUNET_SET_ElementMessage, | 1259 | struct GNUNET_SET_ElementMessage, |
1325 | NULL), | 1260 | NULL), |
1326 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, | 1261 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, |
1327 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, | 1262 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, |
1328 | struct IntersectionElementInfoMessage, | 1263 | struct IntersectionElementInfoMessage, |
1329 | NULL), | 1264 | NULL), |
1330 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, | 1265 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, |
1331 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, | 1266 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, |
1332 | struct BFMessage, | 1267 | struct BFMessage, |
1333 | NULL), | 1268 | NULL), |
1334 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, | 1269 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, |
1335 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, | 1270 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, |
1336 | struct IntersectionDoneMessage, | 1271 | struct IntersectionDoneMessage, |
1337 | NULL), | 1272 | NULL), |
1338 | GNUNET_MQ_handler_end () | 1273 | GNUNET_MQ_handler_end ()}; |
1339 | }; | ||
1340 | struct Listener *listener; | 1274 | struct Listener *listener; |
1341 | 1275 | ||
1342 | if (NULL != cs->listener) | 1276 | if (NULL != cs->listener) |
@@ -1351,21 +1285,18 @@ handle_client_listen (void *cls, | |||
1351 | cs->listener = listener; | 1285 | cs->listener = listener; |
1352 | listener->app_id = msg->app_id; | 1286 | listener->app_id = msg->app_id; |
1353 | listener->operation = (enum GNUNET_SET_OperationType) ntohl (msg->operation); | 1287 | listener->operation = (enum GNUNET_SET_OperationType) ntohl (msg->operation); |
1354 | GNUNET_CONTAINER_DLL_insert (listener_head, | 1288 | GNUNET_CONTAINER_DLL_insert (listener_head, listener_tail, listener); |
1355 | listener_tail, | ||
1356 | listener); | ||
1357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1358 | "New listener created (op %u, port %s)\n", | 1290 | "New listener created (op %u, port %s)\n", |
1359 | listener->operation, | 1291 | listener->operation, |
1360 | GNUNET_h2s (&listener->app_id)); | 1292 | GNUNET_h2s (&listener->app_id)); |
1361 | listener->open_port | 1293 | listener->open_port = GNUNET_CADET_open_port (cadet, |
1362 | = GNUNET_CADET_open_port (cadet, | 1294 | &msg->app_id, |
1363 | &msg->app_id, | 1295 | &channel_new_cb, |
1364 | &channel_new_cb, | 1296 | listener, |
1365 | listener, | 1297 | &channel_window_cb, |
1366 | &channel_window_cb, | 1298 | &channel_end_cb, |
1367 | &channel_end_cb, | 1299 | cadet_handlers); |
1368 | cadet_handlers); | ||
1369 | GNUNET_SERVICE_client_continue (cs->client); | 1300 | GNUNET_SERVICE_client_continue (cs->client); |
1370 | } | 1301 | } |
1371 | 1302 | ||
@@ -1378,8 +1309,7 @@ handle_client_listen (void *cls, | |||
1378 | * @param msg message sent by the client | 1309 | * @param msg message sent by the client |
1379 | */ | 1310 | */ |
1380 | static void | 1311 | static void |
1381 | handle_client_reject (void *cls, | 1312 | handle_client_reject (void *cls, const struct GNUNET_SET_RejectMessage *msg) |
1382 | const struct GNUNET_SET_RejectMessage *msg) | ||
1383 | { | 1313 | { |
1384 | struct ClientState *cs = cls; | 1314 | struct ClientState *cs = cls; |
1385 | struct Operation *op; | 1315 | struct Operation *op; |
@@ -1411,8 +1341,7 @@ handle_client_reject (void *cls, | |||
1411 | * @param msg message sent by the client | 1341 | * @param msg message sent by the client |
1412 | */ | 1342 | */ |
1413 | static int | 1343 | static int |
1414 | check_client_mutation (void *cls, | 1344 | check_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
1415 | const struct GNUNET_SET_ElementMessage *msg) | ||
1416 | { | 1345 | { |
1417 | /* NOTE: Technically, we should probably check with the | 1346 | /* NOTE: Technically, we should probably check with the |
1418 | block library whether the element we are given is well-formed */ | 1347 | block library whether the element we are given is well-formed */ |
@@ -1427,8 +1356,7 @@ check_client_mutation (void *cls, | |||
1427 | * @param msg message sent by the client | 1356 | * @param msg message sent by the client |
1428 | */ | 1357 | */ |
1429 | static void | 1358 | static void |
1430 | handle_client_mutation (void *cls, | 1359 | handle_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
1431 | const struct GNUNET_SET_ElementMessage *msg) | ||
1432 | { | 1360 | { |
1433 | struct ClientState *cs = cls; | 1361 | struct ClientState *cs = cls; |
1434 | struct Set *set; | 1362 | struct Set *set; |
@@ -1446,20 +1374,18 @@ handle_client_mutation (void *cls, | |||
1446 | { | 1374 | { |
1447 | struct PendingMutation *pm; | 1375 | struct PendingMutation *pm; |
1448 | 1376 | ||
1449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling mutation on set\n"); |
1450 | "Scheduling mutation on set\n"); | ||
1451 | pm = GNUNET_new (struct PendingMutation); | 1378 | pm = GNUNET_new (struct PendingMutation); |
1452 | pm->msg = (struct GNUNET_SET_ElementMessage *) GNUNET_copy_message (&msg->header); | 1379 | pm->msg = |
1380 | (struct GNUNET_SET_ElementMessage *) GNUNET_copy_message (&msg->header); | ||
1453 | pm->set = set; | 1381 | pm->set = set; |
1454 | GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head, | 1382 | GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head, |
1455 | set->content->pending_mutations_tail, | 1383 | set->content->pending_mutations_tail, |
1456 | pm); | 1384 | pm); |
1457 | return; | 1385 | return; |
1458 | } | 1386 | } |
1459 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing mutation on set\n"); |
1460 | "Executing mutation on set\n"); | 1388 | execute_mutation (set, msg); |
1461 | execute_mutation (set, | ||
1462 | msg); | ||
1463 | } | 1389 | } |
1464 | 1390 | ||
1465 | 1391 | ||
@@ -1503,8 +1429,7 @@ advance_generation (struct Set *set) | |||
1503 | * @return #GNUNET_OK if the message is well-formed | 1429 | * @return #GNUNET_OK if the message is well-formed |
1504 | */ | 1430 | */ |
1505 | static int | 1431 | static int |
1506 | check_client_evaluate (void *cls, | 1432 | check_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
1507 | const struct GNUNET_SET_EvaluateMessage *msg) | ||
1508 | { | 1433 | { |
1509 | /* FIXME: suboptimal, even if the context below could be NULL, | 1434 | /* FIXME: suboptimal, even if the context below could be NULL, |
1510 | there are malformed messages this does not check for... */ | 1435 | there are malformed messages this does not check for... */ |
@@ -1521,78 +1446,76 @@ check_client_evaluate (void *cls, | |||
1521 | * @param msg message sent by the client | 1446 | * @param msg message sent by the client |
1522 | */ | 1447 | */ |
1523 | static void | 1448 | static void |
1524 | handle_client_evaluate (void *cls, | 1449 | handle_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
1525 | const struct GNUNET_SET_EvaluateMessage *msg) | ||
1526 | { | 1450 | { |
1527 | struct ClientState *cs = cls; | 1451 | struct ClientState *cs = cls; |
1528 | struct Operation *op = GNUNET_new (struct Operation); | 1452 | struct Operation *op = GNUNET_new (struct Operation); |
1529 | const struct GNUNET_MQ_MessageHandler cadet_handlers[] = { | 1453 | const struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1530 | GNUNET_MQ_hd_var_size (incoming_msg, | 1454 | {GNUNET_MQ_hd_var_size (incoming_msg, |
1531 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, | 1455 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, |
1532 | struct OperationRequestMessage, | 1456 | struct OperationRequestMessage, |
1533 | op), | 1457 | op), |
1534 | GNUNET_MQ_hd_var_size (union_p2p_ibf, | 1458 | GNUNET_MQ_hd_var_size (union_p2p_ibf, |
1535 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, | 1459 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, |
1536 | struct IBFMessage, | 1460 | struct IBFMessage, |
1537 | op), | 1461 | op), |
1538 | GNUNET_MQ_hd_var_size (union_p2p_elements, | 1462 | GNUNET_MQ_hd_var_size (union_p2p_elements, |
1539 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, | 1463 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, |
1540 | struct GNUNET_SET_ElementMessage, | 1464 | struct GNUNET_SET_ElementMessage, |
1541 | op), | 1465 | op), |
1542 | GNUNET_MQ_hd_var_size (union_p2p_offer, | 1466 | GNUNET_MQ_hd_var_size (union_p2p_offer, |
1543 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, | 1467 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, |
1544 | struct GNUNET_MessageHeader, | 1468 | struct GNUNET_MessageHeader, |
1545 | op), | 1469 | op), |
1546 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, | 1470 | GNUNET_MQ_hd_var_size (union_p2p_inquiry, |
1547 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, | 1471 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, |
1548 | struct InquiryMessage, | 1472 | struct InquiryMessage, |
1549 | op), | 1473 | op), |
1550 | GNUNET_MQ_hd_var_size (union_p2p_demand, | 1474 | GNUNET_MQ_hd_var_size (union_p2p_demand, |
1551 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, | 1475 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, |
1552 | struct GNUNET_MessageHeader, | 1476 | struct GNUNET_MessageHeader, |
1553 | op), | 1477 | op), |
1554 | GNUNET_MQ_hd_fixed_size (union_p2p_done, | 1478 | GNUNET_MQ_hd_fixed_size (union_p2p_done, |
1555 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, | 1479 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, |
1556 | struct GNUNET_MessageHeader, | 1480 | struct GNUNET_MessageHeader, |
1557 | op), | 1481 | op), |
1558 | GNUNET_MQ_hd_fixed_size (union_p2p_over, | 1482 | GNUNET_MQ_hd_fixed_size (union_p2p_over, |
1559 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, | 1483 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, |
1560 | struct GNUNET_MessageHeader, | 1484 | struct GNUNET_MessageHeader, |
1561 | op), | 1485 | op), |
1562 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, | 1486 | GNUNET_MQ_hd_fixed_size (union_p2p_full_done, |
1563 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, | 1487 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, |
1564 | struct GNUNET_MessageHeader, | 1488 | struct GNUNET_MessageHeader, |
1565 | op), | 1489 | op), |
1566 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, | 1490 | GNUNET_MQ_hd_fixed_size (union_p2p_request_full, |
1567 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, | 1491 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, |
1568 | struct GNUNET_MessageHeader, | 1492 | struct GNUNET_MessageHeader, |
1569 | op), | 1493 | op), |
1570 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1494 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1571 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, | 1495 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, |
1572 | struct StrataEstimatorMessage, | 1496 | struct StrataEstimatorMessage, |
1573 | op), | 1497 | op), |
1574 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, | 1498 | GNUNET_MQ_hd_var_size (union_p2p_strata_estimator, |
1575 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, | 1499 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, |
1576 | struct StrataEstimatorMessage, | 1500 | struct StrataEstimatorMessage, |
1577 | op), | 1501 | op), |
1578 | GNUNET_MQ_hd_var_size (union_p2p_full_element, | 1502 | GNUNET_MQ_hd_var_size (union_p2p_full_element, |
1579 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, | 1503 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, |
1580 | struct GNUNET_SET_ElementMessage, | 1504 | struct GNUNET_SET_ElementMessage, |
1581 | op), | 1505 | op), |
1582 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, | 1506 | GNUNET_MQ_hd_fixed_size (intersection_p2p_element_info, |
1583 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, | 1507 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, |
1584 | struct IntersectionElementInfoMessage, | 1508 | struct IntersectionElementInfoMessage, |
1585 | op), | 1509 | op), |
1586 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, | 1510 | GNUNET_MQ_hd_var_size (intersection_p2p_bf, |
1587 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, | 1511 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, |
1588 | struct BFMessage, | 1512 | struct BFMessage, |
1589 | op), | 1513 | op), |
1590 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, | 1514 | GNUNET_MQ_hd_fixed_size (intersection_p2p_done, |
1591 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, | 1515 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, |
1592 | struct IntersectionDoneMessage, | 1516 | struct IntersectionDoneMessage, |
1593 | op), | 1517 | op), |
1594 | GNUNET_MQ_handler_end () | 1518 | GNUNET_MQ_handler_end ()}; |
1595 | }; | ||
1596 | struct Set *set; | 1519 | struct Set *set; |
1597 | const struct GNUNET_MessageHeader *context; | 1520 | const struct GNUNET_MessageHeader *context; |
1598 | 1521 | ||
@@ -1603,8 +1526,7 @@ handle_client_evaluate (void *cls, | |||
1603 | GNUNET_SERVICE_client_drop (cs->client); | 1526 | GNUNET_SERVICE_client_drop (cs->client); |
1604 | return; | 1527 | return; |
1605 | } | 1528 | } |
1606 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 1529 | op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); |
1607 | UINT32_MAX); | ||
1608 | op->peer = msg->target_peer; | 1530 | op->peer = msg->target_peer; |
1609 | op->result_mode = ntohl (msg->result_mode); | 1531 | op->result_mode = ntohl (msg->result_mode); |
1610 | op->client_request_id = ntohl (msg->request_id); | 1532 | op->client_request_id = ntohl (msg->request_id); |
@@ -1619,9 +1541,7 @@ handle_client_evaluate (void *cls, | |||
1619 | op->set = set; | 1541 | op->set = set; |
1620 | op->generation_created = set->current_generation; | 1542 | op->generation_created = set->current_generation; |
1621 | advance_generation (set); | 1543 | advance_generation (set); |
1622 | GNUNET_CONTAINER_DLL_insert (set->ops_head, | 1544 | GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); |
1623 | set->ops_tail, | ||
1624 | op); | ||
1625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1626 | "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", |
1627 | GNUNET_h2s (&msg->app_id), | 1547 | GNUNET_h2s (&msg->app_id), |
@@ -1634,8 +1554,7 @@ handle_client_evaluate (void *cls, | |||
1634 | &channel_end_cb, | 1554 | &channel_end_cb, |
1635 | cadet_handlers); | 1555 | cadet_handlers); |
1636 | op->mq = GNUNET_CADET_get_mq (op->channel); | 1556 | op->mq = GNUNET_CADET_get_mq (op->channel); |
1637 | op->state = set->vt->evaluate (op, | 1557 | op->state = set->vt->evaluate (op, context); |
1638 | context); | ||
1639 | if (NULL == op->state) | 1558 | if (NULL == op->state) |
1640 | { | 1559 | { |
1641 | GNUNET_break (0); | 1560 | GNUNET_break (0); |
@@ -1655,8 +1574,7 @@ handle_client_evaluate (void *cls, | |||
1655 | * @param ack the message | 1574 | * @param ack the message |
1656 | */ | 1575 | */ |
1657 | static void | 1576 | static void |
1658 | handle_client_iter_ack (void *cls, | 1577 | handle_client_iter_ack (void *cls, const struct GNUNET_SET_IterAckMessage *ack) |
1659 | const struct GNUNET_SET_IterAckMessage *ack) | ||
1660 | { | 1578 | { |
1661 | struct ClientState *cs = cls; | 1579 | struct ClientState *cs = cls; |
1662 | struct Set *set; | 1580 | struct Set *set; |
@@ -1718,14 +1636,10 @@ handle_client_copy_lazy_prepare (void *cls, | |||
1718 | cr = GNUNET_new (struct LazyCopyRequest); | 1636 | cr = GNUNET_new (struct LazyCopyRequest); |
1719 | cr->cookie = ++lazy_copy_cookie; | 1637 | cr->cookie = ++lazy_copy_cookie; |
1720 | cr->source_set = set; | 1638 | cr->source_set = set; |
1721 | GNUNET_CONTAINER_DLL_insert (lazy_copy_head, | 1639 | GNUNET_CONTAINER_DLL_insert (lazy_copy_head, lazy_copy_tail, cr); |
1722 | lazy_copy_tail, | 1640 | ev = GNUNET_MQ_msg (resp_msg, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE); |
1723 | cr); | ||
1724 | ev = GNUNET_MQ_msg (resp_msg, | ||
1725 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE); | ||
1726 | resp_msg->cookie = cr->cookie; | 1641 | resp_msg->cookie = cr->cookie; |
1727 | GNUNET_MQ_send (set->cs->mq, | 1642 | GNUNET_MQ_send (set->cs->mq, ev); |
1728 | ev); | ||
1729 | GNUNET_SERVICE_client_continue (cs->client); | 1643 | GNUNET_SERVICE_client_continue (cs->client); |
1730 | } | 1644 | } |
1731 | 1645 | ||
@@ -1737,8 +1651,9 @@ handle_client_copy_lazy_prepare (void *cls, | |||
1737 | * @param msg the message | 1651 | * @param msg the message |
1738 | */ | 1652 | */ |
1739 | static void | 1653 | static void |
1740 | handle_client_copy_lazy_connect (void *cls, | 1654 | handle_client_copy_lazy_connect ( |
1741 | const struct GNUNET_SET_CopyLazyConnectMessage *msg) | 1655 | void *cls, |
1656 | const struct GNUNET_SET_CopyLazyConnectMessage *msg) | ||
1742 | { | 1657 | { |
1743 | struct ClientState *cs = cls; | 1658 | struct ClientState *cs = cls; |
1744 | struct LazyCopyRequest *cr; | 1659 | struct LazyCopyRequest *cr; |
@@ -1768,9 +1683,7 @@ handle_client_copy_lazy_connect (void *cls, | |||
1768 | GNUNET_SERVICE_client_drop (cs->client); | 1683 | GNUNET_SERVICE_client_drop (cs->client); |
1769 | return; | 1684 | return; |
1770 | } | 1685 | } |
1771 | GNUNET_CONTAINER_DLL_remove (lazy_copy_head, | 1686 | GNUNET_CONTAINER_DLL_remove (lazy_copy_head, lazy_copy_tail, cr); |
1772 | lazy_copy_tail, | ||
1773 | cr); | ||
1774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1775 | "Client %p requested use of lazy copy\n", | 1688 | "Client %p requested use of lazy copy\n", |
1776 | cs); | 1689 | cs); |
@@ -1805,9 +1718,10 @@ handle_client_copy_lazy_connect (void *cls, | |||
1805 | 1718 | ||
1806 | set->current_generation = cr->source_set->current_generation; | 1719 | set->current_generation = cr->source_set->current_generation; |
1807 | set->excluded_generations_size = cr->source_set->excluded_generations_size; | 1720 | set->excluded_generations_size = cr->source_set->excluded_generations_size; |
1808 | set->excluded_generations | 1721 | set->excluded_generations = |
1809 | = GNUNET_memdup (cr->source_set->excluded_generations, | 1722 | GNUNET_memdup (cr->source_set->excluded_generations, |
1810 | set->excluded_generations_size * sizeof (struct GenerationRange)); | 1723 | set->excluded_generations_size * |
1724 | sizeof (struct GenerationRange)); | ||
1811 | 1725 | ||
1812 | /* 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 |
1813 | of the cloned set and the source set are independent. */ | 1727 | of the cloned set and the source set are independent. */ |
@@ -1826,8 +1740,7 @@ handle_client_copy_lazy_connect (void *cls, | |||
1826 | * @param msg the message | 1740 | * @param msg the message |
1827 | */ | 1741 | */ |
1828 | static void | 1742 | static void |
1829 | handle_client_cancel (void *cls, | 1743 | handle_client_cancel (void *cls, const struct GNUNET_SET_CancelMessage *msg) |
1830 | const struct GNUNET_SET_CancelMessage *msg) | ||
1831 | { | 1744 | { |
1832 | struct ClientState *cs = cls; | 1745 | struct ClientState *cs = cls; |
1833 | struct Set *set; | 1746 | struct Set *set; |
@@ -1866,8 +1779,7 @@ handle_client_cancel (void *cls, | |||
1866 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1779 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1867 | "Client requested cancel for op %u\n", | 1780 | "Client requested cancel for op %u\n", |
1868 | (uint32_t) ntohl (msg->request_id)); | 1781 | (uint32_t) ntohl (msg->request_id)); |
1869 | _GSS_operation_destroy (op, | 1782 | _GSS_operation_destroy (op, GNUNET_YES); |
1870 | GNUNET_YES); | ||
1871 | } | 1783 | } |
1872 | GNUNET_SERVICE_client_continue (cs->client); | 1784 | GNUNET_SERVICE_client_continue (cs->client); |
1873 | } | 1785 | } |
@@ -1882,8 +1794,7 @@ handle_client_cancel (void *cls, | |||
1882 | * @param msg the message | 1794 | * @param msg the message |
1883 | */ | 1795 | */ |
1884 | static void | 1796 | static void |
1885 | handle_client_accept (void *cls, | 1797 | handle_client_accept (void *cls, const struct GNUNET_SET_AcceptMessage *msg) |
1886 | const struct GNUNET_SET_AcceptMessage *msg) | ||
1887 | { | 1798 | { |
1888 | struct ClientState *cs = cls; | 1799 | struct ClientState *cs = cls; |
1889 | struct Set *set; | 1800 | struct Set *set; |
@@ -1904,17 +1815,16 @@ handle_client_accept (void *cls, | |||
1904 | { | 1815 | { |
1905 | /* 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 |
1906 | * have been destroyed when the partner peer disconnected. */ | 1817 | * have been destroyed when the partner peer disconnected. */ |
1907 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1818 | GNUNET_log ( |
1908 | "Client %p accepted request %u of listener %p that is no longer active\n", | 1819 | GNUNET_ERROR_TYPE_INFO, |
1909 | cs, | 1820 | "Client %p accepted request %u of listener %p that is no longer active\n", |
1910 | ntohl (msg->accept_reject_id), | 1821 | cs, |
1911 | cs->listener); | 1822 | ntohl (msg->accept_reject_id), |
1912 | ev = GNUNET_MQ_msg (result_message, | 1823 | cs->listener); |
1913 | GNUNET_MESSAGE_TYPE_SET_RESULT); | 1824 | ev = GNUNET_MQ_msg (result_message, GNUNET_MESSAGE_TYPE_SET_RESULT); |
1914 | result_message->request_id = msg->request_id; | 1825 | result_message->request_id = msg->request_id; |
1915 | result_message->result_status = htons (GNUNET_SET_STATUS_FAILURE); | 1826 | result_message->result_status = htons (GNUNET_SET_STATUS_FAILURE); |
1916 | GNUNET_MQ_send (set->cs->mq, | 1827 | GNUNET_MQ_send (set->cs->mq, ev); |
1917 | ev); | ||
1918 | GNUNET_SERVICE_client_continue (cs->client); | 1828 | GNUNET_SERVICE_client_continue (cs->client); |
1919 | return; | 1829 | return; |
1920 | } | 1830 | } |
@@ -1923,13 +1833,9 @@ handle_client_accept (void *cls, | |||
1923 | (uint32_t) ntohl (msg->accept_reject_id)); | 1833 | (uint32_t) ntohl (msg->accept_reject_id)); |
1924 | listener = op->listener; | 1834 | listener = op->listener; |
1925 | op->listener = NULL; | 1835 | op->listener = NULL; |
1926 | GNUNET_CONTAINER_DLL_remove (listener->op_head, | 1836 | GNUNET_CONTAINER_DLL_remove (listener->op_head, listener->op_tail, op); |
1927 | listener->op_tail, | ||
1928 | op); | ||
1929 | op->set = set; | 1837 | op->set = set; |
1930 | GNUNET_CONTAINER_DLL_insert (set->ops_head, | 1838 | GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); |
1931 | set->ops_tail, | ||
1932 | op); | ||
1933 | op->client_request_id = ntohl (msg->request_id); | 1839 | op->client_request_id = ntohl (msg->request_id); |
1934 | op->result_mode = ntohl (msg->result_mode); | 1840 | op->result_mode = ntohl (msg->result_mode); |
1935 | op->byzantine = msg->byzantine; | 1841 | op->byzantine = msg->byzantine; |
@@ -1975,10 +1881,8 @@ shutdown_task (void *cls) | |||
1975 | cadet = NULL; | 1881 | cadet = NULL; |
1976 | } | 1882 | } |
1977 | } | 1883 | } |
1978 | GNUNET_STATISTICS_destroy (_GSS_statistics, | 1884 | GNUNET_STATISTICS_destroy (_GSS_statistics, GNUNET_YES); |
1979 | GNUNET_YES); | 1885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); |
1980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1981 | "handled shutdown request\n"); | ||
1982 | } | 1886 | } |
1983 | 1887 | ||
1984 | 1888 | ||
@@ -1998,15 +1902,13 @@ run (void *cls, | |||
1998 | /* FIXME: need to modify SERVICE (!) API to allow | 1902 | /* FIXME: need to modify SERVICE (!) API to allow |
1999 | us to run a shutdown task *after* clients were | 1903 | us to run a shutdown task *after* clients were |
2000 | forcefully disconnected! */ | 1904 | forcefully disconnected! */ |
2001 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1905 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2002 | NULL); | 1906 | _GSS_statistics = GNUNET_STATISTICS_create ("set", cfg); |
2003 | _GSS_statistics = GNUNET_STATISTICS_create ("set", | ||
2004 | cfg); | ||
2005 | cadet = GNUNET_CADET_connect (cfg); | 1907 | cadet = GNUNET_CADET_connect (cfg); |
2006 | if (NULL == cadet) | 1908 | if (NULL == cadet) |
2007 | { | 1909 | { |
2008 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1910 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2009 | _("Could not connect to CADET service\n")); | 1911 | _ ("Could not connect to CADET service\n")); |
2010 | GNUNET_SCHEDULER_shutdown (); | 1912 | GNUNET_SCHEDULER_shutdown (); |
2011 | return; | 1913 | return; |
2012 | } | 1914 | } |
@@ -2016,62 +1918,62 @@ run (void *cls, | |||
2016 | /** | 1918 | /** |
2017 | * Define "main" method using service macro. | 1919 | * Define "main" method using service macro. |
2018 | */ | 1920 | */ |
2019 | GNUNET_SERVICE_MAIN | 1921 | GNUNET_SERVICE_MAIN ( |
2020 | ("set", | 1922 | "set", |
2021 | GNUNET_SERVICE_OPTION_NONE, | 1923 | GNUNET_SERVICE_OPTION_NONE, |
2022 | &run, | 1924 | &run, |
2023 | &client_connect_cb, | 1925 | &client_connect_cb, |
2024 | &client_disconnect_cb, | 1926 | &client_disconnect_cb, |
2025 | NULL, | 1927 | NULL, |
2026 | GNUNET_MQ_hd_fixed_size (client_accept, | 1928 | GNUNET_MQ_hd_fixed_size (client_accept, |
2027 | GNUNET_MESSAGE_TYPE_SET_ACCEPT, | 1929 | GNUNET_MESSAGE_TYPE_SET_ACCEPT, |
2028 | struct GNUNET_SET_AcceptMessage, | 1930 | struct GNUNET_SET_AcceptMessage, |
2029 | NULL), | 1931 | NULL), |
2030 | GNUNET_MQ_hd_fixed_size (client_iter_ack, | 1932 | GNUNET_MQ_hd_fixed_size (client_iter_ack, |
2031 | GNUNET_MESSAGE_TYPE_SET_ITER_ACK, | 1933 | GNUNET_MESSAGE_TYPE_SET_ITER_ACK, |
2032 | struct GNUNET_SET_IterAckMessage, | 1934 | struct GNUNET_SET_IterAckMessage, |
2033 | NULL), | 1935 | NULL), |
2034 | GNUNET_MQ_hd_var_size (client_mutation, | 1936 | GNUNET_MQ_hd_var_size (client_mutation, |
2035 | GNUNET_MESSAGE_TYPE_SET_ADD, | 1937 | GNUNET_MESSAGE_TYPE_SET_ADD, |
2036 | struct GNUNET_SET_ElementMessage, | 1938 | struct GNUNET_SET_ElementMessage, |
2037 | NULL), | 1939 | NULL), |
2038 | GNUNET_MQ_hd_fixed_size (client_create_set, | 1940 | GNUNET_MQ_hd_fixed_size (client_create_set, |
2039 | GNUNET_MESSAGE_TYPE_SET_CREATE, | 1941 | GNUNET_MESSAGE_TYPE_SET_CREATE, |
2040 | struct GNUNET_SET_CreateMessage, | 1942 | struct GNUNET_SET_CreateMessage, |
2041 | NULL), | 1943 | NULL), |
2042 | GNUNET_MQ_hd_fixed_size (client_iterate, | 1944 | GNUNET_MQ_hd_fixed_size (client_iterate, |
2043 | GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, | 1945 | GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, |
2044 | struct GNUNET_MessageHeader, | 1946 | struct GNUNET_MessageHeader, |
2045 | NULL), | 1947 | NULL), |
2046 | GNUNET_MQ_hd_var_size (client_evaluate, | 1948 | GNUNET_MQ_hd_var_size (client_evaluate, |
2047 | GNUNET_MESSAGE_TYPE_SET_EVALUATE, | 1949 | GNUNET_MESSAGE_TYPE_SET_EVALUATE, |
2048 | struct GNUNET_SET_EvaluateMessage, | 1950 | struct GNUNET_SET_EvaluateMessage, |
2049 | NULL), | 1951 | NULL), |
2050 | GNUNET_MQ_hd_fixed_size (client_listen, | 1952 | GNUNET_MQ_hd_fixed_size (client_listen, |
2051 | GNUNET_MESSAGE_TYPE_SET_LISTEN, | 1953 | GNUNET_MESSAGE_TYPE_SET_LISTEN, |
2052 | struct GNUNET_SET_ListenMessage, | 1954 | struct GNUNET_SET_ListenMessage, |
2053 | NULL), | 1955 | NULL), |
2054 | GNUNET_MQ_hd_fixed_size (client_reject, | 1956 | GNUNET_MQ_hd_fixed_size (client_reject, |
2055 | GNUNET_MESSAGE_TYPE_SET_REJECT, | 1957 | GNUNET_MESSAGE_TYPE_SET_REJECT, |
2056 | struct GNUNET_SET_RejectMessage, | 1958 | struct GNUNET_SET_RejectMessage, |
2057 | NULL), | 1959 | NULL), |
2058 | GNUNET_MQ_hd_var_size (client_mutation, | 1960 | GNUNET_MQ_hd_var_size (client_mutation, |
2059 | GNUNET_MESSAGE_TYPE_SET_REMOVE, | 1961 | GNUNET_MESSAGE_TYPE_SET_REMOVE, |
2060 | struct GNUNET_SET_ElementMessage, | 1962 | struct GNUNET_SET_ElementMessage, |
2061 | NULL), | 1963 | NULL), |
2062 | GNUNET_MQ_hd_fixed_size (client_cancel, | 1964 | GNUNET_MQ_hd_fixed_size (client_cancel, |
2063 | GNUNET_MESSAGE_TYPE_SET_CANCEL, | 1965 | GNUNET_MESSAGE_TYPE_SET_CANCEL, |
2064 | struct GNUNET_SET_CancelMessage, | 1966 | struct GNUNET_SET_CancelMessage, |
2065 | NULL), | 1967 | NULL), |
2066 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_prepare, | 1968 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_prepare, |
2067 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, | 1969 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, |
2068 | struct GNUNET_MessageHeader, | 1970 | struct GNUNET_MessageHeader, |
2069 | NULL), | 1971 | NULL), |
2070 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_connect, | 1972 | GNUNET_MQ_hd_fixed_size (client_copy_lazy_connect, |
2071 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, | 1973 | GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, |
2072 | struct GNUNET_SET_CopyLazyConnectMessage, | 1974 | struct GNUNET_SET_CopyLazyConnectMessage, |
2073 | NULL), | 1975 | NULL), |
2074 | GNUNET_MQ_handler_end ()); | 1976 | GNUNET_MQ_handler_end ()); |
2075 | 1977 | ||
2076 | 1978 | ||
2077 | /* end of gnunet-service-set.c */ | 1979 | /* end of gnunet-service-set.c */ |