From e7952b62750bbebe5c4203da6b42da4ac34d35b3 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 14 Mar 2013 13:51:46 +0000 Subject: - fix arm_api crash --- src/regex/gnunet-daemon-regexprofiler.c | 8 +++++--- src/regex/gnunet-regex-profiler.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/regex') diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index fd6a97d07..711f7fa42 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c @@ -151,9 +151,11 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (unsigned int) max_path_compression, stats_handle); } - /* Will result in a double first announce */ - GNUNET_assert (NULL != announce_handle); - GNUNET_REGEX_reannounce (announce_handle); + else + { + GNUNET_assert (NULL != announce_handle); + GNUNET_REGEX_reannounce (announce_handle); + } random_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, GNUNET_CRYPTO_random_u32 ( diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 0f9574c8b..029ea5b94 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c @@ -1048,6 +1048,23 @@ arm_da (void *cls, void *op_result) } } +/** + * Finish and free the operation used to start the regex daemon. + * operation_done calls ARM_disconnect, which cannot happen inside an + * ARM callback. + * + * @param cls Closure (Peer info) + * @param tc TaskContext + */ +static void +arm_op_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct RegexPeer *peer = (struct RegexPeer *) cls; + + GNUNET_TESTBED_operation_done (peer->op_handle); + peer->op_handle = NULL; +} + static void arm_start_cb (void *cls, struct GNUNET_ARM_Handle *arm, enum GNUNET_ARM_RequestStatus rs, const char *service, @@ -1074,8 +1091,7 @@ arm_start_cb (void *cls, struct GNUNET_ARM_Handle *arm, * Service is currently being started (due to client request). */ case GNUNET_ARM_RESULT_STARTING: - GNUNET_TESTBED_operation_done (peer->op_handle); - peer->op_handle = NULL; + GNUNET_SCHEDULER_add_now (&arm_op_done, peer); if (peer_cnt < (num_peers - 1)) { -- cgit v1.2.3