diff --git a/src/api/sockets.c b/src/api/sockets.c index 8b03e8f4..e3ab4df3 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -1079,7 +1079,7 @@ int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *opt /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ @@ -1182,7 +1182,7 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_ /* UNIMPL case SO_SNDBUF: */ /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ @@ -1264,7 +1264,7 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ diff --git a/src/core/tcp.c b/src/core/tcp.c index f7c76572..35ad15f1 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -249,7 +249,7 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) if (port == 0) { port = tcp_new_port(); } -#ifndef SO_REUSE +#if SO_REUSE == 0 /* Check if the address already is in use. */ for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs; cpcb != NULL; cpcb = cpcb->next) { @@ -444,6 +444,16 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len) } if (!(pcb->flags & TF_ACK_DELAY) && !(pcb->flags & TF_ACK_NOW)) { + /* + * We send an ACK here (if one is not already pending, hence + * the above tests) as tcp_recved() implies that the application + * has processed some data, and so we can open the receiver's + * window to allow more to be transmitted. This could result in + * two ACKs being sent for each received packet in some limited cases + * (where the application is only receiving data, and is slow to + * process it) but it is necessary to guarantee that the sender can + * continue to transmit. + */ tcp_ack(pcb); } diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index f9d5bd8b..d09e1c70 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -153,7 +153,6 @@ tcp_input(struct pbuf *p, struct netif *inp) return; } - /* Move the payload pointer in the pbuf so that it points to the TCP data instead of the TCP header. */ hdrlen = TCPH_HDRLEN(tcphdr); @@ -173,7 +172,7 @@ tcp_input(struct pbuf *p, struct netif *inp) for an active connection. */ prev = NULL; -#ifdef SO_REUSE +#if SO_REUSE pcb_temp = tcp_active_pcbs; again_1: @@ -191,7 +190,7 @@ tcp_input(struct pbuf *p, struct netif *inp) ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) && ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) { -#ifdef SO_REUSE +#if SO_REUSE if(pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ @@ -361,7 +360,7 @@ tcp_input(struct pbuf *p, struct netif *inp) tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ -#ifdef SO_REUSE +#if SO_REUSE /* First socket should receive now */ if(reuse_port) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: searching next PCB.\n")); @@ -373,7 +372,7 @@ tcp_input(struct pbuf *p, struct netif *inp) #endif /* SO_REUSE */ } else { -#ifdef SO_REUSE +#if SO_REUSE if(reuse) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: freeing PBUF with reference counter set to %i\n", p->ref)); pbuf_free(p); @@ -392,7 +391,7 @@ tcp_input(struct pbuf *p, struct netif *inp) } pbuf_free(p); } -#ifdef SO_REUSE +#if SO_REUSE end: #endif /* SO_REUSE */ LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane());