3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/close.c
6 * PURPOSE: Communication mechanism
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 /* FUNCTIONS *****************************************************************/
19 /**********************************************************************
31 NiClosePort (PVOID ObjectBody
, ULONG HandleCount
)
33 PEPORT Port
= (PEPORT
)ObjectBody
;
36 /* FIXME Race conditions here! */
38 DPRINT("NiClosePort 0x%p OtherPort 0x%p State %d\n", Port
, Port
->OtherPort
, Port
->State
);
41 * If the client has just closed its handle then tell the server what
42 * happened and disconnect this port.
44 if (HandleCount
== 1 && Port
->State
== EPORT_CONNECTED_CLIENT
)
46 DPRINT("Informing server\n");
47 Message
.MessageSize
= sizeof(LPC_MESSAGE
);
49 EiReplyOrRequestPort (Port
->OtherPort
,
53 Port
->OtherPort
->OtherPort
= NULL
;
54 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
55 KeReleaseSemaphore( &Port
->OtherPort
->Semaphore
,
59 ObDereferenceObject (Port
);
63 * If the server has closed all of its handles then disconnect the port,
64 * don't actually notify the client until it attempts an operation.
66 if (HandleCount
== 1 && Port
->State
== EPORT_CONNECTED_SERVER
)
68 DPRINT("Cleaning up server\n");
69 Port
->OtherPort
->OtherPort
= NULL
;
70 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
71 ObDereferenceObject(Port
->OtherPort
);
76 /**********************************************************************
88 NiDeletePort (PVOID ObjectBody
)
90 // PEPORT Port = (PEPORT)ObjectBody;
92 // DPRINT1("Deleting port %x\n", Port);