diff --git a/lib/drivers/ip/transport/tcp/event.c b/lib/drivers/ip/transport/tcp/event.c index b9b88220e53..1729b13a2af 100644 --- a/lib/drivers/ip/transport/tcp/event.c +++ b/lib/drivers/ip/transport/tcp/event.c @@ -46,7 +46,6 @@ BucketCompletionWorker(PVOID Context) ExFreePoolWithTag(Bucket, TDI_BUCKET_TAG); } -static VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, BOOLEAN Synchronous) { @@ -149,23 +148,11 @@ TCPFinEventHandler(void *arg, err_t err) DbgPrint("[IP, TCPFinEventHandler] Called for Connection( 0x%x )-> SocketContext = pcb (0x%x)\n", Connection, Connection->SocketContext); /* Only clear the pointer if the shutdown was caused by an error */ - if ((err != ERR_OK))// && (status != STATUS_REMOTE_DISCONNECT)) + if ((err != ERR_OK)) { /* We're already closed by the error so we don't want to call lwip_close */ DbgPrint("[IP, TCPFinEventHandler] MAKING Connection( 0x%x )-> SocketContext = pcb (0x%x) NULL\n", Connection, Connection->SocketContext); - // close all possible callbacks - /*tcp_arg((PTCP_PCB)Connection->SocketContext, NULL); - - if (((PTCP_PCB)Connection->SocketContext)->state != LISTEN) - { - tcp_recv((PTCP_PCB)Connection->SocketContext, NULL); - tcp_sent((PTCP_PCB)Connection->SocketContext, NULL); - tcp_err((PTCP_PCB)Connection->SocketContext, NULL); - } - - tcp_accept((PTCP_PCB)Connection->SocketContext, NULL);*/ - Connection->SocketContext = NULL; } diff --git a/lib/drivers/ip/transport/tcp/tcp.c b/lib/drivers/ip/transport/tcp/tcp.c index f482ea1fdaa..5b25b5f9c56 100644 --- a/lib/drivers/ip/transport/tcp/tcp.c +++ b/lib/drivers/ip/transport/tcp/tcp.c @@ -428,7 +428,7 @@ NTSTATUS TCPReceiveData /* Freed in TCPSocketState */ Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket), TDI_BUCKET_TAG ); - if( !Bucket ) + if (!Bucket) { TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Failed to allocate bucket\n")); UnlockObject(Connection, OldIrql); @@ -438,20 +438,25 @@ NTSTATUS TCPReceiveData Bucket->Request.RequestNotifyObject = Complete; Bucket->Request.RequestContext = Context; - *BytesReceived = 0; - + InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry ); TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Queued read irp\n")); UnlockObject(Connection, OldIrql); TI_DbgPrint(DEBUG_TCP,("[IP, TCPReceiveData] Leaving. Status = STATUS_PENDING\n")); + + (*BytesReceived) = 0; + } + else + { + (*BytesReceived) = Received; } DbgPrint("[IP, TCPReceiveData] Leaving. Status = %s\n", Status == STATUS_PENDING? "STATUS_PENDING" : "STATUS_SUCCESS"); - return STATUS_PENDING; + return Status; } NTSTATUS TCPSendData diff --git a/lib/drivers/lwip/src/rostcp.c b/lib/drivers/lwip/src/rostcp.c index 546b07ee601..987f38e722a 100755 --- a/lib/drivers/lwip/src/rostcp.c +++ b/lib/drivers/lwip/src/rostcp.c @@ -47,7 +47,7 @@ LibTCPEmptyQueue(PCONNECTION_ENDPOINT Connection) qp = CONTAINING_RECORD(Entry, QUEUE_ENTRY, ListEntry); // reenable this later - //pbuf_free(qp->p); + pbuf_free(qp->p); ExFreePoolWithTag(qp, LWIP_TAG); } @@ -92,7 +92,7 @@ NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHA RecvLen = MIN(p->tot_len, RecvLen); - for ((*Received) = 0; (*Received) < RecvLen; *Received += p->len, p = p->next) + for ((*Received) = 0; (*Received) < RecvLen; (*Received) += p->len, p = p->next) { DbgPrint("[lwIP, LibTCPGetDataFromConnectionQueue] 0x%x: Copying %d bytes to 0x%x from 0x%x\n", p, p->len, ((PUCHAR)RecvBuffer) + (*Received), p->payload); @@ -101,7 +101,7 @@ NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHA } // reenable this later - //pbuf_free(qp->p); + pbuf_free(qp->p); ExFreePoolWithTag(qp, LWIP_TAG); Status = STATUS_SUCCESS;