Author: mjmartin
Date: Thu Apr  7 23:57:00 2011
New Revision: 51275

URL: http://svn.reactos.org/svn/reactos?rev=51275&view=rev
Log:
[Win32k]
- co_IntSendMessageWithCallBack: Insert the message into the messagequeue 
before attempting to wake the queue. Probably fixes bug 5580.
- Remove the use of MSQ_SENTNOWAIT that was used to determine if messagequeues 
needed dereferencing. Instead use the SenderQueue member of the message.
- Do not close the NewMessagesHandle member of the messagequeue in 
IntDereferenceMessageQueue. 
The last reference on a messagequeue could be released by a thread belonging to 
a process other than the on that created the handle.
Also the creating process could already be long gone. Instead close this handle 
in MsqDestroyMessageQueue which is in the thread/process that created the 
handle. Problem noticed by smiley.
- Revert change done in 51254. James you are indeed correct. 
Testing shows that the WM_PARENTNOTIFY message is not sent when the program is 
exiting.

Modified:
    trunk/reactos/subsystems/win32/win32k/include/msgqueue.h
    trunk/reactos/subsystems/win32/win32k/ntuser/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c

Modified: trunk/reactos/subsystems/win32/win32k/include/msgqueue.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/msgqueue.h?rev=51275&r1=51274&r2=51275&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/msgqueue.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/msgqueue.h [iso-8859-1] Thu 
Apr  7 23:57:00 2011
@@ -6,7 +6,6 @@
 #define MSQ_NORMAL      0
 #define MSQ_ISHOOK      1
 #define MSQ_ISEVENT     2
-#define MSQ_SENTNOWAIT  0x80000000
 
 #define QSIDCOUNTS 6
 
@@ -277,8 +276,6 @@
       DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
       if ((MsgQueue)->NewMessages != NULL) \
         ObDereferenceObject((MsgQueue)->NewMessages); \
-      if ((MsgQueue)->NewMessagesHandle != NULL) \
-        ZwClose((MsgQueue)->NewMessagesHandle); \
       ExFreePoolWithTag((MsgQueue), USERTAG_Q); \
     } \
   } while(0)

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/message.c?rev=51275&r1=51274&r2=51275&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Thu Apr 
 7 23:57:00 2011
@@ -1483,13 +1483,13 @@
     IntReferenceMessageQueue(Window->head.pti->MessageQueue);
     Message->CompletionCallback = CompletionCallback;
     Message->CompletionCallbackContext = CompletionCallbackContext;
-    Message->HookMessage = MSQ_NORMAL | MSQ_SENTNOWAIT;
+    Message->HookMessage = MSQ_NORMAL;
     Message->HasPackedLParam = (lParamBufferSize > 0);
-
     Message->QS_Flags = QS_SENDMESSAGE;
-    MsqWakeQueue(Window->head.pti->MessageQueue, QS_SENDMESSAGE, FALSE);
 
     InsertTailList(&Window->head.pti->MessageQueue->SentMessagesListHead, 
&Message->ListEntry);
+    MsqWakeQueue(Window->head.pti->MessageQueue, QS_SENDMESSAGE, TRUE);
+
     IntDereferenceMessageQueue(Window->head.pti->MessageQueue);
 
     RETURN(TRUE);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c?rev=51275&r1=51274&r2=51275&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Thu 
Apr  7 23:57:00 2011
@@ -479,7 +479,7 @@
    RemoveEntryList(&Message->ListEntry);
 
    /* remove the message from the dispatching list if needed, so lock the 
sender's message queue */
-   if (!(Message->HookMessage & MSQ_SENTNOWAIT))
+   if (Message->SenderQueue)
    {
       if (Message->DispatchingListEntry.Flink != NULL)
       {
@@ -523,8 +523,8 @@
                                     Result);
    }
 
