summaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-28 18:14:19 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-28 18:15:30 +0100
commitd1aa49fc2767aa141e83ba664cd1d10b3ad1987b (patch)
tree35c44a746caa9473bbcea8caa901b77db149a73b /src/set
parentc9bc0115c53e10a31ffffb6dbb1cb85e77168dda (diff)
set profiler: allow variable element size via -w (width) option
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c82
-rw-r--r--src/set/gnunet-set-profiler.c25
2 files changed, 62 insertions, 45 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 4168685f1..b0f8b2091 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -614,42 +614,6 @@ client_connect_cb (void *cls,
/**
- * Clean up after a client has disconnected
- *
- * @param cls closure, unused
- * @param client the client to clean up after
- * @param internal_cls our client-specific internal data structure
- */
-static void
-client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *client,
- void *internal_cls)
-{
- struct Listener *listener;
- struct Set *set;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "client disconnected, cleaning up\n");
- set = set_get (client);
- if (NULL != set)
- {
- set->client = NULL;
- set_destroy (set);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's set destroyed\n");
- }
- listener = listener_get (client);
- if (NULL != listener)
- {
- listener->client = NULL;
- listener_destroy (listener);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's listener destroyed\n");
- }
-}
-
-
-/**
* Destroy an incoming request from a remote peer
*
* @param incoming remote request to destroy
@@ -684,6 +648,52 @@ incoming_destroy (struct Operation *incoming)
/**
+ * Clean up after a client has disconnected
+ *
+ * @param cls closure, unused
+ * @param client the client to clean up after
+ * @param internal_cls our client-specific internal data structure
+ */
+static void
+client_disconnect_cb (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ void *internal_cls)
+{
+ struct Set *set;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "client disconnected, cleaning up\n");
+ set = set_get (client);
+ if (NULL != set)
+ {
+ set->client = NULL;
+ set_destroy (set);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's set destroyed\n");
+ }
+ struct Listener *listener = listener_get (client);
+ struct Operation *op = incoming_head;
+ if (NULL != listener)
+ {
+ /* destroy all incoming operations whose client just
+ * got destroyed */
+ while (NULL != op)
+ {
+ struct Operation *curr = op;
+ op = op->next;
+ if ( (GNUNET_YES == curr->is_incoming) &&
+ (curr->listener == listener) )
+ incoming_destroy (curr);
+ }
+ listener->client = NULL;
+ listener_destroy (listener);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's listener destroyed\n");
+ }
+}
+
+
+/**
* Suggest the given request to the listener. The listening client can
* then accept or reject the remote request.
*
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index d83e034a6..7de58a0d1 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -62,6 +62,8 @@ static int byzantine;
static int force_delta;
static int force_full;
+static unsigned int element_length = 32;
+
/**
* Handle to the statistics service.
*/
@@ -261,15 +263,17 @@ set_insert_iterator (void *cls,
void *value)
{
struct GNUNET_SET_Handle *set = cls;
- struct GNUNET_SET_Element *el;
-
- el = GNUNET_malloc (sizeof (struct GNUNET_SET_Element) +
- sizeof (struct GNUNET_HashCode));
- el->element_type = 0;
- GNUNET_memcpy (&el[1], key, sizeof *key);
- el->data = &el[1];
- el->size = sizeof *key;
- GNUNET_SET_add_element (set, el, NULL, NULL);
+ struct GNUNET_SET_Element el;
+
+ GNUNET_assert (element_length > 0);
+ char payload[element_length];
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, payload, element_length);
+
+ el.element_type = 0;
+ el.data = payload;
+ el.size = element_length;
+ GNUNET_SET_add_element (set, &el, NULL, NULL);
GNUNET_free (el);
return GNUNET_YES;
}
@@ -432,6 +436,9 @@ main (int argc, char **argv)
{ 'f', "force-full", NULL,
gettext_noop ("force sending full set"),
GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
+ { 'l', "element-length", NULL,
+ gettext_noop ("element length in byte"),
+ GNUNET_NO, &GNUNET_GETOPT_set_uint, &element_length },
{ 'd', "force-delta", NULL,
gettext_noop ("number delta operation"),
GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },