/**
* Data message we are trying to send.
*/
- struct GNUNET_CADET_ChannelAppDataMessage data_message;
+ struct GNUNET_CADET_ChannelAppDataMessage *data_message;
- /* followed by variable-size payload */
};
GNUNET_CONTAINER_DLL_remove (ch->head_sent,
ch->tail_sent,
crm);
+ GNUNET_free (crm->data_message);
GNUNET_free (crm);
}
if (NULL != ch->owner)
ccco->client_ready = GNUNET_YES;
ch = GNUNET_new (struct CadetChannel);
+ ch->mid_recv.mid = htonl (1); /* The OPEN_ACK counts as message 0! */
ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER));
ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE));
ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER));
options);
GNUNET_assert (ntohl (cccd->ccn.channel_of_client) <
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
- ch->mid_recv.mid = htonl (1); /* The CONNECT counts as message 0! */
+ ch->mid_recv.mid = htonl (1); /* The OPEN counts as message 0! */
if (GNUNET_YES == ch->is_loopback)
{
ch->state = CADET_CHANNEL_OPEN_SENT;
size_t payload_size;
GNUNET_assert (GNUNET_NO == ch->is_loopback);
+ if ( (GNUNET_YES == ch->destroy) &&
+ (NULL == ch->owner) &&
+ (NULL == ch->dest) )
+ {
+ /* This client is gone, but we still have messages to send to
+ the other end (which is why @a ch is not yet dead). However,
+ we cannot pass messages to our client anymore. */
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Dropping incoming payload on %s as this end is already closed\n",
+ GCCH_2s (ch));
+ /* FIXME: send back ACK/NACK/Closed notification
+ to stop retransmissions! */
+ return;
+ }
payload_size = ntohs (msg->header.size) - sizeof (*msg);
env = GNUNET_MQ_msg_extra (ld,
payload_size,
for (crm = ch->head_sent;
NULL != crm;
crm = crm->next)
- if (ack->mid.mid == crm->data_message.mid.mid)
+ if (ack->mid.mid == crm->data_message->mid.mid)
break;
if (NULL == crm)
{
GNUNET_CONTAINER_DLL_remove (ch->head_sent,
ch->tail_sent,
crm);
+ GNUNET_free (crm->data_message);
+ GNUNET_free (crm);
ch->pending_messages--;
send_ack_to_client (ch,
(NULL == ch->owner)
? GNUNET_NO
: GNUNET_YES);
- GNUNET_free (crm);
GNUNET_assert (ch->pending_messages < ch->max_pending_messages);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received DATA_ACK on %s for message %u (%u ACKs pending)\n",
ch->retry_data_task = NULL;
GNUNET_assert (NULL == crm->qe);
crm->qe = GCT_send (ch->t,
- &crm->data_message.header,
+ &crm->data_message->header,
&data_sent_cb,
crm);
}
}
/* Everything is correct, send the message. */
- crm = GNUNET_malloc (sizeof (*crm) + buf_len);
+ crm = GNUNET_malloc (sizeof (*crm));
crm->ch = ch;
- crm->data_message.header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len);
- crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
+ crm->data_message = GNUNET_malloc (sizeof (struct GNUNET_CADET_ChannelAppDataMessage)
+ + buf_len);
+ crm->data_message->header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len);
+ crm->data_message->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1);
- crm->data_message.mid = ch->mid_send;
- crm->data_message.ctn = ch->ctn;
- GNUNET_memcpy (&crm[1],
+ crm->data_message->mid = ch->mid_send;
+ crm->data_message->ctn = ch->ctn;
+ GNUNET_memcpy (&crm->data_message[1],
buf,
buf_len);
GNUNET_CONTAINER_DLL_insert (ch->head_sent,
buf_len,
GCCH_2s (ch));
crm->qe = GCT_send (ch->t,
- &crm->data_message.header,
+ &crm->data_message->header,
&data_sent_cb,
crm);
return GNUNET_OK;