lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] tcp_close memory leak


From: K.J. Mansley
Subject: Re: [lwip-users] tcp_close memory leak
Date: 20 Jul 2004 10:16:30 +0100

On Tue, 2004-07-20 at 09:55, Tim Newsham wrote:
> > > If you call tcp_close(tcp_new()) you will create new PCB's but
> > > never destroy them.
> >
> > Why would you call like that?
> 
> Not all lwIP apps are tightly integrated with the stack.  Consider
> for example if you provide an API to other apps and you have
> seperate bind() and connect() calls.  Before the bind() is complete,
> a tcb needs to be created.  If the application does a close()
> before a connect() then you will tcp_close() the tcb while it is
> in the closed state.

Ahhh, ok.  I follow you now - I was confused by nesting the tcp_new()
inside the tcp_close().

The problem we have is distinguishing a connection that has never been
used from one which has been closed already.  However, as tcp_close()
should never be called on a connection that has already been closed, it
might be safe to assume that if it's in the CLOSED state it means that
it's never been used.

That sounds a bit confusing, but hope it's clear.  It would mean adding
a handler for the CLOSED state in tcp_close() that just freed the pcb. 
All the other states that are progressing towards CLOSED would be
handled by the default rule.

Hope that makes sense!  Any comments, let me know in the next day or
two, otherwise I'll check in a patch.

Kierna





reply via email to

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