Ok, I now I get it.

So protection around my calls it is, but I don't quite see how RX and TX 
can be handled in the same thread since the TX-function is registered with 
lwip in the netif-structure and RX isn't. 

OK I see now that there is an input-pointer in the netif-structure as well 
but it's not referenced in the driver-template (ethernetif.c) so I 
invented something on my own...I'll have to dig through the examples one 
more time and look how they have done it...

/Åke
-----------------------------
Åke Forslund
0433-273296
NIBE AB
Box 14
S-285 21  Markaryd
Tel +46-(0)433-273296




From:
"Simon Goldschmidt" <goldsi...@gmx.de>
To:
Mailing list for lwIP users <lwip-users@nongnu.org>
Date:
2011-09-02 14:32
Subject:
Re: [lwip-users] how lwip know internet cable is unplug
Sent by:
lwip-users-bounces+ake.forslund=nibe...@nongnu.org



ake.forsl...@nibe.se wrote:
> I'm not quite sure what you're suggesting. Is it to put all calls that 
may
> change states of netif, dhcp etc. in a single thread or is it the use of 
a
> separate thread to handle RX, or something else?

I'm just repeating the mantra that lwIP core code is not thread protected 
(with very little exceptions, mostly regarding memory management 
functions) and either all code using lwIP functions/variables must be used 
from one thread only or you have to protect it yourself (e.g. by using a 
semaphore or something like that).

E.g. if you have RX in one thread and TX in another thread, you can be 
most sure that you will get problems at some point (e.g. corrupted state, 
corrupted pbuf-ref or corrupted lists).

I have to point this out to prevent other users reading this list from 
making such a mistake (that can be hard to debug). And your statement 
"set_link_up/down looks pretty safe to use from my rx-thread" can sound 
like these functions are thread-safe to new users (as it did, to me).

Simon
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to