From f2587c00c50e212ac9f045a7d80cbfe38ebc0d7b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 14 Jan 2014 15:17:53 -0600 Subject: When dup'ing sockets, need to clone fields for TCP write buffering too --- nuttx/net/Kconfig | 2 +- nuttx/net/net_clone.c | 7 +++++++ nuttx/net/net_send_buffered.c | 8 ++++---- nuttx/net/socket.c | 7 ++----- nuttx/net/uip/uip_tcpwrbuffer.c | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) (limited to 'nuttx/net') diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig index 83b72cb71..b15b7ee9a 100644 --- a/nuttx/net/Kconfig +++ b/nuttx/net/Kconfig @@ -194,7 +194,7 @@ config NET_TCP_RECVDELAY int "TCP Rx delay" default 0 ---help--- - If NET_NTCP_READAHEAD_BUFFERS is zero, then there will be no buffering + If NET_TCP_READAHEAD_BUFFERS is undefined, then there will be no buffering of TCP/IP packets: Any TCP/IP packet received will be ACKed, but its contents will be dropped in the bit-bucket. diff --git a/nuttx/net/net_clone.c b/nuttx/net/net_clone.c index b58c7e1c6..5efed0944 100644 --- a/nuttx/net/net_clone.c +++ b/nuttx/net/net_clone.c @@ -78,9 +78,16 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2) #ifndef CONFIG_DISABLE_CLOCK psock2->s_rcvtimeo = psock1->s_rcvtimeo; /* Receive timeout value (in deciseconds) */ psock2->s_sndtimeo = psock1->s_sndtimeo; /* Send timeout value (in deciseconds) */ +#ifdef CONFIG_NET_SOLINGER + psock2->s_linger = psock1->s_linger; /* Linger timeout value (in deciseconds) */ +#endif #endif #endif psock2->s_conn = psock1->s_conn; /* UDP or TCP connection structure */ +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + psock2->s_sndcb = NULL; /* Force allocation of new callback + * instance for TCP send */ +#endif /* Increment the reference count on the connection */ diff --git a/nuttx/net/net_send_buffered.c b/nuttx/net/net_send_buffered.c index a73ceca23..e251c65ac 100644 --- a/nuttx/net/net_send_buffered.c +++ b/nuttx/net/net_send_buffered.c @@ -211,7 +211,7 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn, * so it can be sent as soon as possible. */ - while ((entry=sq_remlast(&conn->unacked_q))) + while ((entry = sq_remlast(&conn->unacked_q))) { struct uip_wrbuffer_s *segment = (struct uip_wrbuffer_s*)entry; @@ -231,7 +231,7 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn, * field expired can only be updated at UIP_ESTABLISHED state */ - conn->expired ++; + conn->expired++; continue; } @@ -338,7 +338,7 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn, * second interval before expiration. */ - segment->wb_nrtx ++; + segment->wb_nrtx++; /* The segment is waiting for ACK again */ @@ -481,7 +481,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, while (completed < len) { - struct uip_wrbuffer_s *segment = uip_tcpwrbuffer_alloc(NULL); + FAR struct uip_wrbuffer_s *segment = uip_tcpwrbuffer_alloc(NULL); if (segment) { size_t cnt; diff --git a/nuttx/net/socket.c b/nuttx/net/socket.c index 910154de9..7b8db0c05 100644 --- a/nuttx/net/socket.c +++ b/nuttx/net/socket.c @@ -158,9 +158,6 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) DEBUGASSERT(conn->crefs == 0); psock->s_conn = conn; conn->crefs = 1; -#ifdef CONFIG_NET_TCP_WRITE_BUFFERS - psock->s_sndcb = NULL; -#endif } } break; @@ -193,7 +190,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) break; } - /* Did we succesfully allocate some kind of connection structure? */ + /* Did we successfully allocate some kind of connection structure? */ if (!psock->s_conn) { @@ -205,7 +202,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) return OK; errout: - errno = err; + set_errno(err); return ERROR; } diff --git a/nuttx/net/uip/uip_tcpwrbuffer.c b/nuttx/net/uip/uip_tcpwrbuffer.c index b562b894c..c729dd4b8 100644 --- a/nuttx/net/uip/uip_tcpwrbuffer.c +++ b/nuttx/net/uip/uip_tcpwrbuffer.c @@ -162,4 +162,4 @@ void uip_tcpwrbuffer_release(FAR struct uip_wrbuffer_s *wrbuffer) sem_post(&g_wrbuffer.sem); } -#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_NTCP_WRITE_BUFFERS */ +#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCP_WRITE_BUFFERS */ -- cgit v1.2.3