Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / set / set_api.c
index 2b09725e8ccbfe9c7e9350674d96523f691efaa3..04a4e49108f6a7d2661f369d989fb78314f5839c 100644 (file)
@@ -349,6 +349,9 @@ handle_iter_done (void *cls,
   set->iteration_id++;
   iter (set->iterator_cls,
         NULL);
+
+  if (GNUNET_YES == set->destroy_requested)
+    GNUNET_SET_destroy (set);
 }
 
 
@@ -432,6 +435,7 @@ do_final:
   {
     oh->result_cb (oh->result_cls,
                    NULL,
+                   GNUNET_ntohll (msg->current_size),
                    result_status);
   }
   else
@@ -453,6 +457,7 @@ do_element:
   if (NULL != oh->result_cb)
     oh->result_cb (oh->result_cls,
                    &e,
+                   GNUNET_ntohll (msg->current_size),
                    result_status);
 }
 
@@ -538,6 +543,7 @@ handle_client_set_error (void *cls,
     if (NULL != set->ops_head->result_cb)
       set->ops_head->result_cb (set->ops_head->result_cls,
                                 NULL,
+                                0,
                                 GNUNET_SET_STATUS_FAILURE);
     set_operation_destroy (set->ops_head);
   }
@@ -654,6 +660,8 @@ GNUNET_SET_add_element (struct GNUNET_SET_Handle *set,
   struct GNUNET_MQ_Envelope *mqm;
   struct GNUNET_SET_ElementMessage *msg;
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "adding element of type %u\n", (unsigned) element->element_type);
+
   if (GNUNET_YES == set->invalid)
   {
     if (NULL != cont)
@@ -728,8 +736,7 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set)
   /* destroying set while iterator is active is currently
      not supported; we should expand the API to allow
      clients to explicitly cancel the iteration! */
-  GNUNET_assert (NULL == set->iterator);
-  if (NULL != set->ops_head)
+  if ( (NULL != set->ops_head) || (NULL != set->iterator) )
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Set operations are pending, delaying set destruction\n");