Dear Ivan, 
    
    The issue that you mention is already covered in the latest example
    from Atmel, see code below. 
    After reviewing my code I noticed that all sockets are opened and
    closed as thery are used, all but an UDP socket that remained open
    continuously, used to receive broadcast frames, I am now closing
    this socket and reopening it every 30 seconds if no frames are
    received, this operation releases any memory that could be stuck in
    the deadlock. Looks good so far. 
    I'll let the system the system under test this weekend. 
    
    Thanks. 
    
        switch( htons( ethhdr->type ) ) 
            {    
        
                /* IP or ARP 
packet? */ 
                  case 
ETHTYPE_IP: 
                  case 
ETHTYPE_ARP: 
    #if PPPOE_SUPPORT 
                  /* PPPoE 
packet? */ 
                  case 
ETHTYPE_PPPOEDISC: 
                  case 
ETHTYPE_PPPOE: 
    #endif /* PPPOE_SUPPORT */ 
                    
/* full packet send to tcpip_thread to process
    */              
    
                  
    if( xNetIf->input(p, xNetIf) != ERR_OK ) 
                  
    { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP
    input error\n")); 
                
        pbuf_free(p); 
                
        p = NULL; 
                  
    } 
                  
break;      
                default: 
                    
pbuf_free( p ); 
                    
p = NULL; 
                    
break; 
            }    
    
    El 30/05/2013 19:10, Ivan Delamer-2
      [via lwIP] escribió: 
    
     I don't know if this still applies but a while ago
      there was a memory 
      leak in the AT91/FreeRTOS implementation of ethernetif_input()
      when 
      passing the pbuf to netif->input
      
      
      I have this code:
      
      
           switch( htons( ethhdr->type ) )
      
           {
      
             /* IP packet? */
      
             case ETHTYPE_IP:
      
             case ETHTYPE_ARP:
      
             case ETHTYPE_IPV6:
      
               /* pass to network layer */
      
               if (pxNetIf->input( p, pxNetIf ) != 
ERR_OK)
      
               {
      
                 pbuf_free( p );
      
      #if LINK_STATS
      
                 lwip_stats.link.drop++;
      
                 lwip_stats.link.err++;
      
      #endif /* LINK_STATS */
      
               }
      
               break;
      
      
             default:
      
               pbuf_free( p );
      
      #if LINK_STATS
      
               lwip_stats.link.drop++;
      
               lwip_stats.link.proterr++;
      
      #endif /* LINK_STATS */
      
               p = NULL;
      
               break;
      
             }
      
      
      The key is to free the pbuf not only if packet type is
      unrecognized, 
      but also if pxNetIf->input fails (this is where I had my memory
      leak).
      
      
      Cheers
      
      Ivan
      
      
        > Date: Thu, 30 May 2013 02:14:04 -0700 (PDT)
        
        > From: Sebastian Gonzalez < [hidden email] >
        
        > To: [hidden email] 
        
        > Subject: Re: [lwip-users] Receive path stuck due to
        pbuf_alloc
        
        > returning NULL
        
        > Message-ID: < [hidden email] >
        
        > Content-Type: text/plain; charset=us-ascii
        
        > 
        > Hi,
        
        > 
        > I am still having problems, but it's true that it takes
        more time for 
        > the
        
        > system to stop receiving under the same stress tests.
        
        > I made a little test that includes a semaphore that is set
        everytime a 
        > pbuf
        
        > is allocated and is released every time the packet is
        processed, but 
        > with no
        
        > positive results. Wether not every pbuf is freed in the
        TCP/IP thread 
        > after
        
        > being processed, or there is a memory leak as Ivan
        sugested.
        
        > Is there any way to release all the memory? I don't mind
        having to 
        > close my
        
        > application sockets if the system is restored and I can
        reopen them.
        
        > 
        > Thanks.
        
        > 
        > Sebestian.
      
      
      
      _______________________________________________
      
      lwip-users mailing list
      
      [hidden email] 
      
      https://lists.nongnu.org/mailman/listinfo/lwip-users 
      
      
      
      
        If you reply to this email, your
          message will be added to the discussion below: 
        
http://lwip.100.n7.nabble.com/Receive-path-stuck-due-to-pbuf-alloc-returning-NULL-tp21461p21490.html
 
      
      
        To unsubscribe from Receive path stuck due to pbuf_alloc
        returning NULL, click
          here . 
        NAML  
    
    
    -- 
      
        Firma By
           
        Sebastián González 
          Investigación y Desarrollo 
          Tlf: 902 82 00 82 
          Fax: 902 82 00 83 
          
          [email protected] 
          www.by.com.es 
        
         
          Antes de imprimir este e-mail piense si realmente es necesario
          hacerlo, el medio ambiente se lo agradecerá. 
          
            ADVERTENCIA 
                La información contenida en este correo 
electrónico, es
                de carácter privado y confidencial, siendo para uso
                exclusivo de su destinatario. Si usted no es el
                destinatario correcto, o ha recibido esta comunicación
                por error, le informamos que está totalmente prohibida
                cualquier divulgación, distribución o 
reproducción de
                esta comunicación según la legislación 
vigente y le
                rogamos que nos lo notifique inmediatamente, procediendo
                a su destrucción sin continuar su lectura. 
                Su dirección de correo electrónico, así 
como el resto de
                los datos de carácter personal que nos facilite, 
podrían
                ser objeto de tratamiento automatizado en nuestros
                ficheros, con la finalidad de gestionar la agenda de
                contactos de BY TECHDESIGN,S.L. Vd. podrá en cualquier
                momento ejercer sus derechos de acceso, rectificación,
                cancelación y oposición según la Ley 
Orgánica 15/1999
                mediante notificación escrita a la siguiente 
dirección:
                CALLE TOMAS EDISON 5 28500 ARGANDA DEL REY. 
          
        
      
  



LogoBy.jpg (3K) <http://lwip.100.n7.nabble.com/attachment/21494/0/LogoBy.jpg>




--
View this message in context: 
http://lwip.100.n7.nabble.com/Receive-path-stuck-due-to-pbuf-alloc-returning-NULL-tp21461p21494.html
Sent from the lwip-users mailing list archive at Nabble.com.
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to