aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-service-set.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-18 18:59:45 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-18 19:00:18 +0100
commit2beedf90ffdc6d9eb3d13e0868411cf371d06ff6 (patch)
treeccc70760b7f19c9ecd73a1bcc92a21e4217cde2d /src/set/gnunet-service-set.c
parent6fa8e1c652f447ebd94e144314ce55412dab80c8 (diff)
downloadgnunet-2beedf90ffdc6d9eb3d13e0868411cf371d06ff6.tar.gz
gnunet-2beedf90ffdc6d9eb3d13e0868411cf371d06ff6.zip
append to TAIL of mutation list for processing in right order
Diffstat (limited to 'src/set/gnunet-service-set.c')
-rw-r--r--src/set/gnunet-service-set.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 5633561ac..a545e8a06 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -805,16 +805,16 @@ execute_add (struct Set *set,
805 el.data = &msg[1]; 805 el.data = &msg[1];
806 el.element_type = ntohs (msg->element_type); 806 el.element_type = ntohs (msg->element_type);
807 GNUNET_SET_element_hash (&el, &hash); 807 GNUNET_SET_element_hash (&el, &hash);
808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
809 "Client inserts element %s of size %u\n",
810 GNUNET_h2s (&hash),
811 el.size);
812 808
813 ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, 809 ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements,
814 &hash); 810 &hash);
815 811
816 if (NULL == ee) 812 if (NULL == ee)
817 { 813 {
814 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
815 "Client inserts element %s of size %u\n",
816 GNUNET_h2s (&hash),
817 el.size);
818 ee = GNUNET_malloc (el.size + sizeof *ee); 818 ee = GNUNET_malloc (el.size + sizeof *ee);
819 ee->element.size = el.size; 819 ee->element.size = el.size;
820 GNUNET_memcpy (&ee[1], 820 GNUNET_memcpy (&ee[1],
@@ -834,6 +834,11 @@ execute_add (struct Set *set,
834 } 834 }
835 else if (GNUNET_YES == _GSS_is_element_of_set (ee, set)) 835 else if (GNUNET_YES == _GSS_is_element_of_set (ee, set))
836 { 836 {
837 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
838 "Client inserted element %s of size %u twice (ignored)\n",
839 GNUNET_h2s (&hash),
840 el.size);
841
837 /* same element inserted twice */ 842 /* same element inserted twice */
838 return; 843 return;
839 } 844 }
@@ -843,7 +848,9 @@ execute_add (struct Set *set,
843 .generation = set->current_generation, 848 .generation = set->current_generation,
844 .added = GNUNET_YES 849 .added = GNUNET_YES
845 }; 850 };
846 GNUNET_array_append (ee->mutations, ee->mutations_size, mut); 851 GNUNET_array_append (ee->mutations,
852 ee->mutations_size,
853 mut);
847 } 854 }
848 855
849 set->vt->add (set->state, ee); 856 set->vt->add (set->state, ee);
@@ -863,9 +870,6 @@ execute_remove (struct Set *set,
863 870
864 msg = (const struct GNUNET_SET_ElementMessage *) m; 871 msg = (const struct GNUNET_SET_ElementMessage *) m;
865 el.size = ntohs (m->size) - sizeof *msg; 872 el.size = ntohs (m->size) - sizeof *msg;
866 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
867 "Client removes element of size %u\n",
868 el.size);
869 el.data = &msg[1]; 873 el.data = &msg[1];
870 el.element_type = ntohs (msg->element_type); 874 el.element_type = ntohs (msg->element_type);
871 GNUNET_SET_element_hash (&el, &hash); 875 GNUNET_SET_element_hash (&el, &hash);
@@ -874,11 +878,17 @@ execute_remove (struct Set *set,
874 if (NULL == ee) 878 if (NULL == ee)
875 { 879 {
876 /* Client tried to remove non-existing element. */ 880 /* Client tried to remove non-existing element. */
881 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
882 "Client removes non-existing element of size %u\n",
883 el.size);
877 return; 884 return;
878 } 885 }
879 if (GNUNET_NO == _GSS_is_element_of_set (ee, set)) 886 if (GNUNET_NO == _GSS_is_element_of_set (ee, set))
880 { 887 {
881 /* Client tried to remove element twice */ 888 /* Client tried to remove element twice */
889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
890 "Client removed element of size %u twice (ignored)\n",
891 el.size);
882 return; 892 return;
883 } 893 }
884 else 894 else
@@ -887,7 +897,14 @@ execute_remove (struct Set *set,
887 .generation = set->current_generation, 897 .generation = set->current_generation,
888 .added = GNUNET_NO 898 .added = GNUNET_NO
889 }; 899 };
890 GNUNET_array_append (ee->mutations, ee->mutations_size, mut); 900
901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
902 "Client removes element of size %u\n",
903 el.size);
904
905 GNUNET_array_append (ee->mutations,
906 ee->mutations_size,
907 mut);
891 } 908 }
892 set->vt->remove (set->state, ee); 909 set->vt->remove (set->state, ee);
893} 910}
@@ -1505,9 +1522,9 @@ handle_client_mutation (void *cls,
1505 pm = GNUNET_new (struct PendingMutation); 1522 pm = GNUNET_new (struct PendingMutation);
1506 pm->mutation_message = GNUNET_copy_message (m); 1523 pm->mutation_message = GNUNET_copy_message (m);
1507 pm->set = set; 1524 pm->set = set;
1508 GNUNET_CONTAINER_DLL_insert (set->content->pending_mutations_head, 1525 GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head,
1509 set->content->pending_mutations_tail, 1526 set->content->pending_mutations_tail,
1510 pm); 1527 pm);
1511 return; 1528 return;
1512 } 1529 }
1513 execute_mutation (set, m); 1530 execute_mutation (set, m);