Skip to content

Commit efc828d

Browse files
authored
Merge pull request #832 from fjtrujy/fix/udptty-udp-send-return
fix: [udptty] return size from `udp_send` for pre-link-up writes
2 parents 2c8ab66 + 1561b2c commit efc828d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

iop/network/udptty/src/udptty.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int _start(int argc, char *argv[])
205205

206206
close(0);
207207
open(DEVNAME "00:", 0x1000 | O_RDWR);
208-
208+
209209
close(1);
210210
open(DEVNAME "00:", O_WRONLY);
211211

@@ -230,7 +230,9 @@ int _shutdown()
230230
}
231231

232232
/* Copy the data into place, calculate the various checksums, and send the
233-
final packet. */
233+
final packet. Always reports `size` bytes consumed, even when the UDP
234+
send fails (e.g. before SMAP has reported link-up): otherwise the IOP's
235+
stdio layer retries on a short write and ends up in an infinite loop. */
234236
static int udp_send(void *buf, size_t size)
235237
{
236238
struct sockaddr_in peer;
@@ -241,7 +243,7 @@ static int udp_send(void *buf, size_t size)
241243

242244
lwip_sendto(udp_socket, buf, size, 0, (struct sockaddr *)&peer, sizeof(peer));
243245

244-
return 0;
246+
return (int)size;
245247
}
246248

247249
/* TTY driver. */

0 commit comments

Comments
 (0)