From: Bart Polot Date: Wed, 9 Dec 2015 18:56:41 +0000 (+0000) Subject: Another attampt at fixing #4010: mark unavailable neighbors in FlowControl struct... X-Git-Tag: initial-import-from-subversion-38251~1105 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b3d15f0414b5e64ed04cc914b3bf21723d5f0a94;p=oweals%2Fgnunet.git Another attampt at fixing #4010: mark unavailable neighbors in FlowControl struct, test on POLL --- diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index c61f4a53e..c40821c30 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -71,6 +71,7 @@ struct CadetFlowControl /** * How many messages do we accept in the queue. + * If 0, the connection is broken in this direction (next hop disconnected). */ unsigned int queue_max; @@ -1412,6 +1413,11 @@ poll_sent (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL canceled on shutdown\n"); return; } + if (0 == fc->queue_max) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL cancelled: neighbor disconnected\n"); + return; + } LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL sent for %s, scheduling new one!\n", GCC_2s (c)); GNUNET_assert (NULL == fc->poll_task); @@ -3318,6 +3324,7 @@ GCC_allow (struct CadetConnection *c, unsigned int buffer, int fwd) void GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer) { + struct CadetFlowControl *fc; struct CadetPeer *hop; char peer_name[16]; int fwd; @@ -3348,7 +3355,12 @@ GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer) GCC_check_connections (); return; } + /* Mark FlowControl towards the peer as unavaliable. */ + fc = fwd ? &c->bck_fc : &c->fwd_fc; + fc->queue_max = 0; + send_broken (c, &my_full_id, GCP_get_id (peer), fwd); + /* Connection will have at least one pending message * (the one we just scheduled), so delay destruction * and remove from map so we don't use accidentally. */ @@ -3735,6 +3747,13 @@ GCC_start_poll (struct CadetConnection *c, int fwd) fc->poll_task, fc->poll_msg); return; } + if (0 == fc->queue_max) + { + /* Should not be needed, traffic should've been cancelled. */ + GNUNET_break (0); + LOG (GNUNET_ERROR_TYPE_DEBUG, " POLL not possible, peer disconnected\n"); + return; + } LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL started on request\n"); fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, &connection_poll,