Dear folks,
I'm hunting a very seldom shutdown of a ethernut application. After a very long journey, I think I found a problem in the Nut OS DHCP logic. After the DHCP Lease time the Ethernut client is rebinding to the DHCP Server. In this process the application is calling the NutDhcpIfConfig function. This function looses memory in this way: NutDhcpIfConfig->NutDhcpIfConfig2->NutNetIfSetup->NutIpRouteAdd->malloc without free!!!! It's around 48 bytes with every call. To avoid this I changed the NutOs-DHCP-Client in this way (marked with >). With this modification we don't loosing memory anymore. Comments to this are welcome! I hope anyone is listening to this group. NutOs is a great system, but where is anybody ;-) ? On the Linux planet or on freeRtos or... ? Best regards Jörg ------------------------------------------------ /* * We are done somehow. Either a fatal error occured or we * reached the specified timeout time or our lease has been * release or something else configured our interface. * Release all resources and wait for a new API call to * wake us up. */ else if (dhcpState == DHCPST_IDLE) { ReleaseDynCfg(dhcpConfig); dhcpConfig = 0; retries = 0; NutEventBroadcast(&dhcpDone); /* #wi releas Memory for routes */ > if(dhcpDev!=0) > { > NutIpRouteDelAll(dhcpDev); // Alle Routen löschen, damit Speicher wieder frei gegeben wird. #wi Fehlerbehebung..... > } --------------------------------------------- _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
Jörg Wiegelmann writes:
> Dear folks, > > I'm hunting a very seldom shutdown of a ethernut application. After a > very long journey, I think I found a problem in the Nut OS DHCP logic. > > After the DHCP Lease time the Ethernut client is rebinding to the DHCP > Server. In this process the application is calling the NutDhcpIfConfig > function. > This function looses memory in this way: > > NutDhcpIfConfig->NutDhcpIfConfig2->NutNetIfSetup->NutIpRouteAdd->malloc > without free!!!! > > It's around 48 bytes with every call. To avoid this I changed the > NutOs-DHCP-Client in this way (marked with >). > > With this modification we don't loosing memory anymore. > > Comments to this are welcome! I hope anyone is listening to this group. > NutOs is a great system, but where is anybody ;-) ? On the Linux planet > or on freeRtos or... ? > Please check that appended diff is what you intended and give feedback before I appy to master. Providing a real patch would help not not make editing errors. Bye -- Uwe Bonnes [hidden email] Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 1623569 ------- Fax. 06151 1623305 --------- diff --git a/nut/pro/dhcpc.c b/nut/pro/dhcpc.c index 58f33b91c..4c4fdecfd 100644 --- a/nut/pro/dhcpc.c +++ b/nut/pro/dhcpc.c @@ -1734,6 +1734,10 @@ THREAD(NutDhcpClient, arg) retries = 0; dhcpApiTimeout = NUT_WAIT_INFINITE; NutEventBroadcast(&dhcpDone); + /* Release Memory for routes */ + if(dhcpDev!=0) { + NutIpRouteDelAll(dhcpDev); /* Release routes to allow free*/ + } NutEventWait(&dhcpWake, NUT_WAIT_INFINITE); } _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
In reply to this post by Jörg Wiegelmann
Thank you for the feedback Uwe. So I don't feel so alone ;-) . Because
I'm working on Windows I don't have a diff. I downloaded the complete file at this destination: https://www.dropbox.com/s/nxozpqicr4c0pt0/dhcpc.c?dl=0 Yesterday I found another problem. When I'm switching on NUTDEBUG the compiling of dhcpc.c fails because the function call DhcpStateDebug( 1, dhcpState, last_ip, leaseTime, retries); was in the middle of this incredible if/else/if/else construction. I think it could be a good idea to transform this into a switch/case. But I don't feel confident enough to do this. I moved the DhcpStateDebug call to the end so that I can compile. I don't know if this is the best place to be for the call. Watch out for the next post with a new problem :-O . What is when in the middle of DHCP-renew process someone wants to send messages? Best regards Jörg _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
Free forum by Nabble | Edit this page |