summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-01-13 17:26:11 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-01-13 17:26:11 -0600
commit2244d340c287b97bb46fe5b534f4deade40a4c76 (patch)
treedd6a3c8555c534e34795931d8e220cc81b9ed24a
parent7b7ea4c0431da13dd75cc1c2d8d032e8835fbf0e (diff)
downloadnuttx-2244d340c287b97bb46fe5b534f4deade40a4c76.tar.gz
nuttx-2244d340c287b97bb46fe5b534f4deade40a4c76.tar.bz2
nuttx-2244d340c287b97bb46fe5b534f4deade40a4c76.zip
More TCP write buffer code. Part of big change from Jason Jiang
-rw-r--r--nuttx/net/uip/uip_tcpconn.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/nuttx/net/uip/uip_tcpconn.c b/nuttx/net/uip/uip_tcpconn.c
index 071936db1..9809df183 100644
--- a/nuttx/net/uip/uip_tcpconn.c
+++ b/nuttx/net/uip/uip_tcpconn.c
@@ -306,7 +306,10 @@ void uip_tcpfree(struct uip_conn *conn)
FAR struct uip_callback_s *cb;
FAR struct uip_callback_s *next;
#ifdef CONFIG_NET_TCP_READAHEAD
- struct uip_readahead_s *readahead;
+ FAR struct uip_readahead_s *readahead;
+#endif
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ FAR struct uip_wrbuffer_s *wrbuffer;
#endif
uip_lock_t flags;
@@ -339,18 +342,32 @@ void uip_tcpfree(struct uip_conn *conn)
dq_rem(&conn->node, &g_active_tcp_connections);
}
+#ifdef CONFIG_NET_TCP_READAHEAD
/* Release any read-ahead buffers attached to the connection */
-#ifdef CONFIG_NET_TCP_READAHEAD
while ((readahead = (struct uip_readahead_s *)sq_remfirst(&conn->readahead)) != NULL)
{
uip_tcpreadaheadrelease(readahead);
}
#endif
- /* Remove any backlog attached to this connection */
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ /* Release any write buffers attached to the connection */
+
+ while ((wrbuffer = (struct uip_wrbuffer_s *)sq_remfirst(&conn->write_q)) != NULL)
+ {
+ uip_tcpwrbuffer_release(wrbuffer);
+ }
+
+ while ((wrbuffer = (struct uip_wrbuffer_s *)sq_remfirst(&conn->unacked_q)) != NULL)
+ {
+ uip_tcpwrbuffer_release(wrbuffer);
+ }
+#endif
#ifdef CONFIG_NET_TCPBACKLOG
+ /* Remove any backlog attached to this connection */
+
if (conn->backlog)
{
uip_backlogdestroy(conn);
@@ -503,17 +520,29 @@ struct uip_conn *uip_tcpaccept(struct uip_tcpip_hdr *buf)
uip_tcpinitsequence(conn->sndseq);
conn->unacked = 1;
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ conn->expired = 0;
+ conn->isn = 0;
+ conn->sent = 0;
+#endif
/* rcvseq should be the seqno from the incoming packet + 1. */
memcpy(conn->rcvseq, buf->seqno, 4);
+#ifdef CONFIG_NET_TCP_READAHEAD
/* Initialize the list of TCP read-ahead buffers */
-#ifdef CONFIG_NET_TCP_READAHEAD
sq_init(&conn->readahead);
#endif
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ /* Initialize the write buffer lists */
+
+ sq_init(&conn->write_q);
+ sq_init(&conn->unacked_q);
+#endif
+
/* And, finally, put the connection structure into the active list.
* Interrupts should already be disabled in this context.
*/
@@ -642,6 +671,11 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr)
conn->sa = 0;
conn->sv = 16; /* Initial value of the RTT variance. */
conn->lport = htons((uint16_t)port);
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ conn->expired = 0;
+ conn->isn = 0;
+ conn->sent = 0;
+#endif
/* The sockaddr port is 16 bits and already in network order */
@@ -651,12 +685,19 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr)
uip_ipaddr_copy(conn->ripaddr, addr->sin_addr.s_addr);
+#ifdef CONFIG_NET_TCP_READAHEAD
/* Initialize the list of TCP read-ahead buffers */
-#ifdef CONFIG_NET_TCP_READAHEAD
sq_init(&conn->readahead);
#endif
+#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
+ /* Initialize the TCP write buffer lists */
+
+ sq_init(&conn->write_q);
+ sq_init(&conn->unacked_q);
+#endif
+
/* And, finally, put the connection structure into the active
* list. Because g_active_tcp_connections is accessed from user level and
* interrupt level, code, it is necessary to keep interrupts disabled during