-   /* Only if it is not a no wait message */
-   if (!(Message->HookMessage & MSQ_SENTNOWAIT))
+   /* Only if the message has a sender was the queue referenced */
+   if (Message->SenderQueue)
    {
       IntDereferenceMessageQueue(Message->SenderQueue);
       IntDereferenceMessageQueue(MessageQueue);
@@ -588,8 +588,8 @@
          RemoveEntryList(&SentMessage->ListEntry);
          ClearMsgBitsMask(MessageQueue, SentMessage->QS_Flags);
 
-         /* remove the message from the dispatching list if neede */
-         if ((!(SentMessage->HookMessage & MSQ_SENTNOWAIT))
+         /* Only if the message has a sender was the queue referenced */
+         if ((SentMessage->SenderQueue)
             && (SentMessage->DispatchingListEntry.Flink != NULL))
          {
             RemoveEntryList(&SentMessage->DispatchingListEntry);
@@ -607,8 +607,8 @@
                ExFreePool((PVOID)SentMessage->Msg.lParam);
          }
 
-         /* Only if it is not a no wait message */
-         if (!(SentMessage->HookMessage & MSQ_SENTNOWAIT))
+         /* Only if the message has a sender was the queue referenced */
+         if (SentMessage->SenderQueue)
          {
             /* dereference our and the sender's message queue */
             IntDereferenceMessageQueue(MessageQueue);
@@ -1451,9 +1451,8 @@
                                              ListEntry);
 
       DPRINT("Notify the sender and remove a message from the queue that had 
not been dispatched\n");
-
-      /* remove the message from the dispatching list if needed */
-      if ((!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT)) 
+      /* Only if the message has a sender was the queue referenced */
+      if ((CurrentSentMessage->SenderQueue) 
          && (CurrentSentMessage->DispatchingListEntry.Flink != NULL))
       {
          RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
@@ -1471,8 +1470,8 @@
             ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
       }
 
-      /* Only if it is not a no wait message */
-      if (!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT))
+      /* Only if the message has a sender was the queue referenced */
+      if (CurrentSentMessage->SenderQueue)
       {
          /* dereference our and the sender's message queue */
          IntDereferenceMessageQueue(MessageQueue);
@@ -1511,8 +1510,8 @@
             ExFreePool((PVOID)CurrentSentMessage->Msg.lParam);
       }
 
-      /* Only if it is not a no wait message */
-      if (!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT))
+      /* Only if the message has a sender was the queue referenced */
+      if (CurrentSentMessage->SenderQueue)
       {
          /* dereference our and the sender's message queue */
          IntDereferenceMessageQueue(MessageQueue);
@@ -1592,6 +1591,9 @@
    /* clean it up */
    MsqCleanupMessageQueue(MessageQueue);
 
+   if (MessageQueue->NewMessagesHandle != NULL)
+      ZwClose(MessageQueue->NewMessagesHandle);
+   MessageQueue->NewMessagesHandle = NULL;
    /* decrease the reference counter, if it hits zero, the queue will be freed 
*/
    IntDereferenceMessageQueue(MessageQueue);
 }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=51275&r1=51274&r2=51275&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Thu Apr  
7 23:57:00 2011
@@ -1531,11 +1531,10 @@
         {
             USER_REFERENCE_ENTRY Ref;
             UserRefObjectCo(pWindow->spwndParent, &Ref);
-            // Should be co_IntSendMessage please retest, Ref to Chg, revision 
51254...
-            co_IntSendMessageNoWait( pWindow->spwndParent->head.h,
-                                     WM_PARENTNOTIFY,
-                                     MAKEWPARAM( msg, pWindow->IDMenu),
-                                     (LPARAM)pWindow->head.h );
+            co_IntSendMessage( pWindow->spwndParent->head.h,
+                               WM_PARENTNOTIFY,
+                               MAKEWPARAM( msg, pWindow->IDMenu),
+                               (LPARAM)pWindow->head.h );
             UserDerefObjectCo(pWindow->spwndParent);
         }
     }


Reply via email to