Closed GoogleCodeExporter closed 9 years ago
Adrian, can you take a look at this one?
Original comment by dmel...@gmail.com
on 1 Jun 2012 at 3:17
Now that I look more closely, should not:
_dhcp = new DhcpClass();
be:
_dhcp = new DhcpClass;
Original comment by n...@gammon.com.au
on 1 Jun 2012 at 3:32
I found the same bug. I filed a duplicate (Id #1000) before I noticed that
someone else had already found the same problem.
I prefer the first fix using delete because you don't have to worry if there
might be some side effects from reusing _dhcp.
delete _dhcp;
_dhcp = new DhcpClass();
It would be nice if the original poster submitted a patch to include the change
that initializes _dhcp to NULL.
I have attached my test sketch which demonstrates the problem. After about 15
to 20 loops the Arduino will either hang or reset itself.
Original comment by n...@noah.org
on 31 Jul 2012 at 10:07
Attachments:
Good spot, and the fix looks like it would work.
It has tempted me back to wondering if we could get away without creating the
DhcpClass object on the heap again though. Allocating it on the heap uses an
extra 500-plus bytes in the sketch, as it has to pull in new/delete (although
if you're using them elsewhere you'd have that anyway).
I wonder if we could break the DhcpClass into two parts: DhcpClass which would
do the work of requesting leases, etc. and which would only be created while
the Arduino needed to talk to a DHCP server; and a DhcpPersistentClass, which
would hold the lease info and be contained within the Ethernet class.
That solution would mean we didn't need new/delete (saving 500+ bytes of sketch
size) and would use 81 fewer bytes of RAM apart from when it was actually
acquiring a lease.
Given that I'm looking at the DHCP stuff for issue 985 too, I'll have a look at
changing this too, unless anyone can think of a reason not to?
Original comment by adrian.m...@gmail.com
on 10 Aug 2012 at 4:03
It looks like the DhcpClass will need a destructor if the "delete _dhcp; _dhcp
= new DhcpClass();" option is chosen, as its _dhcpUdpSocket will need to be
closed.
Original comment by richard....@gmail.com
on 3 Dec 2012 at 2:32
I'd like to suggest implementing this as Ethernet.stop(), to match several
other APIs that have begin() and stop() methods.
I don't think I'd consider this a breaking API change, since if you don't call
stop() the behaviour would be identical to what it is now.
Original comment by richard....@gmail.com
on 3 Dec 2012 at 5:16
I have submitted a pull request with a fix for this issue here:
https://github.com/arduino/Arduino/pull/1150
Original comment by richard....@gmail.com
on 3 Dec 2012 at 8:01
Merged, thank you.
https://github.com/arduino/Arduino/commit/cce70d269c23e9985fe970378fb6dd209b5766
43
Original comment by c.mag...@bug.st
on 12 Dec 2012 at 12:02
Issue 1000 has been merged into this issue.
Original comment by c.mag...@bug.st
on 15 Dec 2012 at 11:57
Original issue reported on code.google.com by
n...@gammon.com.au
on 30 May 2012 at 11:10