1 /* $Id: close.c,v 1.13 2004/08/15 16:39:06 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/close.c
6 * PURPOSE: Communication mechanism
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
16 #include <internal/debug.h>
18 /* FUNCTIONS *****************************************************************/
20 /**********************************************************************
32 NiClosePort (PVOID ObjectBody
, ULONG HandleCount
)
34 PEPORT Port
= (PEPORT
)ObjectBody
;
38 * If the client has just closed its handle then tell the server what
39 * happened and disconnect this port.
41 if (HandleCount
== 0 && Port
->State
== EPORT_CONNECTED_CLIENT
&&
42 ObGetObjectPointerCount(Port
) == 2)
44 Message
.MessageSize
= sizeof(LPC_MESSAGE
);
46 EiReplyOrRequestPort (Port
->OtherPort
,
50 Port
->OtherPort
->OtherPort
= NULL
;
51 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
52 KeReleaseSemaphore( &Port
->OtherPort
->Semaphore
,
56 ObDereferenceObject (Port
);
60 * If the server has closed all of its handles then disconnect the port,
61 * don't actually notify the client until it attempts an operation.
63 if (HandleCount
== 0 && Port
->State
== EPORT_CONNECTED_SERVER
&&
64 ObGetObjectPointerCount(Port
) == 2)
66 Port
->OtherPort
->OtherPort
= NULL
;
67 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
68 ObDereferenceObject(Port
->OtherPort
);
73 /**********************************************************************
85 NiDeletePort (PVOID ObjectBody
)
87 // PEPORT Port = (PEPORT)ObjectBody;
89 // DPRINT1("Deleting port %x\n", Port);