From a3122bfda5ad59fff1d790b3e5daa3044e62bb57 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 18 Oct 2013 11:13:33 +0000 Subject: [PATCH] - fixes --- src/mesh/gnunet-service-mesh_channel.c | 16 +++++++++++++++- src/mesh/gnunet-service-mesh_connection.c | 5 +++-- src/mesh/gnunet-service-mesh_tunnel.c | 10 +++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index bee65c65c..0a74115e3 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -1086,18 +1086,32 @@ GMCH_send_create (struct MeshChannel *ch) /** * Notify a client that the channel is no longer valid. - * FIXME send on tunnel if some client == NULL? * * @param ch Channel that is destroyed. */ void GMCH_send_destroy (struct MeshChannel *ch) { + struct GNUNET_MESH_ChannelManage msg; + + msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY); + msg.header.size = htons (sizeof (msg)); + msg.chid = htonl (ch->gid); + + /* If root is not NULL, notify. + * If it's NULL, check lid_root. When a local destroy comes in, root + * is set to NULL but lid_root is left untouched. In this case, do nothing, + * the client is the one who reuqested the channel to be destroyed. + */ if (NULL != ch->root) GML_send_channel_destroy (ch->root, ch->lid_root); + else if (0 == ch->lid_root) + GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO); if (NULL != ch->dest) GML_send_channel_destroy (ch->dest, ch->lid_dest); + else if (0 == ch->lid_dest) + GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES); } diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 99b156595..afdb801c9 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -1405,13 +1405,14 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, } else { + /* Unexpected peer sending traffic on a connection. */ GNUNET_break_op (0); return GNUNET_OK; } } - fc = fwd ? &c->bck_fc : &c->fwd_fc; /* Check PID */ + fc = fwd ? &c->bck_fc : &c->fwd_fc; pid = ntohl (msg->pid); if (GMC_is_pid_bigger (pid, fc->last_ack_sent)) { @@ -1429,7 +1430,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, pid, fc->last_pid_recv + 1); return GNUNET_OK; } - if (MESH_CONNECTION_SENT == c->state) + if (MESH_CONNECTION_SENT == c->state || MESH_CONNECTION_ACK == c->state) connection_change_state (c, MESH_CONNECTION_READY); connection_reset_timeout (c, fwd); fc->last_pid_recv = pid; diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 11c7019c3..d6922f76a 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -474,7 +474,7 @@ handle_ch_destroy (struct MeshTunnel3 *t, * @param fwd Is this message fwd? */ static void -handle_GMT_decrypted (struct MeshTunnel3 *t, +handle_decrypted (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msgh, int fwd) { @@ -551,7 +551,7 @@ GMT_handle_encrypted (struct MeshTunnel3 *t, while (off < payload_size) { msgh = (struct GNUNET_MessageHeader *) &cbuf[off]; - handle_GMT_decrypted (t, msgh, fwd); + handle_decrypted (t, msgh, fwd); off += ntohs (msgh->size); } } @@ -1172,9 +1172,9 @@ GMT_send_acks (struct MeshTunnel3 *t, int fwd) unsigned int cs; unsigned int buffer; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tunnel send %s ACKs on %s\n", - fwd ? "FWD" : "BCK", GMT_2s (t)); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Tunnel send %s ACKs on %s\n", + fwd ? "FWD" : "BCK", GMT_2s (t)); if (NULL == t) { -- 2.25.1