Skip to content

Commit b7173ed

Browse files
committed
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
1 parent 4878d5c commit b7173ed

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

libraries/Ethernet/src/EthernetUdp.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ size_t EthernetUDP::write(const uint8_t *buffer, size_t size)
118118
int EthernetUDP::parsePacket()
119119
{
120120
// discard any remaining bytes in the last packet
121-
flush();
121+
while (_remaining) {
122+
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
123+
// should only occur if recv fails after telling us the data is there, lets
124+
// hope the w5100 always behaves :)
125+
read();
126+
}
122127

123128
if (recvAvailable(_sock) > 0)
124129
{
@@ -206,14 +211,7 @@ int EthernetUDP::peek()
206211

207212
void EthernetUDP::flush()
208213
{
209-
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
210-
// should only occur if recv fails after telling us the data is there, lets
211-
// hope the w5100 always behaves :)
212-
213-
while (_remaining)
214-
{
215-
read();
216-
}
214+
// TODO: we should wait for TX buffer to be emptied
217215
}
218216

219217
/* Start EthernetUDP socket, listening at local port PORT */

0 commit comments

Comments
 (0)