1 /* $Id: close.c,v 1.5 2001/06/23 19:13:33 phreak 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/ob.h>
16 #include <internal/port.h>
17 #include <internal/dbg.h>
20 #include <internal/debug.h>
23 /**********************************************************************
36 NiClosePort (PVOID ObjectBody
, ULONG HandleCount
)
38 PEPORT Port
= (PEPORT
)ObjectBody
;
42 * If the client has just closed its handle then tell the server what
43 * happened and disconnect this port.
45 if (HandleCount
== 0 && Port
->State
== EPORT_CONNECTED_CLIENT
&&
46 ObGetReferenceCount(Port
) == 2)
48 Message
.MessageSize
= sizeof(LPC_MESSAGE
);
50 EiReplyOrRequestPort (Port
->OtherPort
,
54 Port
->OtherPort
->OtherPort
= NULL
;
55 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
56 KeReleaseSemaphore( &Port
->OtherPort
->Semaphore
,
60 ObDereferenceObject (Port
);
64 * If the server has closed all of its handles then disconnect the port,
65 * don't actually notify the client until it attempts an operation.
67 if (HandleCount
== 0 && Port
->State
== EPORT_CONNECTED_SERVER
&&
68 ObGetReferenceCount(Port
) == 2)
70 Port
->OtherPort
->OtherPort
= NULL
;
71 Port
->OtherPort
->State
= EPORT_DISCONNECTED
;
72 ObDereferenceObject(Port
->OtherPort
);
77 /**********************************************************************
90 NiDeletePort (PVOID ObjectBody
)
92 // PEPORT Port = (PEPORT)ObjectBody;
94 // DPRINT1("Deleting port %x\n", Port);