SAM4E-16E... lwIP stuck in slow timer loop

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

scowell
Posts: 29
Joined: Fri Feb 13, 2015 11:00 pm

SAM4E-16E... lwIP stuck in slow timer loop

Tue Aug 25, 2015 11:41 pm

I found a problem where my project gets stuck in tcp.c/tcp_slowtmr()... the code gets stuck in
the while (pcb != NULL) portion since the current PCB has itself set as the next PCB... the
containing while (pcb != NULL) means infinite loop time.

I added the code at the bottom (in bold) that checks if the PCB is the same after assignment to ->next...
if so, make ->next = NULL, which will break out of the loop.

This is just a hack, since the ->next got set to itself somehow... it should never do that. If anyone has
any ideas I'd be very pleased to hear them.

Code: Select all

  /* Steps through all of the TIME-WAIT PCBs. */
  prev = NULL;
  pcb = tcp_tw_pcbs;
  while (pcb != NULL) {
    LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
    pcb_remove = 0;

    /* Check if this PCB has stayed long enough in TIME-WAIT */
    if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) {
      ++pcb_remove;
    }
    


    /* If the PCB should be removed, do it. */
    if (pcb_remove) {
      struct tcp_pcb *pcb2;
      tcp_pcb_purge(pcb);
      /* Remove PCB from tcp_tw_pcbs list. */
      if (prev != NULL) {
        LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
        prev->next = pcb->next;
      } else {
        /* This PCB was the first. */
        LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb);
        tcp_tw_pcbs = pcb->next;
      }
      pcb2 = pcb;
      pcb = pcb->next;
      memp_free(MEMP_TCP_PCB, pcb2);
    } else {
      prev = pcb;
      pcb = pcb->next;
[b]	  if (prev == pcb)
		pcb->next = NULL;/[/b]/ hack to escape infinite loop 
    }
  }

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 3 guests