From 2aef8bad55b42e92935a87aeb45a1627a298b558 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Thu, 21 Jun 2007 18:55:09 +0000 Subject: [PATCH] Moved the nagle algorithm from netconn_write/do_write into a define (tcp_output_nagle) in tcp.h to provide it to raw api users, too. --- CHANGELOG | 4 ++++ src/api/api_msg.c | 10 +--------- src/include/lwip/tcp.h | 11 +++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5aa09a6f..555e899a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,10 @@ HISTORY ++ New features: + 2007-06-21 Simon Goldschmidt + * tcp.h, api_msg.c: Moved the nagle algorithm from netconn_write/do_write + into a define (tcp_output_nagle) in tcp.h to provide it to raw api users, too. + 2007-06-21 Simon Goldschmidt * api.h, api_lib.c, api_msg.c: Fixed bug #20021: Moved sendbuf-processing in netconn_write from api_lib.c to api_msg.c to also prevent multiple context- diff --git a/src/api/api_msg.c b/src/api/api_msg.c index a22db7e1..a6a30b60 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -752,15 +752,7 @@ do_writemore(struct netconn *conn) conn->write_msg = NULL; conn->write_offset = 0; } - /* This is the Nagle algorithm: inhibit the sending of new TCP - segments when new outgoing data arrives from the user if any - previously transmitted data on the connection remains - unacknowledged. */ - if ((conn->pcb.tcp->unacked == NULL || - (conn->pcb.tcp->flags & TF_NODELAY) || - (conn->pcb.tcp->snd_queuelen) > 1)) { - err = tcp_output(conn->pcb.tcp); - } + err = tcp_output_nagle(conn->pcb.tcp); conn->err = err; if ((conn->callback) && (err == ERR_OK) && (tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT)) { diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 455f3fe5..16e75696 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -111,6 +111,17 @@ err_t tcp_output (struct tcp_pcb *pcb); void tcp_rexmit (struct tcp_pcb *pcb); void tcp_rexmit_rto (struct tcp_pcb *pcb); +/** + * This is the Nagle algorithm: inhibit the sending of new TCP + * segments when new outgoing data arrives from the user if any + * previously transmitted data on the connection remains + * unacknowledged. + */ +#define tcp_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ + ((tpcb)->flags & TF_NODELAY) || \ + ((tpcb)->snd_queuelen > 1)) ? \ + tcp_output(tpcb) : ERR_OK) + #define TCP_SEQ_LT(a,b) ((s32_t)((a)-(b)) < 0)