[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] threading issues with sockets
From: |
Åke Forslund |
Subject: |
Re: [lwip-users] threading issues with sockets |
Date: |
Thu, 21 Jun 2012 13:05:33 +0000 |
Another update.
The problem has been found and corrected. A high level debug message had snuck
in to the registered netif_set_status_callback... this kind of debug message
would try to echo to the terminal instead of serial out if a terminal is
connected. And since the callback is called from lwip's tcpip-thread calling
sockets functions will result in a deadlock.
/Åke
-----Ursprungligt meddelande-----
Från: address@hidden [mailto:address@hidden För Åke Forslund
Skickat: den 20 juni 2012 14:32
Till: Mailing list for lwIP users
Ämne: Re: [lwip-users] threading issues with sockets
I'll try to get some debug-information shortly I'm not sure my debugger will
let me have stack-traces without a fight... In the meantime I can add to my
previous statement that my problems seem to originate when the network-handling
thread does the following:
netifapi_netif_set_down(emmyNetif);
ip4_addr_set_u32(&ipAddr, *(unsigned long *)ip);
netif_set_ipaddr(emmyNetif, &ipAddr);
netifapi_netif_set_up(emmyNetif); <--Hangs here
If I remove the netifapi_netif_set_down/up() I get better results, everything
works and lwip_read() returns as you say. I'll see if a little general cleanup
of the functions for handling both manually set ip and dhcp will solve my
troubles.
Thanks for the quick reply.
/Åke
-----Ursprungligt meddelande-----
Från: address@hidden [mailto:address@hidden För Simon Goldschmidt
Skickat: den 20 juni 2012 13:35
Till: Mailing list for lwIP users
Ämne: Re: [lwip-users] threading issues with sockets
"Åke Forslund" <address@hidden> wrote:
> I'm not quite sure how to handle the situation since when using
> blocking sockets lwip_read() doesn't return even if the link goes down
> (? is this expected behavior?)
A link-down event shouldn't cause read() to abort, I guess, since you could
re-plug the device into the same network again.
A netif-down event (which is what stopping DHCP does) however should cause the
read() to abort since the IP address is gone.
> so I can't use a semaphore to ensure that socket functions can't be
> accessed at the same time as the netifapi_*()-functions.
>
> Any advice on how to handle link-status changes together with sockets
> in a safe manner would be great.
I'm not aware of problems here. As far as I know, there should be no problems
with what you described. As you are having problems, I don't have any
suggestions except for debugging to see which threads are pending on which
semaphores, I'm afraid. A stack trace of all threads at the time of suspected
deadlock would be helpful to give more hints.
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
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users