lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Proper use of pbuf_take...


From: Tom Hennen
Subject: [lwip-users] Proper use of pbuf_take...
Date: Tue, 18 Jul 2006 09:58:52 -0400

I'm having some trouble with pbuf_take and ip_frag and I was wondering if I'm using pbuf_take incorrectly.
 
Currently my netif_output calls pbuf_take as it places the packets on a queue to be sent later. 
// netif_output pseudo-code
err_t netif_output(struct pbuf * p)
{
  p = pbuf_take(p)
  if (p) {
    pbuf_ref(p);
    queue(p);
    return ERR_OK;
  }
  return ERR_MEM;
}
 
This seems to work fine until pbuf_take can't allocate the pbuf's nessecary to copy the referenced data.
 
When pbuf_take can't allocate the referenced data it frees the pbuf passed to it and returns NULL.
 
When ip_frag calls netif_output 'header' has a ref-count of 1.  Then, netif_output tries to take the packet but fails, causing header to have a ref-count of 0 (though the rambuf still has a ref-count of 1).  ip_frag does not check the return value of netif_output to see if it succeeded or not, it simply tries to free header (at line 357).  Of coures at this point header has a ref-count of 0 and so pbuf_free asserts.
 
 
So, do I need to call pbuf_ref before calling pbuf_take or am I correct in calling it after?  If I'm doing it correctly, how can I prevent this assertion from occuring?
 
Thanks,
 
Tom

reply via email to

[Prev in Thread] Current Thread [Next in Thread]