From f5164502be55aa48ea4c3b44167e19ac15ba53af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julius=20B=C3=BCnger?= Date: Fri, 13 Jul 2018 01:11:32 +0200 Subject: [PATCH] rps profiler: proper disconnect from service --- src/rps/gnunet-rps-profiler.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 02259d628..a06598764 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c @@ -883,6 +883,9 @@ static int check_statistics_collect_completed () return GNUNET_YES; } +static void +rps_disconnect_adapter (void *cls, + void *op_result); static void cancel_pending_req (struct PendingRequest *pending_req) @@ -928,15 +931,8 @@ clean_peer (unsigned peer_index) cancel_request (pending_rep); } pending_req = rps_peers[peer_index].pending_req_head; - while (NULL != (pending_req = rps_peers[peer_index].pending_req_head)) - { - cancel_pending_req (pending_req); - } - if (NULL != rps_peers[peer_index].rps_handle) - { - GNUNET_RPS_disconnect (rps_peers[peer_index].rps_handle); - rps_peers[peer_index].rps_handle = NULL; - } + rps_disconnect_adapter (&rps_peers[peer_index], + &rps_peers[peer_index].rps_handle); for (unsigned stat_type = STAT_TYPE_ROUNDS; stat_type < STAT_TYPE_MAX; stat_type++) @@ -1277,6 +1273,7 @@ rps_disconnect_adapter (void *cls, { struct RPSPeer *peer = cls; struct GNUNET_RPS_Handle *h = op_result; + struct PendingRequest *pending_req; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect_adapter (%u)\n", @@ -1284,6 +1281,10 @@ rps_disconnect_adapter (void *cls, GNUNET_assert (NULL != peer); if (NULL != peer->rps_handle) { + while (NULL != (pending_req = peer->pending_req_head)) + { + cancel_pending_req (pending_req); + } GNUNET_assert (h == peer->rps_handle); GNUNET_RPS_disconnect (h); peer->rps_handle = NULL; -- 2.25.1