From f65ed3aab8bf35e48934cdccf4ec5b64e4b14e88 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 4 Jul 2014 12:29:08 +0000 Subject: [PATCH] - fix #3483 --- src/cadet/gnunet-service-cadet_connection.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index f6ac0ef8f..a706aeed3 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -1809,6 +1809,7 @@ GCC_handle_broken (void* cls, struct GNUNET_MessageHeader *out_msg; struct CadetPeer *neighbor; struct CadetPeer *endpoint; + int pending_msgs; neighbor = get_hop (c, !fwd); endpoint = GCP_get_short (c->path->peers[c->path->length - 1]); @@ -1816,14 +1817,24 @@ GCC_handle_broken (void* cls, GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2); c->state = CADET_CONNECTION_DESTROYED; t = c->t; + pending_msgs = c->pending_messages; while (NULL != (out_msg = GCP_connection_pop (neighbor, c))) { GNUNET_assert (NULL == GCT_send_prebuilt_message (out_msg, t, NULL, GNUNET_YES, NULL, NULL)); + pending_msgs--; } - GCC_destroy (c); + /* All pending messages should have been popped and the connection + * destroyed. If not, destroy the connection anyway! */ + if (0 < pending_msgs) + { + GNUNET_break (0); + GCC_destroy (c); + } + else + GNUNET_break (0 == pending_msgs); /* Counter error! */ } else { -- 2.25.1