Author: cgutman
Date: Sat Aug 6 10:07:24 2011
New Revision: 53097
URL:
http://svn.reactos.org/svn/reactos?rev=53097&view=rev
Log:
[LWIP]
- Fix a couple bugs in my previous commit
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 10:07:24 2011
@@ -476,7 +476,6 @@
PVOID Context )
{
PTDI_BUCKET Bucket;
- KIRQL OldIrql;
PUCHAR DataBuffer;
UINT DataLen, Received;
NTSTATUS Status;
@@ -485,8 +484,6 @@
ReceiveLength, Connection->SocketContext));
NdisQueryBuffer(Buffer, &DataBuffer, &DataLen);
-
- LockObject(Connection, &OldIrql);
Status = LibTCPGetDataFromConnectionQueue(Connection, DataBuffer, DataLen,
&Received);
@@ -498,7 +495,6 @@
if (!Bucket)
{
TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Failed to allocate
bucket\n"));
- UnlockObject(Connection, OldIrql);
return STATUS_NO_MEMORY;
}
@@ -506,7 +502,7 @@
Bucket->Request.RequestNotifyObject = Complete;
Bucket->Request.RequestContext = Context;
- InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry );
+ ExInterlockedInsertTailList( &Connection->ReceiveRequest,
&Bucket->Entry, &Connection->Lock );
TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Queued read irp\n"));
TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Leaving. Status =
STATUS_PENDING\n"));
@@ -517,8 +513,6 @@
{
(*BytesReceived) = Received;
}
-
- UnlockObject(Connection, OldIrql);
return Status;
}
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
10:07:24 2011
@@ -83,9 +83,13 @@
PQUEUE_ENTRY qp;
struct pbuf* p;
NTSTATUS Status = STATUS_PENDING;
- UINT ReadLength, ExistingDataLength;
+ UINT ReadLength, ExistingDataLength, SpaceLeft;
+ KIRQL OldIrql;
(*Received) = 0;
+ SpaceLeft = RecvLen;
+
+ LockObject(Connection, &OldIrql);
if (!IsListEmpty(&Connection->PacketQueue))
{
@@ -94,14 +98,37 @@
p = qp->p;
ExistingDataLength = (*Received);
- ReadLength = MIN(p->tot_len, RecvLen);
-
+ Status = STATUS_SUCCESS;
+
+ ReadLength = MIN(p->tot_len, SpaceLeft);
+ if (ReadLength != p->tot_len)
+ {
+ if (ExistingDataLength)
+ {
+ /* The packet was too big but we used some data already so give it
another shot later */
+ InsertHeadList(&Connection->PacketQueue,
&qp->ListEntry);
+ break;
+ }
+ else
+ {
+ /* The packet is just too big to fit fully in our buffer, even when
empty so
+ * return an informative status but still copy all the data we can
fit.
+ */
+ Status = STATUS_BUFFER_OVERFLOW;
+ }
+ }
+
+ UnlockObject(Connection, OldIrql);
+
+ /* Return to a lower IRQL because the receive buffer may be pageable memory
*/
for (; (*Received) < ReadLength + ExistingDataLength; (*Received) +=
p->len, p = p->next)
{
RtlCopyMemory(RecvBuffer + (*Received), p->payload, p->len);
}
- RecvLen -= ReadLength;
+ LockObject(Connection, &OldIrql);
+
+ SpaceLeft -= ReadLength;
/* Use this special pbuf free callback function because we're outside
tcpip thread */
pbuf_free_callback(qp->p);
@@ -110,9 +137,10 @@
if (!RecvLen)
break;
+
+ if (Status != STATUS_SUCCESS)
+ break;
}
-
- Status = STATUS_SUCCESS;
}
else
{
@@ -121,6 +149,8 @@
else
Status = STATUS_PENDING;
}
+
+ UnlockObject(Connection, OldIrql);
return Status;
}