From 806af1f4e250d3b0b5f60052f48d68a3c6de3f1e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 14 Jan 2014 15:17:53 -0600 Subject: [PATCH] When dup'ing sockets, need to clone fields for TCP write buffering too --- ChangeLog | 2 ++ include/nuttx/net/net.h | 2 +- include/nuttx/net/uip/uip-tcp.h | 2 +- net/Kconfig | 2 +- net/net_clone.c | 7 +++++++ net/net_send_buffered.c | 8 ++++---- net/socket.c | 7 ++----- net/uip/uip_tcpwrbuffer.c | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c08ef7c7d..68640e5a36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6436,4 +6436,6 @@ in the PX4 GIT repository. * fs/fat/fs_fat32.c: A correction to FAT cluster allocation from Tridge via Lorenz Meier (2014-1-14). + * net/net_clone.c: Need to clone fields for TCP write buffering + as well (2014-1-14). diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index dffa47592a..46858b8c5b 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -106,7 +106,7 @@ struct socket FAR void *s_conn; /* Connection: struct uip_conn or uip_udp_conn */ -#ifdef CONFIG_NET_NTCP_WRITE_BUFFERS +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS /* Callback instance for TCP send */ FAR struct uip_callback_s *s_sndcb; diff --git a/include/nuttx/net/uip/uip-tcp.h b/include/nuttx/net/uip/uip-tcp.h index 55d281cc0d..001ae088e6 100644 --- a/include/nuttx/net/uip/uip-tcp.h +++ b/include/nuttx/net/uip/uip-tcp.h @@ -162,7 +162,7 @@ struct uip_conn uint16_t mss; /* Current maximum segment size for the * connection */ uint16_t winsize; /* Current window size of the connection */ -#ifdef CONFIG_NET_NTCP_WRITE_BUFFERS +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS uint32_t unacked; /* Number bytes sent but not yet ACKed */ #else uint16_t unacked; /* Number bytes sent but not yet ACKed */ diff --git a/net/Kconfig b/net/Kconfig index 83b72cb716..b15b7ee9af 100644 --- a/net/Kconfig +++ b/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/net/net_clone.c b/net/net_clone.c index b58c7e1c62..5efed0944c 100644 --- a/net/net_clone.c +++ b/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/net/net_send_buffered.c b/net/net_send_buffered.c index a73ceca238..e251c65ac7 100644 --- a/net/net_send_buffered.c +++ b/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/net/socket.c b/net/socket.c index 910154de95..7b8db0c05a 100644 --- a/net/socket.c +++ b/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/net/uip/uip_tcpwrbuffer.c b/net/uip/uip_tcpwrbuffer.c index b562b894c5..c729dd4b87 100644 --- a/net/uip/uip_tcpwrbuffer.c +++ b/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 */