[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] sys_mbox_free() problem
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] sys_mbox_free() problem |
Date: |
Wed, 08 Jan 2003 22:54:43 -0000 |
Hi Horst!
On Wednesday 14 November 2001 11:59, you wrote:
> Here is my question:
> sys_mbox_free(sys_mbox_t mbox) is called in some situations with a not
> empty mbox! I found no possibility of freeing the attached element (it
> seems to me a memp of type MEMP_NETBUF - but who knows?).
You have found a very serious bug since this can lead to memory leakage which
eventually will render a device useless.
The problem is that when packets are recieved by TCP, a callback function is
called from TCP. The callback function posts the incoming packet in a mailbox
which will be read from by the netconn_recv() function. The problem occurs
when the connection is shut down before all data has been processed by the
application. To fix this, the queue must be drained when a connection is
closed.
The way I see it, there are two ways to solve this. In the upcoming 0.5
version, the sys_arch has a function that can be used to drain the queue;
sys_arch_mbox_fetch(). Since it has a timeout argument, it can be called with
a timeout of 1 which means "almost no waiting at all". The other way is to
implement a new queue using semaphores for just this special case. The queue
can then be freed in any way when the connection is closed.
Of those two alternatives, I prefer the first. The bad part is of course that
it won't work with a sys_arch from 0.4.2.
> [I have running lwip on an motorola 68302 processor, SMSC 91C111
> ethernet controller and a propriatary os called srtx]
Great!
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]