#include "cadet_protocol.h"
#define LOG(kind,...) GNUNET_log_from (kind, "cadet-api",__VA_ARGS__)
+#define DATA_OVERHEAD sizeof(struct GNUNET_CADET_LocalData)
/******************************************************************************/
/************************ DATA STRUCTURES ****************************/
*
* @param h Cadet handle.
*
- * @return The size of the first ready message in the queue,
+ * @return The size of the first ready message in the queue, including overhead.
* 0 if there is none.
*/
static size_t
if (GNUNET_YES == ch->allow_send)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "# message payload ok\n");
- return th->size;
+ return th->size + DATA_OVERHEAD;
}
}
return 0;
LOG (GNUNET_ERROR_TYPE_DEBUG, "# payload\n");
if (GNUNET_NO == ch->allow_send)
{
- /* This channel is not ready to transmit yet, try next message */
+ /* This channel is not ready to transmit yet, Try the next message */
next = th->next;
continue;
}
GNUNET_assert (size >= th->size);
dmsg = (struct GNUNET_CADET_LocalData *) cbuf;
mh = (struct GNUNET_MessageHeader *) &dmsg[1];
- psize = th->notify (th->notify_cls,
- size - sizeof (struct GNUNET_CADET_LocalData),
- mh);
+ psize = th->notify (th->notify_cls, size - DATA_OVERHEAD, mh);
if (psize > 0)
{
- psize += sizeof (struct GNUNET_CADET_LocalData);
- GNUNET_assert (size >= psize);
GNUNET_assert (sizeof (struct GNUNET_MessageHeader) <= psize);
+ psize += DATA_OVERHEAD;
+ GNUNET_assert (size >= psize);
dmsg->header.size = htons (psize);
dmsg->id = htonl (ch->chid);
dmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= psize);
if (th->timeout_task != NULL)
GNUNET_SCHEDULER_cancel (th->timeout_task);
+ next = th->next;
GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th);
GNUNET_free (th);
- next = h->th_head;
nsize = message_ready_size (h);
cbuf += psize;
size -= psize;