2003-07-11 01:23:16 +00:00
|
|
|
/* $Id: close.c,v 1.12 2003/07/11 01:23:15 royce Exp $
|
2000-06-04 17:27:39 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
#include <internal/port.h>
|
|
|
|
#include <internal/dbg.h>
|
2000-06-04 17:27:39 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <internal/debug.h>
|
|
|
|
|
2001-12-02 23:34:43 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
2000-06-04 17:27:39 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
*
|
|
|
|
* ARGUMENTS
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* REVISIONS
|
|
|
|
*/
|
2001-08-26 17:30:21 +00:00
|
|
|
VOID STDCALL
|
2001-03-13 16:25:55 +00:00
|
|
|
NiClosePort (PVOID ObjectBody, ULONG HandleCount)
|
2000-06-04 17:27:39 +00:00
|
|
|
{
|
2001-03-13 16:25:55 +00:00
|
|
|
PEPORT Port = (PEPORT)ObjectBody;
|
|
|
|
LPC_MESSAGE Message;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 &&
|
2002-03-01 00:47:40 +00:00
|
|
|
ObGetObjectPointerCount(Port) == 2)
|
2001-03-13 16:25:55 +00:00
|
|
|
{
|
|
|
|
Message.MessageSize = sizeof(LPC_MESSAGE);
|
|
|
|
Message.DataSize = 0;
|
|
|
|
EiReplyOrRequestPort (Port->OtherPort,
|
|
|
|
&Message,
|
|
|
|
LPC_PORT_CLOSED,
|
|
|
|
Port);
|
|
|
|
Port->OtherPort->OtherPort = NULL;
|
|
|
|
Port->OtherPort->State = EPORT_DISCONNECTED;
|
2001-06-23 19:13:33 +00:00
|
|
|
KeReleaseSemaphore( &Port->OtherPort->Semaphore,
|
|
|
|
IO_NO_INCREMENT,
|
|
|
|
1,
|
|
|
|
FALSE );
|
2001-03-13 16:25:55 +00:00
|
|
|
ObDereferenceObject (Port);
|
|
|
|
}
|
2000-06-04 17:27:39 +00:00
|
|
|
|
2001-03-13 16:25:55 +00:00
|
|
|
/*
|
|
|
|
* 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 &&
|
2002-03-01 00:47:40 +00:00
|
|
|
ObGetObjectPointerCount(Port) == 2)
|
2001-03-13 16:25:55 +00:00
|
|
|
{
|
2000-12-10 23:42:01 +00:00
|
|
|
Port->OtherPort->OtherPort = NULL;
|
|
|
|
Port->OtherPort->State = EPORT_DISCONNECTED;
|
|
|
|
ObDereferenceObject(Port->OtherPort);
|
|
|
|
}
|
2000-06-04 17:27:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
*
|
|
|
|
* ARGUMENTS
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* REVISIONS
|
|
|
|
*/
|
2001-08-26 17:30:21 +00:00
|
|
|
VOID STDCALL
|
2000-12-10 23:42:01 +00:00
|
|
|
NiDeletePort (PVOID ObjectBody)
|
2000-06-04 17:27:39 +00:00
|
|
|
{
|
2000-12-10 23:42:01 +00:00
|
|
|
// PEPORT Port = (PEPORT)ObjectBody;
|
2000-06-04 17:27:39 +00:00
|
|
|
|
2000-12-10 23:42:01 +00:00
|
|
|
// DPRINT1("Deleting port %x\n", Port);
|
2000-06-04 17:27:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* EOF */
|