aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-05-06 15:09:34 +0000
committerBart Polot <bart@net.in.tum.de>2013-05-06 15:09:34 +0000
commit2a95087a42e62852573086e8b993a120d2931807 (patch)
tree03d1a2a64fd67d3e0dbda0ebaa621cd890fcb594 /src
parent5db8393ac0292d55042f8a01f72541b3c9104387 (diff)
downloadgnunet-2a95087a42e62852573086e8b993a120d2931807.tar.gz
gnunet-2a95087a42e62852573086e8b993a120d2931807.zip
- unify testbed operation handlers, avoid pointer arithmetic
Diffstat (limited to 'src')
-rw-r--r--src/regex/gnunet-regex-profiler.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index 8c36e440c..04c8a8e71 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -163,11 +163,6 @@ struct RegexPeer
163 struct GNUNET_STATISTICS_Handle *stats_handle; 163 struct GNUNET_STATISTICS_Handle *stats_handle;
164 164
165 /** 165 /**
166 * Testbed operation handle for the statistics service.
167 */
168 struct GNUNET_TESTBED_Operation *stats_op_handle;
169
170 /**
171 * The starting time of a profiling step. 166 * The starting time of a profiling step.
172 */ 167 */
173 struct GNUNET_TIME_Absolute prof_start_time; 168 struct GNUNET_TIME_Absolute prof_start_time;
@@ -386,17 +381,6 @@ stats_connect_cb (void *cls,
386 381
387 382
388/** 383/**
389 * Task to collect all statistics from s, will shutdown the
390 * profiler, when done.
391 *
392 * @param cls NULL
393 * @param tc the task context
394 */
395static void
396do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
397
398
399/**
400 * Start announcing the next regex in the DHT. 384 * Start announcing the next regex in the DHT.
401 * 385 *
402 * @param cls Index of the next peer in the peers array. 386 * @param cls Index of the next peer in the peers array.
@@ -456,8 +440,6 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
456 440
457 if (NULL != peers[peer_cnt].op_handle) 441 if (NULL != peers[peer_cnt].op_handle)
458 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle); 442 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle);
459 if (NULL != peers[peer_cnt].stats_op_handle)
460 GNUNET_TESTBED_operation_done (peers[peer_cnt].stats_op_handle);
461 } 443 }
462 444
463 if (NULL != data_file) 445 if (NULL != data_file)
@@ -606,10 +588,10 @@ stats_cb (void *cls,
606 return; 588 return;
607 } 589 }
608 590
609 GNUNET_assert (NULL != peer->stats_op_handle); 591 GNUNET_assert (NULL != peer->op_handle);
610 592
611 GNUNET_TESTBED_operation_done (peer->stats_op_handle); 593 GNUNET_TESTBED_operation_done (peer->op_handle);
612 peer->stats_op_handle = NULL; 594 peer->op_handle = NULL;
613 595
614 peer_cnt++; 596 peer_cnt++;
615 peer = &peers[peer_cnt]; 597 peer = &peers[peer_cnt];
@@ -621,7 +603,7 @@ stats_cb (void *cls,
621 } 603 }
622 else 604 else
623 { 605 {
624 peer->stats_op_handle = 606 peer->op_handle =
625 GNUNET_TESTBED_service_connect (NULL, 607 GNUNET_TESTBED_service_connect (NULL,
626 peer->peer_handle, 608 peer->peer_handle,
627 "statistics", 609 "statistics",
@@ -688,7 +670,7 @@ do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
688 670
689 GNUNET_assert (NULL != peer->peer_handle); 671 GNUNET_assert (NULL != peer->peer_handle);
690 672
691 peer->stats_op_handle = 673 peer->op_handle =
692 GNUNET_TESTBED_service_connect (NULL, 674 GNUNET_TESTBED_service_connect (NULL,
693 peer->peer_handle, 675 peer->peer_handle,
694 "statistics", 676 "statistics",
@@ -892,7 +874,8 @@ find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
892 unsigned int search_peer = (unsigned int) (long) cls; 874 unsigned int search_peer = (unsigned int) (long) cls;
893 875
894 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || 876 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) ||
895 search_peer >= num_peers) 877 search_peer >= num_peers ||
878 GNUNET_YES == in_shutdown)
896 return; 879 return;
897 880
898 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 881 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -933,15 +916,13 @@ daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op,
933 struct RegexPeer *peer = (struct RegexPeer *) cls; 916 struct RegexPeer *peer = (struct RegexPeer *) cls;
934 unsigned long search_peer; 917 unsigned long search_peer;
935 unsigned int i; 918 unsigned int i;
936 unsigned int me;
937 919
938 GNUNET_TESTBED_operation_done (peer->daemon_op); 920 GNUNET_TESTBED_operation_done (peer->daemon_op);
939 peer->daemon_op = NULL; 921 peer->daemon_op = NULL;
940 me = peer - peers;
941 if (NULL != emsg) 922 if (NULL != emsg)
942 { 923 {
943 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 924 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
944 "Failed to start/stop daemon at peer %u: %s\n", me, emsg); 925 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
945 GNUNET_abort (); 926 GNUNET_abort ();
946 } 927 }
947 928
@@ -954,7 +935,7 @@ daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op,
954 if (i > num_peers) 935 if (i > num_peers)
955 GNUNET_abort (); /* we ran out of peers, must be a bug */ 936 GNUNET_abort (); /* we ran out of peers, must be a bug */
956 } 937 }
957 peers[search_peer].search_str = search_strings[me]; 938 peers[search_peer].search_str = search_strings[peer->id];
958 peers[search_peer].search_str_matched = GNUNET_NO; 939 peers[search_peer].search_str_matched = GNUNET_NO;
959 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( 940 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
960 reannounce_period_max, 941 reannounce_period_max,