gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34426 - in gnunet/src: include set


From: gnunet
Subject: [GNUnet-SVN] r34426 - in gnunet/src: include set
Date: Mon, 24 Nov 2014 14:57:17 +0100

Author: grothoff
Date: 2014-11-24 14:57:17 +0100 (Mon, 24 Nov 2014)
New Revision: 34426

Modified:
   gnunet/src/include/gnunet_set_service.h
   gnunet/src/set/gnunet-service-set.c
   gnunet/src/set/gnunet-service-set.h
   gnunet/src/set/gnunet-service-set_intersection.c
   gnunet/src/set/gnunet-service-set_union.c
Log:
fixing collect_generation_garbage() complexity, doxygen, etc.

Modified: gnunet/src/include/gnunet_set_service.h
===================================================================
--- gnunet/src/include/gnunet_set_service.h     2014-11-23 20:38:01 UTC (rev 
34425)
+++ gnunet/src/include/gnunet_set_service.h     2014-11-24 13:57:17 UTC (rev 
34426)
@@ -133,11 +133,13 @@
    * Client gets every element in the resulting set.
    */
   GNUNET_SET_RESULT_FULL,
+
   /**
    * Client gets only elements that have been added to the set.
    * Only works with set union.
    */
   GNUNET_SET_RESULT_ADDED,
+
   /**
    * Client gets only elements that have been removed from the set.
    * Only works with set intersection.

Modified: gnunet/src/set/gnunet-service-set.c
===================================================================
--- gnunet/src/set/gnunet-service-set.c 2014-11-23 20:38:01 UTC (rev 34425)
+++ gnunet/src/set/gnunet-service-set.c 2014-11-24 13:57:17 UTC (rev 34426)
@@ -42,25 +42,24 @@
   struct GNUNET_PeerIdentity peer;
 
   /**
-   * Unique request id for the request from
-   * a remote peer, sent to the client, which will
-   * accept or reject the request.
-   * Set to '0' iff the request has not been
-   * suggested yet.
+   * Timeout task, if the incoming peer has not been accepted
+   * after the timeout, it will be disconnected.
    */
-  uint32_t suggest_id;
+  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
 
   /**
-   * Timeout task, if the incoming peer has not been accepted
-   * after the timeout, it will be disconnected.
+   * Unique request id for the request from a remote peer, sent to the
+   * client, which will accept or reject the request.  Set to '0' iff
+   * the request has not been suggested yet.
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  uint32_t suggest_id;
+
 };
 
 
 /**
- * A listener is inhabited by a client, and
- * waits for evaluation requests from remote peers.
+ * A listener is inhabited by a client, and waits for evaluation
+ * requests from remote peers.
  */
 struct Listener
 {
@@ -86,15 +85,15 @@
   struct GNUNET_MQ_Handle *client_mq;
 
   /**
-   * The type of the operation.
+   * Application ID for the operation, used to distinguish
+   * multiple operations of the same type with the same peer.
    */
-  enum GNUNET_SET_OperationType operation;
+  struct GNUNET_HashCode app_id;
 
   /**
-   * Application ID for the operation, used to distinguish
-   * multiple operations of the same type with the same peer.
+   * The type of the operation.
    */
-  struct GNUNET_HashCode app_id;
+  enum GNUNET_SET_OperationType operation;
 };
 
 
@@ -104,8 +103,8 @@
 static const struct GNUNET_CONFIGURATION_Handle *configuration;
 
 /**
- * Handle to the cadet service, used
- * to listen for and connect to remote peers.
+ * Handle to the cadet service, used to listen for and connect to
+ * remote peers.
  */
 static struct GNUNET_CADET_Handle *cadet;
 
@@ -130,21 +129,21 @@
 static struct Listener *listeners_tail;
 
 /**
- * Incoming sockets from remote peers are
- * held in a doubly linked list.
+ * Incoming sockets from remote peers are held in a doubly linked
+ * list.
  */
 static struct Operation *incoming_head;
 
 /**
- * Incoming sockets from remote peers are
- * held in a doubly linked list.
+ * Incoming sockets from remote peers are held in a doubly linked
+ * list.
  */
 static struct Operation *incoming_tail;
 
 /**
- * Counter for allocating unique IDs for clients,
- * used to identify incoming operation requests from remote peers,
- * that the client can choose to accept or refuse.
+ * Counter for allocating unique IDs for clients, used to identify
+ * incoming operation requests from remote peers, that the client can
+ * choose to accept or refuse.
  */
 static uint32_t suggest_id = 1;
 
@@ -223,8 +222,10 @@
   if (NULL != listener->client)
   {
     struct GNUNET_SERVER_Client *client = listener->client;
+
     listener->client = NULL;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnecting listener client\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "disconnecting listener client\n");
     GNUNET_SERVER_client_disconnect (client);
     return;
   }
@@ -233,48 +234,95 @@
     GNUNET_MQ_destroy (listener->client_mq);
     listener->client_mq = NULL;
   }
-  GNUNET_CONTAINER_DLL_remove (listeners_head, listeners_tail, listener);
+  GNUNET_CONTAINER_DLL_remove (listeners_head,
+                               listeners_tail,
+                               listener);
   GNUNET_free (listener);
 }
 
 
 /**
+ * Context for the #garbage_collect_cb().
+ */
+struct GarbageContext
+{
+
+  /**
+   * Map for which we are garbage collecting removed elements.
+   */
+  struct GNUNET_CONTAINER_MultiHashMap *map;
+
+  /**
+   * Lowest generation for which an operation is still pending.
+   */
+  unsigned int min_op_generation;
+
+  /**
+   * Largest generation for which an operation is still pending.
+   */
+  unsigned int max_op_generation;
+
+};
+
+
+/**
+ * Function invoked to check if an element can be removed from
+ * the set's history because it is no longer needed.
+ *
+ * @param cls the `struct GarbageContext *`
+ * @param key key of the element in the map
+ * @param value the `struct ElementEntry *`
+ * @return #GNUNET_OK (continue to iterate)
+ */
+static int
+garbage_collect_cb (void *cls,
+                    const struct GNUNET_HashCode *key,
+                    void *value)
+{
+  struct GarbageContext *gc = cls;
+  struct ElementEntry *ee = value;
+
+  if (GNUNET_YES != ee->removed)
+    return GNUNET_OK;
+  if ( (gc->max_op_generation < ee->generation_added) ||
+       (ee->generation_removed > gc->min_op_generation) )
+  {
+    GNUNET_assert (GNUNET_YES ==
+                   GNUNET_CONTAINER_multihashmap_remove (gc->map,
+                                                         key,
+                                                         ee));
+    GNUNET_free (ee);
+  }
+  return GNUNET_OK;
+}
+
+
+/**
  * Collect and destroy elements that are not needed anymore, because
- * their lifetime (as determined by their generation) does not overlap with 
any active
- * set operation.
+ * their lifetime (as determined by their generation) does not overlap
+ * with any active set operation.
  *
- * We hereby replace the old element hashmap with a new one, instead of 
removing elements.
+ * @param set set to garbage collect
  */
-void
+static void
 collect_generation_garbage (struct Set *set)
 {
-  struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
-  struct ElementEntry *ee;
-  struct GNUNET_CONTAINER_MultiHashMap *new_elements;
-  int res;
   struct Operation *op;
+  struct GarbageContext gc;
 
-  new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
-  iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements);
-  while (GNUNET_OK ==
-         (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, 
(const void **) &ee)))
+  gc.min_op_generation = UINT_MAX;
+  gc.max_op_generation = 0;
+  for (op = set->ops_head; NULL != op; op = op->next)
   {
-    if (GNUNET_NO == ee->removed)
-      goto still_needed;
-    for (op = set->ops_head; NULL != op; op = op->next)
-      if ((op->generation_created >= ee->generation_added) &&
-          (op->generation_created < ee->generation_removed))
-        goto still_needed;
-    GNUNET_free (ee);
-    continue;
-still_needed:
-    // we don't expect collisions, thus the replace option
-    GNUNET_CONTAINER_multihashmap_put (new_elements, &ee->element_hash, ee,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
+    gc.min_op_generation = GNUNET_MIN (gc.min_op_generation,
+                                       op->generation_created);
+    gc.max_op_generation = GNUNET_MAX (gc.max_op_generation,
+                                       op->generation_created);
   }
-  GNUNET_CONTAINER_multihashmap_iterator_destroy (iter);
-  GNUNET_CONTAINER_multihashmap_destroy (set->elements);
-  set->elements = new_elements;
+  gc.map = set->elements;
+  GNUNET_CONTAINER_multihashmap_iterate (set->elements,
+                                         &garbage_collect_cb,
+                                         &gc);
 }
 
 

Modified: gnunet/src/set/gnunet-service-set.h
===================================================================
--- gnunet/src/set/gnunet-service-set.h 2014-11-23 20:38:01 UTC (rev 34425)
+++ gnunet/src/set/gnunet-service-set.h 2014-11-24 13:57:17 UTC (rev 34426)
@@ -22,8 +22,8 @@
  * @file set/gnunet-service-set.h
  * @brief common components for the implementation the different set operations
  * @author Florian Dold
+ * @author Christian Grothoff
  */
-
 #ifndef GNUNET_SERVICE_SET_H_PRIVATE
 #define GNUNET_SERVICE_SET_H_PRIVATE
 
@@ -38,24 +38,33 @@
 
 
 /**
- * Implementation-specific set state.
- * Used as opaque pointer, and specified further
- * in the respective implementation.
+ * Implementation-specific set state.  Used as opaque pointer, and
+ * specified further in the respective implementation.
  */
 struct SetState;
 
-
 /**
- * Implementation-specific set operation.
- * Used as opaque pointer, and specified further
- * in the respective implementation.
+ * Implementation-specific set operation.  Used as opaque pointer, and
+ * specified further in the respective implementation.
  */
 struct OperationState;
 
+/**
+ * A set that supports a specific operation with other peers.
+ */
+struct Set;
 
-/* forward declarations */
-struct Set;
+/**
+ * Information about an element element in the set.  All elements are
+ * stored in a hash-table from their hash-code to their 'struct
+ * Element', so that the remove and add operations are reasonably
+ * fast.
+ */
 struct ElementEntry;
+
+/**
+ * Operation context used to execute a set operation.
+ */
 struct Operation;
 
 
