summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extmod/modlwip.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index bbb01b5d7..2c194e1bd 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -498,6 +498,11 @@ STATIC mp_uint_t lwip_tcp_send(lwip_socket_obj_t *socket, const byte *buf, mp_ui
err_t err = tcp_write(socket->pcb.tcp, buf, write_len, TCP_WRITE_FLAG_COPY);
+ // If the output buffer is getting full then send the data to the lower layers
+ if (err == ERR_OK && tcp_sndbuf(socket->pcb.tcp) < TCP_SND_BUF / 4) {
+ err = tcp_output(socket->pcb.tcp);
+ }
+
if (err != ERR_OK) {
*_errno = error_lookup_table[-err];
return MP_STREAM_ERROR;