}
VOID
-FlushReceiveQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status, const BOOLEAN interlocked)
+FlushReceiveQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
{
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
+ ASSERT_TCPIP_OBJECT_LOCKED(Connection);
- if (interlocked)
+ while (!IsListEmpty(&Connection->ReceiveRequest))
{
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ReceiveRequest, &Connection->Lock)))
- {
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
-
- TI_DbgPrint(DEBUG_TCP,
- ("Completing Receive request: %x %x\n",
- Bucket->Request, Status));
+ Entry = RemoveHeadList(&Connection->ReceiveRequest);
- Bucket->Status = Status;
- Bucket->Information = 0;
+ Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
- CompleteBucket(Connection, Bucket, FALSE);
- }
- }
- else
- {
- while (!IsListEmpty(&Connection->ReceiveRequest))
- {
- Entry = RemoveHeadList(&Connection->ReceiveRequest);
-
- Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
-
- Bucket->Information = 0;
- Bucket->Status = Status;
+ Bucket->Information = 0;
+ Bucket->Status = Status;
- CompleteBucket(Connection, Bucket, FALSE);
- }
+ CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
}
VOID
-FlushSendQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status, const BOOLEAN interlocked)
+FlushSendQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
{
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
+ ASSERT_TCPIP_OBJECT_LOCKED(Connection);
- if (interlocked)
+ while (!IsListEmpty(&Connection->SendRequest))
{
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->SendRequest, &Connection->Lock)))
- {
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
-
- TI_DbgPrint(DEBUG_TCP,
- ("Completing Send request: %x %x\n",
- Bucket->Request, Status));
-
- Bucket->Status = Status;
- Bucket->Information = 0;
-
- CompleteBucket(Connection, Bucket, FALSE);
- }
- }
- else
- {
- while (!IsListEmpty(&Connection->SendRequest))
- {
- Entry = RemoveHeadList(&Connection->SendRequest);
+ Entry = RemoveHeadList(&Connection->SendRequest);
- Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
+ Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
- Bucket->Information = 0;
- Bucket->Status = Status;
+ Bucket->Information = 0;
+ Bucket->Status = Status;
- CompleteBucket(Connection, Bucket, FALSE);
- }
+ CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
}
VOID
-FlushShutdownQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status, const BOOLEAN interlocked)
+FlushShutdownQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
{
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
-
- if (interlocked)
- {
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ShutdownRequest, &Connection->Lock)))
- {
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
-
- Bucket->Status = Status;
- Bucket->Information = 0;
+ ASSERT_TCPIP_OBJECT_LOCKED(Connection);
- CompleteBucket(Connection, Bucket, FALSE);
- }
- }
- else
+ while (!IsListEmpty(&Connection->ShutdownRequest))
{
- while (!IsListEmpty(&Connection->ShutdownRequest))
- {
- Entry = RemoveHeadList(&Connection->ShutdownRequest);
+ Entry = RemoveHeadList(&Connection->ShutdownRequest);
- Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
+ Bucket = CONTAINING_RECORD(Entry, TDI_BUCKET, Entry);
- Bucket->Information = 0;
- Bucket->Status = Status;
+ Bucket->Information = 0;
+ Bucket->Status = Status;
- CompleteBucket(Connection, Bucket, FALSE);
- }
+ CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
}
VOID
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
+ ASSERT_TCPIP_OBJECT_LOCKED(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ConnectRequest, &Connection->Lock)))
+ while (!IsListEmpty(&Connection->ConnectRequest))
{
+ Entry = RemoveHeadList(&Connection->ConnectRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Bucket->Status = Status;
CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
}
VOID
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
+ ASSERT_TCPIP_OBJECT_LOCKED(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ListenRequest, &Connection->Lock)))
+ while (!IsListEmpty(&Connection->ListenRequest))
{
+ Entry = RemoveHeadList(&Connection->ListenRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Bucket->Status = Status;
DereferenceObject(Bucket->AssociatedEndpoint);
CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
}
VOID
FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
{
- ReferenceObject(Connection);
-
// flush receive queue
- FlushReceiveQueue(Connection, Status, TRUE);
+ FlushReceiveQueue(Connection, Status);
/* We completed the reads successfully but we need to return failure now */
if (Status == STATUS_SUCCESS)
FlushListenQueue(Connection, Status);
// flush send queue
- FlushSendQueue(Connection, Status, TRUE);
+ FlushSendQueue(Connection, Status);
// flush connect queue
FlushConnectQueue(Connection, Status);
// flush shutdown queue
- FlushShutdownQueue(Connection, Status, TRUE);
-
- DereferenceObject(Connection);
+ FlushShutdownQueue(Connection, Status);
}
VOID
{
PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)arg, LastConnection;
const NTSTATUS Status = TCPTranslateError(err);
- KIRQL OldIrql;
ASSERT(Connection->SocketContext == NULL);
ASSERT(Connection->AddressFile);
ASSERT(err != ERR_OK);
+ LockObject(Connection);
+
/* Complete all outstanding requests now */
FlushAllQueues(Connection, Status);
- LockObject(Connection, &OldIrql);
-
- LockObjectAtDpcLevel(Connection->AddressFile);
+ LockObject(Connection->AddressFile);
/* Unlink this connection from the address file */
if (Connection->AddressFile->Connection == Connection)
}
}
- UnlockObjectFromDpcLevel(Connection->AddressFile);
+ UnlockObject(Connection->AddressFile);
/* Remove the address file from this connection */
DereferenceObject(Connection->AddressFile);
Connection->AddressFile = NULL;
- UnlockObject(Connection, OldIrql);
+ UnlockObject(Connection);
}
VOID
PLIST_ENTRY Entry;
PIRP Irp;
NTSTATUS Status;
- KIRQL OldIrql;
- ReferenceObject(Connection);
+ LockObject(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ListenRequest, &Connection->Lock)))
+ while (!IsListEmpty(&Connection->ListenRequest))
{
PIO_STACK_LOCATION IrpSp;
+ Entry = RemoveHeadList(&Connection->ListenRequest);
+
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Irp = Bucket->Request.RequestContext;
if (Status == STATUS_SUCCESS)
{
- LockObject(Bucket->AssociatedEndpoint, &OldIrql);
+ LockObject(Bucket->AssociatedEndpoint);
/* sanity assert...this should never be in anything else but a CLOSED state */
ASSERT( ((PTCP_PCB)Bucket->AssociatedEndpoint->SocketContext)->state == CLOSED );
/* free previously created socket context (we don't use it, we use newpcb) */
Bucket->AssociatedEndpoint->SocketContext = newpcb;
- LibTCPAccept(newpcb, (PTCP_PCB)Connection->SocketContext, Bucket->AssociatedEndpoint);
+ UnlockObject(Bucket->AssociatedEndpoint);
- UnlockObject(Bucket->AssociatedEndpoint, OldIrql);
+ LibTCPAccept(newpcb, (PTCP_PCB)Connection->SocketContext, Bucket->AssociatedEndpoint);
}
DereferenceObject(Bucket->AssociatedEndpoint);
}
}
- DereferenceObject(Connection);
+ UnlockObject(Connection);
}
VOID
ULONG BytesSent;
ReferenceObject(Connection);
+ LockObject(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->SendRequest, &Connection->Lock)))
+ while (!IsListEmpty(&Connection->SendRequest))
{
UINT SendLen = 0;
PVOID SendBuffer = 0;
+ Entry = RemoveHeadList(&Connection->SendRequest);
+
+ UnlockObject(Connection);
+
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Irp = Bucket->Request.RequestContext;
if( Status == STATUS_PENDING )
{
- ExInterlockedInsertHeadList(&Connection->SendRequest,
- &Bucket->Entry,
- &Connection->Lock);
+ LockObject(Connection);
+ InsertHeadList(&Connection->SendRequest, &Bucket->Entry);
break;
}
else
CompleteBucket(Connection, Bucket, FALSE);
}
+
+ LockObject(Connection);
}
// If we completed all outstanding send requests then finish all pending shutdown requests,
// cancel the timer and dereference the connection
if (IsListEmpty(&Connection->SendRequest))
{
- FlushShutdownQueue(Connection, STATUS_SUCCESS, FALSE);
+ FlushShutdownQueue(Connection, STATUS_SUCCESS);
if (KeCancelTimer(&Connection->DisconnectTimer))
{
}
}
+ UnlockObject(Connection);
+
DereferenceObject(Connection);
}
PUCHAR RecvBuffer;
NTSTATUS Status;
- ReferenceObject(Connection);
+ LockObject(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ReceiveRequest, &Connection->Lock)))
+ while(!IsListEmpty(&Connection->ReceiveRequest))
{
+ Entry = RemoveHeadList(&Connection->ReceiveRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
Irp = Bucket->Request.RequestContext;
Status = LibTCPGetDataFromConnectionQueue(Connection, RecvBuffer, RecvLen, &Received);
if (Status == STATUS_PENDING)
{
- ExInterlockedInsertHeadList(&Connection->ReceiveRequest,
- &Bucket->Entry,
- &Connection->Lock);
+ InsertHeadList(&Connection->ReceiveRequest, &Bucket->Entry);
break;
}
CompleteBucket(Connection, Bucket, FALSE);
}
-
- DereferenceObject(Connection);
+ UnlockObject(Connection);
}
VOID
PTDI_BUCKET Bucket;
PLIST_ENTRY Entry;
- ReferenceObject(Connection);
+ LockObject(Connection);
- while ((Entry = ExInterlockedRemoveHeadList(&Connection->ConnectRequest, &Connection->Lock)))
+ while (!IsListEmpty(&Connection->ConnectRequest))
{
+ Entry = RemoveHeadList(&Connection->ConnectRequest);
Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
CompleteBucket(Connection, Bucket, FALSE);
}
- DereferenceObject(Connection);
+ UnlockObject(Connection);
}