@@ -64,13 +73,9 @@
  */
 struct OperationSpecification
 {
-  /**
-   * The type of the operation.
-   */
-  enum GNUNET_SET_OperationType operation;
 
   /**
-   * The remove peer we evaluate the operation with
+   * The remove peer we evaluate the operation with.
    */
   struct GNUNET_PeerIdentity peer;
 
@@ -86,6 +91,12 @@
   struct GNUNET_MessageHeader *context_msg;
 
   /**
+   * Set associated with the operation, NULL until the spec has been
+   * associated with a set.
+   */
+  struct Set *set;
+
+  /**
    * Salt to use for the operation.
    */
   uint32_t salt;
@@ -101,10 +112,9 @@
   uint32_t client_request_id;
 
   /**
-   * Set associated with the operation, NULL until the spec has been associated
-   * with a set.
+   * The type of the operation.
    */
-  struct Set *set;
+  enum GNUNET_SET_OperationType operation;
 
   /**
    * When are elements sent to the client, and which elements are sent?
@@ -113,15 +123,14 @@
 };
 
 
-
-
 /**
  * Signature of functions that create the implementation-specific
  * state for a set supporting a specific operation.
  *
  * @return a set state specific to the supported operation
  */
-typedef struct SetState *(*CreateImpl) (void);
+typedef struct SetState *
+(*CreateImpl) (void);
 
 
 /**
@@ -129,18 +138,21 @@
  * for a set supporting a specific operation.
  *
  * @param set implementation-specific set state
- * @param msg element message from the client
+ * @param ee element message from the client
  */
-typedef void (*AddRemoveImpl) (struct SetState *state, struct ElementEntry 
*ee);
+typedef void
+(*AddRemoveImpl) (struct SetState *state,
+                  struct ElementEntry *ee);
 
 
 /**
- * Signature of functions that handle disconnection
- * of the remote peer.
+ * Signature of functions that handle disconnection of the remote
+ * peer.
  *
  * @param op the set operation, contains implementation-specific data
  */
-typedef void (*PeerDisconnectImpl) (struct Operation *op);
+typedef void
+(*PeerDisconnectImpl) (struct Operation *op);
 
 
 /**
@@ -149,16 +161,18 @@
  *
  * @param state the set state, contains implementation-specific data
  */
-typedef void (*DestroySetImpl) (struct SetState *state);
+typedef void
+(*DestroySetImpl) (struct SetState *state);
 
 
 /**
  * Signature of functions that implement the creation of set operations
- * (currently evaluate and accept).
+ * (currently "evaluate" and "accept").
  *
  * @param op operation that is created, should be initialized by the 
implementation
  */
-typedef void (*OpCreateImpl) (struct Operation *op);
+typedef void
+(*OpCreateImpl) (struct Operation *op);
 
 
 /**
@@ -167,24 +181,26 @@
  *
  * @param op operation state
  * @param msg received message
- * @return GNUNET_OK on success, GNUNET_SYSERR to
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR to
  *         destroy the operation and the tunnel
  */
-typedef int (*MsgHandlerImpl) (struct Operation *op,
-                               const struct GNUNET_MessageHeader *msg);
+typedef int
+(*MsgHandlerImpl) (struct Operation *op,
+                   const struct GNUNET_MessageHeader *msg);
 
+
 /**
  * Signature of functions that implement operation cancellation
  *
  * @param op operation state
  */
-typedef void (*CancelImpl) (struct Operation *op);
+typedef void
+(*CancelImpl) (struct Operation *op);
 
 
 /**
- * Dispatch table for a specific set operation.
- * Every set operation has to implement the callback
- * in this struct.
+ * Dispatch table for a specific set operation.  Every set operation
+ * has to implement the callback in this struct.
  */
 struct SetVT
 {
@@ -224,24 +240,21 @@
   MsgHandlerImpl msg_handler;
 
   /**
-   * Callback for handling the remote peer's
-   * disconnect.
+   * Callback for handling the remote peer's disconnect.
    */
   PeerDisconnectImpl peer_disconnect;
 
   /**
-   * Callback for canceling an operation by
-   * its ID.
+   * Callback for canceling an operation by its ID.
    */
   CancelImpl cancel;
 };
 
 
 /**
- * Information about an element element in the set.
- * All elements are stored in a hash-table
- * from their hash-code to their 'struct Element',
- * so that the remove and add operations are reasonably
+ * Information about an element element in the set.  All elements are
+ * stored in a hash-table from their hash-code to their `struct
+ * Element`, so that the remove and add operations are reasonably
  * fast.
  */
 struct ElementEntry
@@ -253,10 +266,8 @@
   struct GNUNET_SET_Element element;
 
   /**
-   * Hash of the element.
-   * For set union:
-   * Will be used to derive the different IBF keys
-   * for different salts.
+   * Hash of the element.  For set union: Will be used to derive the
+   * different IBF keys for different salts.
    */
   struct GNUNET_HashCode element_hash;
 
@@ -267,32 +278,32 @@
   unsigned int generation_added;
 
   /**
-   * GNUNET_YES if the element has been removed in some generation.
-   */
-  int removed;
-
-  /**
    * Generation the element was removed by the client.
    * Operations of later generations will not consider the element.
-   * Only valid if is_removed is GNUNET_YES.
+   * Only valid if @e removed is #GNUNET_YES.
    */
   unsigned int generation_removed;
 
   /**
-   * GNUNET_YES if the element is a remote element, and does not belong
+   * #GNUNET_YES if the element has been removed in some generation.
+   */
+  int removed;
+
+  /**
+   * #GNUNET_YES if the element is a remote element, and does not belong
    * to the operation's set.
-   *
-   * //TODO: Move to Union, unless additional set-operations are implemented 
ever
    */
   int remote;
 };
 
 
