diff --git a/reactos/ntoskrnl/include/internal/lpc.h b/reactos/ntoskrnl/include/internal/lpc.h index 28bb3b31761..c6d3a14d781 100644 --- a/reactos/ntoskrnl/include/internal/lpc.h +++ b/reactos/ntoskrnl/include/internal/lpc.h @@ -60,7 +60,7 @@ // // LPC Locking Flags // -#define LPCP_LOCK_OWNED 1 +#define LPCP_LOCK_HELD 1 #define LPCP_LOCK_RELEASE 2 // diff --git a/reactos/ntoskrnl/lpc/close.c b/reactos/ntoskrnl/lpc/close.c index eb301c46137..74796d3350c 100644 --- a/reactos/ntoskrnl/lpc/close.c +++ b/reactos/ntoskrnl/lpc/close.c @@ -55,7 +55,7 @@ LpcpFreeToPortZone(IN PLPCP_MESSAGE Message, PLPCP_CONNECTION_MESSAGE ConnectMessage; PLPCP_PORT_OBJECT ClientPort = NULL; PETHREAD Thread = NULL; - BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_OWNED); + BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_HELD); BOOLEAN ReleaseLock = (LockFlags & LPCP_LOCK_RELEASE); PAGED_CODE(); @@ -186,7 +186,7 @@ LpcpDestroyPortQueue(IN PLPCP_PORT_OBJECT Port, Thread->LpcReplyMessage = NULL; /* And remove the message from the port zone */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD); NextEntry = Port->LpcReplyChainHead.Flink; } @@ -213,7 +213,7 @@ LpcpDestroyPortQueue(IN PLPCP_PORT_OBJECT Port, InitializeListHead(&Message->Entry); /* Remove it from the port zone */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD); } /* Release the lock */ @@ -407,7 +407,7 @@ LpcpDeletePort(IN PVOID ObjectBody) /* Free queued messages */ RemoveEntryList(&Message->Entry); InitializeListHead(&Message->Entry); - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD); /* Restart at the head */ NextEntry = ListHead->Flink; @@ -420,7 +420,7 @@ LpcpDeletePort(IN PVOID ObjectBody) /* Remove it */ RemoveEntryList(&Message->Entry); InitializeListHead(&Message->Entry); - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD); /* Restart at the head */ NextEntry = ListHead->Flink; diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index fa89d58970e..744c9105232 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -48,7 +48,7 @@ LpcpFreeDataInfoMessage(IN PLPCP_PORT_OBJECT Port, /* Unlink and free it */ RemoveEntryList(&Message->Entry); InitializeListHead(&Message->Entry); - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD); break; } @@ -63,7 +63,7 @@ LpcpSaveDataInfoMessage(IN PLPCP_PORT_OBJECT Port, IN PLPCP_MESSAGE Message, IN ULONG LockFlags) { - BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_OWNED); + BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_HELD); PAGED_CODE(); @@ -238,7 +238,7 @@ NtReplyPort(IN HANDLE PortHandle, Request) != LPC_REQUEST))) { /* It isn't, fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); if (ConnectionPort) ObDereferenceObject(ConnectionPort); ObDereferenceObject(WakeupThread); ObDereferenceObject(Port); @@ -257,7 +257,7 @@ NtReplyPort(IN HANDLE PortHandle, _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(WakeupThread); ObDereferenceObject(Port); _SEH2_YIELD(return _SEH2_GetExceptionCode()); @@ -482,7 +482,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, Request) != LPC_REQUEST))) { /* It isn't, fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); if (ConnectionPort) ObDereferenceObject(ConnectionPort); ObDereferenceObject(WakeupThread); ObDereferenceObject(Port); @@ -639,7 +639,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, if (Message->Request.u2.s2.DataInfoOffset) { /* It does, save it, and don't free the message below */ - LpcpSaveDataInfoMessage(Port, Message, LPCP_LOCK_OWNED); + LpcpSaveDataInfoMessage(Port, Message, LPCP_LOCK_HELD); Message = NULL; } } @@ -661,7 +661,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, if (Message) { /* Free it and release the lock */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); } else { diff --git a/reactos/ntoskrnl/lpc/send.c b/reactos/ntoskrnl/lpc/send.c index 72ae7dde0ec..7a3cd451929 100644 --- a/reactos/ntoskrnl/lpc/send.c +++ b/reactos/ntoskrnl/lpc/send.c @@ -104,7 +104,7 @@ LpcRequestPort(IN PVOID PortObject, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); return STATUS_PORT_DISCONNECTED; } } @@ -115,7 +115,7 @@ LpcRequestPort(IN PVOID PortObject, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); return STATUS_PORT_DISCONNECTED; } } @@ -134,7 +134,7 @@ LpcRequestPort(IN PVOID PortObject, if (QueuePort) { /* Generate the Message ID and set it */ - Message->Request.MessageId = LpcpNextMessageId++; + Message->Request.MessageId = LpcpNextMessageId++; if (!LpcpNextMessageId) LpcpNextMessageId = 1; Message->Request.CallbackId = 0; @@ -144,7 +144,7 @@ LpcRequestPort(IN PVOID PortObject, /* Insert the message in our chain */ InsertTailList(&QueuePort->MsgQueue.ReceiveHead, &Message->Entry); - /* Release the lock and release the semaphore */ + /* Release the lock and the semaphore */ KeEnterCriticalRegion(); KeReleaseGuardedMutex(&LpcpLock); LpcpCompleteWait(QueuePort->MsgQueue.Semaphore); @@ -156,15 +156,16 @@ LpcRequestPort(IN PVOID PortObject, KeSetEvent(&QueuePort->WaitEvent, IO_NO_INCREMENT, FALSE); } - /* We're done */ KeLeaveCriticalRegion(); + + /* We're done */ if (ConnectionPort) ObDereferenceObject(ConnectionPort); LPCTRACE(LPC_SEND_DEBUG, "Port: %p. Message: %p\n", QueuePort, Message); return STATUS_SUCCESS; } /* If we got here, then free the message and fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); if (ConnectionPort) ObDereferenceObject(ConnectionPort); return STATUS_PORT_DISCONNECTED; } @@ -284,7 +285,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject, if (!QueuePort) { /* We have no connected port, fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); return STATUS_PORT_DISCONNECTED; } @@ -300,7 +301,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); return STATUS_PORT_DISCONNECTED; } } @@ -312,7 +313,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); return STATUS_PORT_DISCONNECTED; } } @@ -331,7 +332,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject, Message->SenderPort = Port; /* Generate the Message ID and set it */ - Message->Request.MessageId = LpcpNextMessageId++; + Message->Request.MessageId = LpcpNextMessageId++; if (!LpcpNextMessageId) LpcpNextMessageId = 1; Message->Request.CallbackId = 0; @@ -413,7 +414,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject, } /* Free the message */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); } else { @@ -452,7 +453,6 @@ NtRequestPort(IN HANDLE PortHandle, PLPCP_MESSAGE Message; KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); PETHREAD Thread = PsGetCurrentThread(); - PKSEMAPHORE Semaphore; PAGED_CODE(); @@ -536,7 +536,7 @@ NtRequestPort(IN HANDLE PortHandle, if (!QueuePort) { /* We have no connected port, fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -550,7 +550,7 @@ NtRequestPort(IN HANDLE PortHandle, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -563,7 +563,7 @@ NtRequestPort(IN HANDLE PortHandle, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -585,7 +585,7 @@ NtRequestPort(IN HANDLE PortHandle, Message->SenderPort = Port; /* Generate the Message ID and set it */ - Message->Request.MessageId = LpcpNextMessageId++; + Message->Request.MessageId = LpcpNextMessageId++; if (!LpcpNextMessageId) LpcpNextMessageId = 1; Message->Request.CallbackId = 0; @@ -595,13 +595,10 @@ NtRequestPort(IN HANDLE PortHandle, /* Insert the message in our chain */ InsertTailList(&QueuePort->MsgQueue.ReceiveHead, &Message->Entry); - /* Release the lock and get the semaphore we'll use later */ + /* Release the lock and the semaphore */ KeEnterCriticalRegion(); KeReleaseGuardedMutex(&LpcpLock); - - /* Now release the semaphore */ - Semaphore = QueuePort->MsgQueue.Semaphore; - LpcpCompleteWait(Semaphore); + LpcpCompleteWait(QueuePort->MsgQueue.Semaphore); /* If this is a waitable port, wake it up */ if (QueuePort->Flags & LPCP_WAITABLE_PORT) @@ -629,7 +626,7 @@ NtRequestPort(IN HANDLE PortHandle, Status); /* The wait failed, free the message */ - if (Message) LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + if (Message) LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); if (ConnectionPort) ObDereferenceObject(ConnectionPort); @@ -762,7 +759,7 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle, if (!QueuePort) { /* We have no connected port, fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -779,7 +776,7 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -792,7 +789,7 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle, if (!ConnectionPort) { /* Fail */ - LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE); + LpcpFreeToPortZone(Message, LPCP_LOCK_HELD | LPCP_LOCK_RELEASE); ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } @@ -812,7 +809,7 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle, Message->SenderPort = Port; /* Generate the Message ID and set it */ - Message->Request.MessageId = LpcpNextMessageId++; + Message->Request.MessageId = LpcpNextMessageId++; if (!LpcpNextMessageId) LpcpNextMessageId = 1; Message->Request.CallbackId = 0;