|
From: | mgroups |
Subject: | Re: [lwip-users] chaining pbufs as an user |
Date: | Thu, 22 Jul 2010 12:43:44 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.7) Gecko/20100713 Lightning/1.0b2 Thunderbird/3.1.1 |
Hello Simon, can you please check the code please, if it is correct or a bug. Thanks a lot for your help! http://cvs.savannah.gnu.org/viewvc/contrib/apps/tcpecho_raw/echo.c?revision=1.3&root=lwip&view=markup On Thu, 22 Jul 2010 08:22:29 +0200, Simon Goldschmidt wrote: Mike Kleshov wrote:Again, if I am not mistaken, the while loop is needed if there is more than 1 reference to the pbuf in question. Perhaps, in this particular program this will never happen. Maybe the author of the code put the while loop there just to be on the safe side?I didn't have a look at the code yet, bug writing such a loop is not a good idea at all: you should only call pbuf_free as often as you called pbuf_ref (and once more for the original reference passed to you, of course). Calling pbuf_ref as long as the pbuf has actually been freed would mean that if anyone else actually had a reference stored to that pbuf, it would get deallocated without the other one noticing. That sounds like a bug in that example code to me! Simon --
demmel products Radnitzkygasse 43 A-1100 Vienna / Austria / Europe Voice: +43-1-6894700-0 Fax: +43-1-6894700-40 Email: address@hidden WWW: http://www.demmel.com |
[Prev in Thread] | Current Thread | [Next in Thread] |