lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] One more context of execution question


From: Jeff Barber
Subject: Re: [lwip-users] One more context of execution question
Date: Mon, 13 Dec 2010 07:07:29 -0500

On Sun, Dec 12, 2010 at 6:30 PM, shogun <address@hidden> wrote:
> I have one more question about what is safe to run in different execution
> context for lwip (interrupt/thread).  I did add an OS to my application and
> now moved some things around so data is only sent and received in the tcp/ip
> thread context.  Is it recommended I move any of the following API calls to
> LWIP into the tcp/ip thread context also?

See doc/rawapi.txt:
  lwIP started targeting single-threaded environments. When adding multi-
  threading support, instead of making the core thread-safe, another
  approach was chosen: there is one main thread running the lwIP core
  (also known as the "tcpip_thread"). The raw API may only be used from
  this thread! [....]


> //Called when there is an unrecoverable error etc
> static void close(struct tcp_pcb *pcb)
> {
>        tcp_abort(pcb);
>        tcp_close(pcb);
> }

This is wrong.  tcp_abort removes the pcb.  Hence, when you call
tcp_close here you are passing a pointer to de-allocated memory.

I would think of tcp_abort() and tcp_close() as mutually exclusive.
tcp_close is normal session termination. tcp_abort is used when
something catastrophic has happened and you need to immediately abort
the connection. Both de-allocate the pcb so you cannot make further
calls with that pcb.

Jeff



reply via email to

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