+/**
+ * Operation context used to execute a set operation.
+ */
 struct Operation
 {
   /**
-   * V-Table for the operation belonging
-   * to the tunnel contest.
+   * V-Table for the operation belonging to the tunnel contest.
    *
    * Used for all operation specific operations after receiving the ops request
    */
@@ -309,21 +320,8 @@
   struct GNUNET_MQ_Handle *mq;
 
   /**
-   * GNUNET_YES if this is not a "real" set operation yet, and we still
-   * need to wait for the other peer to give us more details.
-   */
-  int is_incoming;
-
-  /**
-   * Generation in which the operation handle
-   * was created.
-   */
-  unsigned int generation_created;
-
-  /**
-   * Detail information about the set operation,
-   * including the set to use.
-   * When 'spec' is NULL, the operation is not yet entirely
+   * Detail information about the set operation, including the set to
+   * use.  When 'spec' is NULL, the operation is not yet entirely
    * initialized.
    */
   struct OperationSpecification *spec;
@@ -334,50 +332,65 @@
   struct OperationState *state;
 
   /**
-   * Evaluate operations are held in
-   * a linked list.
+   * Evaluate operations are held in a linked list.
    */
   struct Operation *next;
 
-   /**
-    * Evaluate operations are held in
-    * a linked list.
-    */
+  /**
+   * Evaluate operations are held in a linked list.
+   */
   struct Operation *prev;
 
   /**
-   * Set to GNUNET_YES if the set service should not free
-   * the operation, as it is still needed (e.g. in some scheduled task).
+   * #GNUNET_YES if this is not a "real" set operation yet, and we still
+   * need to wait for the other peer to give us more details.
    */
+  int is_incoming;
+
+  /**
+   * Generation in which the operation handle
+   * was created.
+   */
+  unsigned int generation_created;
+
+  /**
+   * Set to #GNUNET_YES if the set service should not free the
+   * operation, as it is still needed (e.g. in some scheduled task).
+   */
   int keep;
 };
 
 
 /**
- * A set that supports a specific operation
- * with other peers.
+ * A set that supports a specific operation with other peers.
  */
 struct Set
 {
+
   /**
-   * Client that owns the set.
-   * Only one client may own a set.
+   * Sets are held in a doubly linked list (in `sets_head` and `sets_tail`).
    */
-  struct GNUNET_SERVER_Client *client;
+  struct Set *next;
 
   /**
-   * Message queue for the client
+   * Sets are held in a doubly linked list.
    */
-  struct GNUNET_MQ_Handle *client_mq;
+  struct Set *prev;
 
   /**
-   * Type of operation supported for this set
+   * Client that owns the set.  Only one client may own a set,
+   * and there can only be one set per client.
    */
-  enum GNUNET_SET_OperationType operation;
+  struct GNUNET_SERVER_Client *client;
 
   /**
-   * Virtual table for this set.
-   * Determined by the operation type of this set.
+   * Message queue for the client.
+   */
+  struct GNUNET_MQ_Handle *client_mq;
+
+  /**
+   * Virtual table for this set.  Determined by the operation type of
+   * this set.
    *
    * Used only for Add/remove of elements and when receiving an incoming
    * operation from a remote peer.
@@ -385,16 +398,6 @@
   const struct SetVT *vt;
 
   /**
-   * Sets are held in a doubly linked list.
-   */
-  struct Set *next;
-
-  /**
-   * Sets are held in a doubly linked list.
-   */
-  struct Set *prev;
-
-  /**
    * Implementation-specific state.
    */
   struct SetState *state;
@@ -406,34 +409,39 @@
   struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
 
   /**
-   * Maps 'struct GNUNET_HashCode' to 'struct ElementEntry'.
+   * Maps `struct GNUNET_HashCode *` to `struct ElementEntry *`.
    */
   struct GNUNET_CONTAINER_MultiHashMap *elements;
 
   /**
-   * Current generation, that is, number of
-   * previously executed operations on this set
+   * Evaluate operations are held in a linked list.
    */
-  unsigned int current_generation;
+  struct Operation *ops_head;
 
   /**
-   * Evaluate operations are held in
-   * a linked list.
+   * Evaluate operations are held in a linked list.
    */
-  struct Operation *ops_head;
+  struct Operation *ops_tail;
 
   /**
-   * Evaluate operations are held in
-   * a linked list.
+   * Current generation, that is, number of previously executed
+   * operations on this set
    */
-  struct Operation *ops_tail;
+  unsigned int current_generation;
+
+  /**
+   * Type of operation supported for this set
+   */
+  enum GNUNET_SET_OperationType operation;
+
 };
 
 
 /**
- * Destroy the given operation.  Call the implementation-specific cancel 
function
- * of the operation.  Disconnects from the remote peer.
- * Does not disconnect the client, as there may be multiple operations per set.
+ * Destroy the given operation.  Call the implementation-specific
+ * cancel function of the operation.  Disconnects from the remote
+ * peer.  Does not disconnect the client, as there may be multiple
+ * operations per set.
  *
  * @param op operation to destroy
  */
