From: Bart Polot Date: Thu, 12 Dec 2013 18:00:06 +0000 (+0000) Subject: - react to connection destrutcion in exisitng tunnel X-Git-Tag: initial-import-from-subversion-38251~5529 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=223657699f2e2f5b5bfa91a3a08784952e604c2e;p=oweals%2Fgnunet.git - react to connection destrutcion in exisitng tunnel --- diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 9806bf674..06bd15231 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -2564,7 +2564,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, memcpy (data, message, size); type = ntohs (message->type); LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u bytes) on connection %s\n", - GM_m2s (type), size, GMC_2s (c)); + GM_m2s (type), size, GMC_2s (c)); fc = fwd ? &c->fwd_fc : &c->bck_fc; droppable = GNUNET_NO == force; diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 1fb37bcd3..83c024de1 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -768,7 +768,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message, tq->tqd = NULL; } tq->cq = GMC_send_prebuilt_message (&msg->header, c, fwd, force, - &message_sent, tq); + &message_sent, tq); tq->cont = cont; tq->cont_cls = cont_cls; @@ -1748,7 +1748,10 @@ void GMT_remove_connection (struct MeshTunnel3 *t, struct MeshConnection *c) { struct MeshTConnection *aux; + unsigned int i; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing connection %s from tunnel %s\n", + GMC_2s (c), GMT_2s (t)); for (aux = t->connection_head; aux != NULL; aux = aux->next) if (aux->c == c) { @@ -1756,6 +1759,26 @@ GMT_remove_connection (struct MeshTunnel3 *t, struct MeshConnection *c) GNUNET_free (aux); return; } + + /* Start new connections if needed */ + if (NULL == t->connection_head) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections\n"); + GMP_connect (t->peer); + t->cstate = MESH_TUNNEL3_SEARCHING; + return; + } + + /* If not marked as ready, no change is needed */ + if (MESH_TUNNEL3_READY != t->cstate) + return; + + /* Check if any connection is ready to maintaing cstate */ + for (aux = t->connection_head; aux != NULL; aux = aux->next) + if (MESH_CONNECTION_READY == GMC_get_state (aux->c)) + return; + + t->cstate = MESH_TUNNEL3_WAITING; }