I have used tcpecho in card and
PC program to generate different size of messages to be sent to card to
test tcp connection. Everyting is working when I send more than ~200 bytes
in message, but when size is decreased pbufs get lost. This happends because
sys_mbox_post can't put message into queue, it's full and it just discards
whole packet, -> memory not freed!
sys_mbox_post should return with error
if message is not handled and upper layer should do cleanup!
I used API (not raw Api) ported to uC/OS.
While doing testing I found bug
in tcp_out.c.
/* If total number of pbufs on
the unsent/unacked queues exceeds the
* configured maximum, return
an error */
queuelen = pcb->snd_queuelen;
if (queuelen >= TCP_SND_QUEUELEN)
{
LWIP_DEBUGF(TCP_OUTPUT_DEBUG
| 3, ("tcp_enqueue: too long queue %u (max %u)\n", queuelen,
TCP_SND_QUEUELEN));
goto memerr;
}
should be (because queue
is not initialized and used in memerr):
/* If total number of pbufs on
the unsent/unacked queues exceeds the
* configured maximum, return
an error */
queuelen = pcb->snd_queuelen;
if (queuelen >= TCP_SND_QUEUELEN)
{
LWIP_DEBUGF(TCP_OUTPUT_DEBUG
| 3, ("tcp_enqueue: too long queue %u (max %u)\n", queuelen,
TCP_SND_QUEUELEN));
return ERR_MEM;
}