@@ -442,8 +450,7 @@
 
 
 /**
- * Get the table with implementing functions for
- * set union.
+ * Get the table with implementing functions for set union.
  *
  * @return the operation specific VTable
  */
@@ -452,8 +459,7 @@
 
 
 /**
- * Get the table with implementing functions for
- * set intersection.
+ * Get the table with implementing functions for set intersection.
  *
  * @return the operation specific VTable
  */

Modified: gnunet/src/set/gnunet-service-set_intersection.c
===================================================================
--- gnunet/src/set/gnunet-service-set_intersection.c    2014-11-23 20:38:01 UTC 
(rev 34425)
+++ gnunet/src/set/gnunet-service-set_intersection.c    2014-11-24 13:57:17 UTC 
(rev 34426)
@@ -17,7 +17,6 @@
       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       Boston, MA 02111-1307, USA.
 */
-
 /**
  * @file set/gnunet-service-set_intersection.c
  * @brief two-peer set intersection
@@ -86,59 +85,57 @@
   struct GNUNET_CONTAINER_BloomFilter *local_bf;
 
   /**
-   * for multipart msgs we have to store the bloomfilter-data until we fully 
sent it.
+   * Iterator for sending elements on the key to element mapping to the client.
    */
-  char * bf_data;
+  struct GNUNET_CONTAINER_MultiHashMapIterator *full_result_iter;
 
   /**
-   * size of the bloomfilter
+   * Evaluate operations are held in a linked list.
    */
-  uint32_t bf_data_size;
+  struct OperationState *next;
 
   /**
-   * size of the bloomfilter
+   * Evaluate operations are held in a linked list.
    */
-  uint32_t bf_bits_per_element;
+  struct OperationState *prev;
 
   /**
-   * Current state of the operation.
+   * for multipart msgs we have to store the bloomfilter-data until we fully 
sent it.
    */
