aboutsummaryrefslogtreecommitdiff
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
parentc9bc0115c53e10a31ffffb6dbb1cb85e77168dda (diff)
downloadgnunet-d1aa49fc2767aa141e83ba664cd1d10b3ad1987b.tar.gz
gnunet-d1aa49fc2767aa141e83ba664cd1d10b3ad1987b.zip
set profiler: allow variable element size via -w (width) option
-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,
614 614
615 615
616/** 616/**
617 * Clean up after a client has disconnected
618 *
619 * @param cls closure, unused
620 * @param client the client to clean up after
621 * @param internal_cls our client-specific internal data structure
622 */
623static void
624client_disconnect_cb (void *cls,
625 struct GNUNET_SERVICE_Client *client,
626 void *internal_cls)
627{
628 struct Listener *listener;
629 struct Set *set;
630
631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
632 "client disconnected, cleaning up\n");
633 set = set_get (client);
634 if (NULL != set)
635 {
636 set->client = NULL;
637 set_destroy (set);
638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
639 "Client's set destroyed\n");
640 }
641 listener = listener_get (client);
642 if (NULL != listener)
643 {
644 listener->client = NULL;
645 listener_destroy (listener);
646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
647 "Client's listener destroyed\n");
648 }
649}
650
651
652/**
653 * Destroy an incoming request from a remote peer 617 * Destroy an incoming request from a remote peer
654 * 618 *
655 * @param incoming remote request to destroy 619 * @param incoming remote request to destroy
@@ -684,6 +648,52 @@ incoming_destroy (struct Operation *incoming)
684 648
685 649
686/** 650/**
651 * Clean up after a client has disconnected
652 *
653 * @param cls closure, unused
654 * @param client the client to clean up after
655 * @param internal_cls our client-specific internal data structure
656 */
657static void
658client_disconnect_cb (void *cls,
659 struct GNUNET_SERVICE_Client *client,
660 void *internal_cls)
661{
662 struct Set *set;
663
664 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
665 "client disconnected, cleaning up\n");
666 set = set_get (client);
667 if (NULL != set)
668 {
669 set->client = NULL;
670 set_destroy (set);
671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
672 "Client's set destroyed\n");
673 }
674 struct Listener *listener = listener_get (client);
675 struct Operation *op = incoming_head;
676 if (NULL != listener)
677 {
678 /* destroy all incoming operations whose client just
679 * got destroyed */
680 while (NULL != op)
681 {
682 struct Operation *curr = op;
683 op = op->next;
684 if ( (GNUNET_YES == curr->is_incoming) &&
685 (curr->listener == listener) )
686 incoming_destroy (curr);
687 }
688 listener->client = NULL;
689 listener_destroy (listener);
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
691 "Client's listener destroyed\n");
692 }
693}
694
695
696/**
687 * Suggest the given request to the listener. The listening client can 697 * Suggest the given request to the listener. The listening client can
688 * then accept or reject the remote request. 698 * then accept or reject the remote request.
689 * 699 *
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;
62static int force_delta; 62static int force_delta;
63static int force_full; 63static int force_full;
64 64
65static unsigned int element_length = 32;
66
65/** 67/**
66 * Handle to the statistics service. 68 * Handle to the statistics service.
67 */ 69 */
@@ -261,15 +263,17 @@ set_insert_iterator (void *cls,
261 void *value) 263 void *value)
262{ 264{
263 struct GNUNET_SET_Handle *set = cls; 265 struct GNUNET_SET_Handle *set = cls;
264 struct GNUNET_SET_Element *el; 266 struct GNUNET_SET_Element el;
265 267
266 el = GNUNET_malloc (sizeof (struct GNUNET_SET_Element) + 268 GNUNET_assert (element_length > 0);
267 sizeof (struct GNUNET_HashCode)); 269 char payload[element_length];
268 el->element_type = 0; 270
269 GNUNET_memcpy (&el[1], key, sizeof *key); 271 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, payload, element_length);
270 el->data = &el[1]; 272
271 el->size = sizeof *key; 273 el.element_type = 0;
272 GNUNET_SET_add_element (set, el, NULL, NULL); 274 el.data = payload;
275 el.size = element_length;
276 GNUNET_SET_add_element (set, &el, NULL, NULL);
273 GNUNET_free (el); 277 GNUNET_free (el);
274 return GNUNET_YES; 278 return GNUNET_YES;
275} 279}
@@ -432,6 +436,9 @@ main (int argc, char **argv)
432 { 'f', "force-full", NULL, 436 { 'f', "force-full", NULL,
433 gettext_noop ("force sending full set"), 437 gettext_noop ("force sending full set"),
434 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full }, 438 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
439 { 'l', "element-length", NULL,
440 gettext_noop ("element length in byte"),
441 GNUNET_NO, &GNUNET_GETOPT_set_uint, &element_length },
435 { 'd', "force-delta", NULL, 442 { 'd', "force-delta", NULL,
436 gettext_noop ("number delta operation"), 443 gettext_noop ("number delta operation"),
437 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta }, 444 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },