diff options
author | Damien George <damien.p.george@gmail.com> | 2017-10-31 13:50:08 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-11-24 15:52:32 +1100 |
commit | 48f6990fbc54ac29b15fa765d431244d1dcb5f21 (patch) | |
tree | f08e71da153542dbd66ce077cf03da35097b2029 /extmod/modlwip.c | |
parent | e511f24ddd62f8157ac137f8e4b87e15e5012d70 (diff) |
extmod/modlwip: Commit TCP out data to lower layers if buffer gets full.
Dramatically improves TCP sending throughput because without an explicit
call to tcp_output() the data is only sent to the lower layers via the
lwIP slow timer which (by default) ticks every 500ms.
Diffstat (limited to 'extmod/modlwip.c')
-rw-r--r-- | extmod/modlwip.c | 5 |
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; |