Fri 17 Mar 2017 08:27:54 AM UTC, comment #6:
I'm using lwIP 1.4.1.
I think the problem is before the switch statement in tcp_close_shutdown, just after the comment /* TODO: to which state do we move now? */
I enabled TCP_DEBUG_PCB_LISTS and an assert fails in TCP_REG following the TODO comment.
This change seems to address the problem for me
static err_t
tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
{
err_t err;
if (rst_on_unacked_data && (pcb->state != LISTEN)) {
if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) {
/* Not all data received by application, send RST to tell the remote
side about this. */
LWIP_ASSERT("pcb->flags & TF_RXCLOSED", pcb->flags & TF_RXCLOSED);
/* don't call tcp_abort here: we must not deallocate the pcb since
that might not be expected when calling tcp_close */
tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
pcb->local_port, pcb->remote_port);
tcp_pcb_purge(pcb);
/* TODO: to which state do we move now? */
/* move to TIME_WAIT since we close actively */
if (pcb->state != TIME_WAIT)//MT
{//MT
// MT: Don't put into tcp_tw_pcbs if it is already in tcp_tw_pcbs
TCP_RMV(&tcp_active_pcbs, pcb);
pcb->state = TIME_WAIT;
TCP_REG(&tcp_tw_pcbs, pcb);
}//MT
return ERR_OK;
}
}
switch (pcb->state) {
...
|