diff --git a/net/uip/uip_tcpconn.c b/net/uip/uip_tcpconn.c index 071936db16..9809df183a 100644 --- a/net/uip/uip_tcpconn.c +++ b/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