diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index 7c4aa317d7c..912aa094162 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -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"); } diff --git a/reactos/ntoskrnl/lpc/close.c b/reactos/ntoskrnl/lpc/close.c index 1f16b975a07..ce70f329c1c 100644 --- a/reactos/ntoskrnl/lpc/close.c +++ b/reactos/ntoskrnl/lpc/close.c @@ -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); diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index db71510f17c..b45a6de7a15 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -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, diff --git a/reactos/ntoskrnl/lpc/send.c b/reactos/ntoskrnl/lpc/send.c index d29d2166a17..9f3debfbfb0 100644 --- a/reactos/ntoskrnl/lpc/send.c +++ b/reactos/ntoskrnl/lpc/send.c @@ -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