X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmesh%2Fgnunet-service-mesh_channel.c;h=06cf599d4ca6c89e5a9933eee2f47cb9a630a886;hb=e43078b68951ad8a3daa3a193473e9c321549e1d;hp=bf1a127c5d8fc1080b80e582812d66fecbc4fdff;hpb=58cda642bdd13b46cb85b109a9d54f9c37dceebd;p=oweals%2Fgnunet.git diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index bf1a127c5..06cf599d4 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -636,7 +636,7 @@ send_client_nack (struct MeshChannel *ch) GNUNET_break (0); return; } - GML_send_nack (ch->root, ch->lid_root); + GML_send_channel_nack (ch->root, ch->lid_root); } @@ -741,7 +741,7 @@ ch_message_sent (void *cls, rel = copy->rel; if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in %s\n", + LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in 4 * %s\n", GNUNET_STRINGS_relative_time_to_string (rel->expected_delay, GNUNET_YES)); if (0 != rel->expected_delay.rel_value_us) @@ -780,7 +780,8 @@ ch_message_sent (void *cls, rel->uniq = NULL; if (MESH_CHANNEL_READY != rel->ch->state - && GNUNET_MESSAGE_TYPE_MESH_DATA_ACK != type) + && GNUNET_MESSAGE_TYPE_MESH_DATA_ACK != type + && GNUNET_NO == rel->ch->destroy) { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rel->retry_task); LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! STD BACKOFF %s\n", @@ -1018,7 +1019,7 @@ channel_rel_free_sent (struct MeshChannelReliability *rel, target = mid + i + 1; LOG (GNUNET_ERROR_TYPE_DEBUG, " target %u\n", target); while (NULL != copy && GM_is_pid_bigger (target, copy->mid)) - copy = copy->next; + copy = copy->next; /* Did we run out of copies? (previously freed, it's ok) */ if (NULL == copy) @@ -1132,30 +1133,33 @@ channel_confirm (struct MeshChannel *ch, int fwd) oldstate = ch->state; ch->state = MESH_CHANNEL_READY; - rel->client_ready = GNUNET_YES; - LOG (GNUNET_ERROR_TYPE_DEBUG, - " !! retry timer confirm %s\n", - GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, GNUNET_NO)); - rel->expected_delay = rel->retry_timer; - if (GMT_get_connections_buffer (ch->t) > 0 || GMT_is_loopback (ch->t)) - send_client_ack (ch, fwd); - - if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) + if (MESH_CHANNEL_READY != oldstate || GNUNET_YES == is_loopback (ch)) { - GNUNET_SCHEDULER_cancel (rel->retry_task); - rel->retry_task = GNUNET_SCHEDULER_NO_TASK; - } - else if (NULL != rel->uniq) - { - GMT_cancel (rel->uniq->tq); - /* ch_message_sent will free and NULL uniq */ - } - else - { - if (GNUNET_NO == is_loopback (ch)) + rel->client_ready = GNUNET_YES; + LOG (GNUNET_ERROR_TYPE_DEBUG, + " !! retry timer confirm %s\n", + GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, GNUNET_NO)); + rel->expected_delay = rel->retry_timer; + if (GMT_get_connections_buffer (ch->t) > 0 || GMT_is_loopback (ch->t)) + send_client_ack (ch, fwd); + + if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) + { + GNUNET_SCHEDULER_cancel (rel->retry_task); + rel->retry_task = GNUNET_SCHEDULER_NO_TASK; + } + else if (NULL != rel->uniq) { - /* We SHOULD have been trying to retransmit this! */ - GNUNET_break (oldstate == MESH_CHANNEL_READY); + GMT_cancel (rel->uniq->tq); + /* ch_message_sent will free and NULL uniq */ + } + else + { + if (GNUNET_NO == is_loopback (ch)) + { + /* We SHOULD have been trying to retransmit this! */ + GNUNET_break (0); + } } } @@ -1261,6 +1265,8 @@ handle_loopback (struct MeshChannel *ch, { case GNUNET_MESSAGE_TYPE_MESH_DATA: /* Don't send hop ACK, wait for client to ACK */ + LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SEND loopback %u (%u)\n", + ntohl (((struct GNUNET_MESH_Data *) msgh)->mid), ntohs (msgh->size)); GMCH_handle_data (ch, (struct GNUNET_MESH_Data *) msgh, fwd); break; @@ -1346,11 +1352,11 @@ GMCH_destroy (struct MeshChannel *ch) /** - * Get channel ID. + * Get the channel's public ID. * * @param ch Channel. * - * @return ID + * @return ID used to identify the channel with the remote peer. */ MESH_ChannelNumber GMCH_get_id (const struct MeshChannel *ch) @@ -1877,7 +1883,7 @@ GMCH_handle_data (struct MeshChannel *ch, if (NULL == c) { - GNUNET_break (0); + GNUNET_break (GNUNET_NO != ch->destroy); return; } @@ -1907,7 +1913,8 @@ GMCH_handle_data (struct MeshChannel *ch, ( !GM_is_pid_bigger (rel->mid_recv, mid) && GM_is_pid_bigger (rel->mid_recv + 64, mid) ) ) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RECV %u\n", mid); + LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RECV %u (%u)\n", + mid, ntohs (msg->header.size)); if (GNUNET_YES == ch->reliable) { /* Is this the exact next expected messasge? */ @@ -1991,11 +1998,11 @@ GMCH_handle_data_ack (struct MeshChannel *ch, } if (NULL == rel) { - GNUNET_break_op (0); + GNUNET_break_op (GNUNET_NO != ch->destroy); return; } - /* Free ACK'd copies: no need to retransmit those anymore */ + /* Free ACK'd copies: no need to retransmit those anymore FIXME refactor */ for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next) { if (GM_is_pid_bigger (copy->mid, ack)) @@ -2011,7 +2018,7 @@ GMCH_handle_data_ack (struct MeshChannel *ch, return; } - /* ACK client if needed */ + /* ACK client if needed and possible */ GMCH_allow_client (ch, fwd); /* If some message was free'd, update the retransmission delay */ @@ -2037,8 +2044,9 @@ GMCH_handle_data_ack (struct MeshChannel *ch, rel); } } - else /* work was done but no task was pending? shouldn't happen! */ + else { + /* Work was done but no task was pending? Shouldn't happen! */ GNUNET_break (0); } } @@ -2301,7 +2309,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, { /* BCK ACK (going FWD) is just a response for a SYNACK, don't keep*/ fire_and_forget (message, ch, GNUNET_YES); - break; + return; } /* fall-trough */ case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: @@ -2324,6 +2332,13 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, } chq->tq = GMT_send_prebuilt_message (message, ch->t, GNUNET_YES, &ch_message_sent, chq); + if (NULL == chq->tq) + { + GNUNET_break (0); + GNUNET_free (chq); + chq = NULL; + return; + } chq->rel->uniq = chq; break;