Fix closing of LPC ports

svn path=/trunk/; revision=10847
This commit is contained in:
Gé van Geldorp 2004-09-13 19:10:45 +00:00
parent 32bd722bb4
commit 2161bebe79
4 changed files with 25 additions and 8 deletions

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.64 2004/08/29 14:46:02 weiden Exp $
/* $Id: proc.c,v 1.65 2004/09/13 19:10:45 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -639,8 +639,7 @@ ExitProcess(UINT uExitCode)
sizeof(CSRSS_API_REPLY));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
{
DbgPrint("Failed to tell csrss about terminating process. "
"Expect trouble.\n");
DPRINT("Failed to tell csrss about terminating process\n");
}

View file

@ -1,4 +1,4 @@
/* $Id: close.c,v 1.13 2004/08/15 16:39:06 chorns Exp $
/* $Id: close.c,v 1.14 2004/09/13 19:10:45 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -33,7 +33,11 @@ NiClosePort (PVOID ObjectBody, ULONG HandleCount)
{
PEPORT Port = (PEPORT)ObjectBody;
LPC_MESSAGE Message;
/* FIXME Race conditions here! */
DPRINT("NiClosePort 0x%p OtherPort 0x%p State %d\n", Port, Port->OtherPort, Port->State);
/*
* If the client has just closed its handle then tell the server what
* happened and disconnect this port.
@ -41,6 +45,7 @@ NiClosePort (PVOID ObjectBody, ULONG HandleCount)
if (HandleCount == 0 && Port->State == EPORT_CONNECTED_CLIENT &&
ObGetObjectPointerCount(Port) == 2)
{
DPRINT("Informing server\n");
Message.MessageSize = sizeof(LPC_MESSAGE);
Message.DataSize = 0;
EiReplyOrRequestPort (Port->OtherPort,
@ -61,8 +66,9 @@ NiClosePort (PVOID ObjectBody, ULONG HandleCount)
* don't actually notify the client until it attempts an operation.
*/
if (HandleCount == 0 && Port->State == EPORT_CONNECTED_SERVER &&
ObGetObjectPointerCount(Port) == 2)
ObGetObjectPointerCount(Port) == 1)
{
DPRINT("Cleaning up server\n");
Port->OtherPort->OtherPort = NULL;
Port->OtherPort->State = EPORT_DISCONNECTED;
ObDereferenceObject(Port->OtherPort);

View file

@ -1,4 +1,4 @@
/* $Id: reply.c,v 1.21 2004/08/15 16:39:06 chorns Exp $
/* $Id: reply.c,v 1.22 2004/09/13 19:10:45 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -99,6 +99,12 @@ NtReplyPort (IN HANDLE PortHandle,
DPRINT("NtReplyPort() = %x\n", Status);
return(Status);
}
if (EPORT_DISCONNECTED == Port->State)
{
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
Status = EiReplyOrRequestPort(Port->OtherPort,
LpcReply,

View file

@ -1,4 +1,4 @@
/* $Id: send.c,v 1.17 2004/08/31 20:17:18 hbirr Exp $
/* $Id: send.c,v 1.18 2004/09/13 19:10:45 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -240,6 +240,12 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle,
return(Status);
}
if (EPORT_DISCONNECTED == Port->State)
{
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
/* win32k sometimes needs to KeAttach() the CSRSS process in order to make
the PortHandle valid. Now that we've got the EPORT structure from the
handle we can undo this, so everything is normal again. Need to