Cleanup isn't necessary after calling the driver in NtQueryDirectoryFile.
[reactos.git] / reactos / ntoskrnl / lpc / close.c
index c73a8df..1091bfc 100644 (file)
@@ -1,10 +1,10 @@
 /* $Id$
- * 
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/lpc/close.c
  * PURPOSE:         Communication mechanism
- * 
+ *
  * PROGRAMMERS:     David Welch (welch@cwcom.net)
  */
 
  * REVISIONS
  */
 VOID STDCALL
-NiClosePort (PVOID     ObjectBody, ULONG       HandleCount)
+LpcpClosePort (PVOID   ObjectBody, ULONG       HandleCount)
 {
   PEPORT Port = (PEPORT)ObjectBody;
-  LPC_MESSAGE Message;
+  PORT_MESSAGE Message;
 
   /* FIXME Race conditions here! */
 
@@ -44,8 +44,8 @@ NiClosePort (PVOID    ObjectBody, ULONG       HandleCount)
   if (HandleCount == 1 && Port->State == EPORT_CONNECTED_CLIENT)
     {
       DPRINT("Informing server\n");
-      Message.MessageSize = sizeof(LPC_MESSAGE);
-      Message.DataSize = 0;
+      Message.u1.s1.TotalLength = sizeof(PORT_MESSAGE);
+      Message.u1.s1.DataLength = 0;
       EiReplyOrRequestPort (Port->OtherPort,
                            &Message,
                            LPC_PORT_CLOSED,
@@ -85,11 +85,29 @@ NiClosePort (PVOID  ObjectBody, ULONG       HandleCount)
  * REVISIONS
  */
 VOID STDCALL
-NiDeletePort (PVOID    ObjectBody)
+LpcpDeletePort (PVOID  ObjectBody)
 {
-   //   PEPORT Port = (PEPORT)ObjectBody;
-   
-   //   DPRINT1("Deleting port %x\n", Port);
+   PLIST_ENTRY Entry;
+   PQUEUEDMESSAGE      Message;
+
+   PEPORT Port = (PEPORT)ObjectBody;
+
+   DPRINT("Deleting port %x\n", Port);
+
+   /* Free all waiting messages */
+   while (!IsListEmpty(&Port->QueueListHead))
+     {
+       Entry = RemoveHeadList(&Port->QueueListHead);
+       Message = CONTAINING_RECORD (Entry, QUEUEDMESSAGE, QueueListEntry);
+       ExFreePool(Message);
+     }
+
+   while (!IsListEmpty(&Port->ConnectQueueListHead))
+     {
+       Entry = RemoveHeadList(&Port->ConnectQueueListHead);
+       Message = CONTAINING_RECORD (Entry, QUEUEDMESSAGE, QueueListEntry);
+       ExFreePool(Message);
+     }
 }