Ethernet: partially fix flush() behaviour in EthernetUDP

We still need to check if trasmission is completed, BTW this commit
should alleviate bugs involving data loss.

See #4029
This commit is contained in:
Cristian Maglie 2015-11-11 16:36:11 +01:00
parent 4878d5c2ec
commit b7173ed06c
1 changed files with 7 additions and 9 deletions

View File

@ -118,7 +118,12 @@ size_t EthernetUDP::write(const uint8_t *buffer, size_t size)
int EthernetUDP::parsePacket()
{
// discard any remaining bytes in the last packet
flush();
while (_remaining) {
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
// should only occur if recv fails after telling us the data is there, lets
// hope the w5100 always behaves :)
read();
}
if (recvAvailable(_sock) > 0)
{
@ -206,14 +211,7 @@ int EthernetUDP::peek()
void EthernetUDP::flush()
{
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
// should only occur if recv fails after telling us the data is there, lets
// hope the w5100 always behaves :)
while (_remaining)
{
read();
}
// TODO: we should wait for TX buffer to be emptied
}
/* Start EthernetUDP socket, listening at local port PORT */