-/* $Id: close.c,v 1.14 2004/09/13 19:10:45 gvg Exp $
- *
+/* $Id$
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/lpc/close.c
* PURPOSE: Communication mechanism
- * PROGRAMMER: David Welch (welch@cwcom.net)
- * UPDATE HISTORY:
- * Created 22/05/98
+ *
+ * PROGRAMMERS: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
* 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! */
* If the client has just closed its handle then tell the server what
* happened and disconnect this port.
*/
- if (HandleCount == 0 && Port->State == EPORT_CONNECTED_CLIENT &&
- ObGetObjectPointerCount(Port) == 2)
+ 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,
* If the server has closed all of its handles then disconnect the port,
* don't actually notify the client until it attempts an operation.
*/
- if (HandleCount == 0 && Port->State == EPORT_CONNECTED_SERVER &&
- ObGetObjectPointerCount(Port) == 1)
+ if (HandleCount == 1 && Port->State == EPORT_CONNECTED_SERVER)
{
DPRINT("Cleaning up server\n");
Port->OtherPort->OtherPort = NULL;
* 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);
+ }
}