diff --git a/CHANGELOG b/CHANGELOG index 3cc39187..19c5ae82 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,10 @@ HISTORY ++ Bugfixes: + 2009-11-26: Simon Goldschmidt + * tcp.h, sockets.c: Fixed bug #28099: API required to disable Nagle + algorithm at PCB level + 2009-11-22: Simon Goldschmidt * tcp_out.c: Fixed bug #27905: FIN isn't combined with data on unsent diff --git a/src/api/sockets.c b/src/api/sockets.c index 34ef098b..1d50aebb 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1492,7 +1492,7 @@ lwip_getsockopt_internal(void *arg) case IPPROTO_TCP: switch (optname) { case TCP_NODELAY: - *(int*)optval = (sock->conn->pcb.tcp->flags & TF_NODELAY); + *(int*)optval = tcp_nagle_enabled(sock->conn->pcb.tcp); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n", s, (*(int*)optval)?"on":"off") ); break; @@ -1853,9 +1853,9 @@ lwip_setsockopt_internal(void *arg) switch (optname) { case TCP_NODELAY: if (*(int*)optval) { - sock->conn->pcb.tcp->flags |= TF_NODELAY; + tcp_nagle_enable(sock->conn->pcb.tcp); } else { - sock->conn->pcb.tcp->flags &= ~TF_NODELAY; + tcp_nagle_disable(sock->conn->pcb.tcp); } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n", s, (*(int *)optval)?"on":"off") ); diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 9a34872b..3d309578 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -78,6 +78,9 @@ void tcp_err (struct tcp_pcb *pcb, #define tcp_mss(pcb) ((pcb)->mss) #define tcp_sndbuf(pcb) ((pcb)->snd_buf) +#define tcp_nagle_enable(pcb) ((pcb)->flags |= TF_NODELAY) +#define tcp_nagle_disable(pcb) ((pcb)->flags &= ~TF_NODELAY) +#define tcp_nagle_enabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) #if TCP_LISTEN_BACKLOG #define tcp_accepted(pcb) (((struct tcp_pcb_listen *)(pcb))->accepts_pending--) @@ -137,7 +140,7 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); * than one unsent segment - with lwIP, this can happen although unsent->len < mss) */ #define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ - ((tpcb)->flags & TF_NODELAY) || \ + (tcp_nagle_enabled(tpcb)) || \ (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ ((tpcb)->unsent->len >= (tpcb)->mss))) \ ) ? 1 : 0)