Skip to content

Commit 5775686

Browse files
committed
picow: depending on memory pressure, may only be able to write 1 MSS
Foamyguy discovered that trying to send >2920 bytes at once consistently failed. I further discovered that sometimes trying to send >1460 bytes would fail too. By "fail", I mean that it would take a very long time (around 200 * 50ms) before erroneously reporting that all bytes were written. In my testing, this change causes larger writes to successfully send either 2920 or 1460 bytes (possibly after doing some 50ms waits for a previous packet to clear). The documentation of socket.send always stated that it COULD send fewer bytes than requested, but adafruit_httpserver assumed that the number of requested bytes were always sent, so after this change alone, adafruit_httpserver will still not work properly. Closes: #7077 (albeit fixes are needed in adafruit_httpserver too)
1 parent 861b227 commit 5775686

File tree

1 file changed

+2
-2
lines changed
  • ports/raspberrypi/common-hal/socketpool

1 file changed

+2
-2
lines changed

ports/raspberrypi/common-hal/socketpool/Socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ STATIC mp_uint_t lwip_tcp_send(socketpool_socket_obj_t *socket, const byte *buf,
505505
break;
506506
}
507507
if (err == ERR_MEM && write_len > TCP_MSS) {
508-
// Try writing just one MSS worth of data
509-
write_len = TCP_MSS;
508+
// Decreasing the amount sent to the next lower number of MSS
509+
write_len = (write_len - 1) / TCP_MSS * TCP_MSS;
510510
continue;
511511
}
512512
err = tcp_output(socket->pcb.tcp);

0 commit comments

Comments
 (0)