1 /* $Id: close.c,v 1.12 2003/07/11 01:23:15 royce 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 *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/port.h>
16 #include <internal/dbg.h>
19 #include <internal/debug.h>
21 /* FUNCTIONS *****************************************************************/
23 /**********************************************************************
35 NiClosePort (PVOID ObjectBody
, ULONG HandleCount
)
37 PEPORT Port
= (PEPORT
)ObjectBody
;
41 * If the client has just closed its handle then tell the server what
42 * happened and disconnect this port.
44 if (HandleCount
== 0 && Port
->State
== EPORT_CONNECTED_CLIENT
&&
45 ObGetObjectPointerCount(Port
) == 2)
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
== 0 && Port
->State
== EPORT_CONNECTED_SERVER
&&
67 ObGetObjectPointerCount(Port
) == 2)
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);