-  enum IntersectionOperationPhase phase;
+  char *bf_data;
 
   /**
-   * Generation in which the operation handle
-   * was created.
-   */
-  unsigned int generation_created;
-
-  /**
    * Maps element-id-hashes to 'elements in our set'.
    */
   struct GNUNET_CONTAINER_MultiHashMap *my_elements;
 
   /**
-   * Current element count contained within contained_elements
+   * Current element count contained within @e my_elements
    */
   uint32_t my_element_count;
 
   /**
-   * Iterator for sending elements on the key to element mapping to the client.
+   * size of the bloomfilter in @e bf_data.
    */
-  struct GNUNET_CONTAINER_MultiHashMapIterator *full_result_iter;
+  uint32_t bf_data_size;
 
   /**
-   * Evaluate operations are held in
-   * a linked list.
+   * size of the bloomfilter
    */
-  struct OperationState *next;
+  uint32_t bf_bits_per_element;
 
-   /**
-    * Evaluate operations are held in
-    * a linked list.
-    */
-  struct OperationState *prev;
+  /**
+   * Current state of the operation.
+   */
+  enum IntersectionOperationPhase phase;
 
   /**
+   * Generation in which the operation handle
+   * was created.
+   */
+  unsigned int generation_created;
+
+  /**
    * Did we send the client that we are done?
    */
   int client_done_sent;
@@ -237,6 +234,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * fills the contained-elements hashmap with all relevant
  * elements and adds their mutated hashes to our local bloomfilter
@@ -1093,9 +1091,16 @@
   }*/
   GNUNET_free (op->state);
   op->state = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying intersection op done\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "destroying intersection op done\n");
 }
 
+
+/**
+ * Get the table with implementing functions for set intersection.
+ *
+ * @return the operation specific VTable
+ */
 const struct SetVT *
 _GSS_intersection_vt ()
 {

Modified: gnunet/src/set/gnunet-service-set_union.c
===================================================================
--- gnunet/src/set/gnunet-service-set_union.c   2014-11-23 20:38:01 UTC (rev 
34425)
+++ gnunet/src/set/gnunet-service-set_union.c   2014-11-24 13:57:17 UTC (rev 
34426)
@@ -478,7 +478,8 @@
  * @param ee the element entry
  */
 static void
-op_register_element (struct Operation *op, struct ElementEntry *ee)
+op_register_element (struct Operation *op,
+                     struct ElementEntry *ee)
 {
   int ret;
   struct IBF_Key ibf_key;
@@ -1089,7 +1090,8 @@
   struct ElementEntry *ee;
   uint16_t element_size;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got element from peer\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "got element from peer\n");
 
   if ( (op->state->phase != PHASE_EXPECT_ELEMENTS) &&
        (op->state->phase != PHASE_EXPECT_ELEMENTS_AND_REQUESTS) )
@@ -1099,16 +1101,19 @@
     return;
   }
   element_size = ntohs (mh->size) - sizeof (struct GNUNET_MessageHeader);
-  ee = GNUNET_malloc (sizeof *ee + element_size);
+  ee = GNUNET_malloc (sizeof (struct ElementEntry) + element_size);
   memcpy (&ee[1], &mh[1], element_size);
   ee->element.size = element_size;
   ee->element.data = &ee[1];
   ee->remote = GNUNET_YES;
-  GNUNET_CRYPTO_hash (ee->element.data, ee->element.size, &ee->element_hash);
+  GNUNET_CRYPTO_hash (ee->element.data,
+                      ee->element.size,
+                      &ee->element_hash);
 
   if (GNUNET_YES == op_has_element (op, &ee->element_hash))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got existing element from peer\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "got existing element from peer\n");
     GNUNET_free (ee);
     return;
   }
@@ -1127,7 +1132,8 @@
  * @param mh the message
  */
 static void
-handle_p2p_element_requests (void *cls, const struct GNUNET_MessageHeader *mh)
+handle_p2p_element_requests (void *cls,
+                             const struct GNUNET_MessageHeader *mh)
 {
   struct Operation *op = cls;
   struct IBF_Key *ibf_key;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]