Author: cgutman
Date: Sat Aug 6 21:28:11 2011
New Revision: 53105
URL:
http://svn.reactos.org/svn/reactos?rev=53105&view=rev
Log:
[LWIP]
- Fix leaking queued packets after a socket is closed by an error
- Always call tcp_write to ensure that the Nagle code knows that we're full
Modified:
branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Sat Aug
6 21:28:11 2011
@@ -155,13 +155,9 @@
Socket = Connection->SocketContext;
- /* Don't try to close again if the other side closed us already */
- if (Connection->SocketContext)
- {
- FlushAllQueues(Connection, STATUS_CANCELLED);
-
- LibTCPClose(Connection, FALSE, TRUE);
- }
+ FlushAllQueues(Connection, STATUS_CANCELLED);
+
+ LibTCPClose(Connection, FALSE, TRUE);
UnlockObject(Connection, OldIrql);
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Sat Aug 6
21:28:11 2011
@@ -460,17 +460,18 @@
goto done;
}
- if (tcp_sndbuf((PTCP_PCB)msg->Input.Send.Connection->SocketContext) <
msg->Input.Send.DataLength)
- {
+ msg->Output.Send.Error =
tcp_write((PTCP_PCB)msg->Input.Send.Connection->SocketContext,
+ msg->Input.Send.Data,
+ msg->Input.Send.DataLength,
+ TCP_WRITE_FLAG_COPY);
+ if (msg->Output.Send.Error == ERR_MEM)
+ {
+ /* No buffer space so return pending */
msg->Output.Send.Error = ERR_INPROGRESS;
}
- else
- {
- msg->Output.Send.Error =
tcp_write((PTCP_PCB)msg->Input.Send.Connection->SocketContext,
- msg->Input.Send.Data,
- msg->Input.Send.DataLength,
- TCP_WRITE_FLAG_COPY);
-
+ else if (msg->Output.Send.Error == ERR_OK)
+ {
+ /* Queued successfully so try to send it */
tcp_output((PTCP_PCB)msg->Input.Send.Connection->SocketContext);
}
@@ -643,13 +644,14 @@
PTCP_PCB pcb = msg->Input.Close.Connection->SocketContext;
int state;
+ /* Empty the queue even if we're already "closed" */
+ LibTCPEmptyQueue(msg->Input.Close.Connection);
+
if (!msg->Input.Close.Connection->SocketContext)
{
msg->Output.Close.Error = ERR_OK;
goto done;
}
-
- LibTCPEmptyQueue(msg->Input.Close.Connection);
/* Clear the PCB pointer */
msg->Input.Close.Connection->SocketContext = NULL;