<div><div>Hi,</div><div><span style="line-height: 1.5;">I got it. The CoWaitForMultipleHandles of Microsoft implement is this:</span></div><div>The message loop continue although has received WM_QUIT,</div><div>but just dispatch message who sent to the OleMainThreadWndClass Window.</div><div><br></div><div>I attached a latest patch and a verify function.</div><div>Run the test_CoWaitForMultipleHandlesDispatchMsg, We will only get the</div><div>message who send to cowait_test_class window .  </div><div><br></div><div>It also pass your PeekMessage test at:</div><div>https://github.com/wine-compholio/wine-staging/blob/master/patches/ole32-CoWaitForMultipleHandles/0001-ole32-tests-Add-additional-tests-for-CoWaitForMultip.patch</div><div><br></div><div>Please help me review it again when you are free.</div><div>Thank you.</div><div><br></div></div><div><br></div><div><sign signid="0"><div style="color:#909090;font-family:Arial Narrow;font-size:12px"><br><br><br><br>------------------</div><div style="font-size:14px;font-family:Verdana;color:#000;"><div>Regards.</div>
</div></sign></div><div> </div><div><tincludetail><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "Sebastian Lackner"<sebastian@fds-team.de>;</div><div><b>Date: </b> Sat, Dec 13, 2014 11:32 PM</div><div><b>To: </b> "Changhui Liu"<liuchanghui@linuxdeepin.com>; <wbr></div><div><b>Cc: </b> "wine-devel"<wine-devel@winehq.org>; <wbr></div><div><b>Subject: </b> Re: ole32:fix CoWaitForMultipleHandles cause RPC hang</div></div><div> </div>Hi,<br><br>On 13.12.2014 16:15, Changhui Liu wrote:<br>> Hi Sebastian,<br>> <br>> <br>> I tested your current work-in-progress patch:<br>> https://github.com/wine-compholio/wine-staging/blob/master/patches/ole32-CoWaitForMultipleHandles/0001-ole32-tests-Add-additional-tests-for-CoWaitForMultip.patch<br>> <br>> I have two puzzles about these code:<br>>>       index = 0xdeadbeef;<br>>>       PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);<br>>>       PostQuitMessage(44);<br>>>       thread = CreateThread(NULL, 0, post_message_thread, hWnd, 0, &tid);<br>>>       ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());<br>>>       hr = CoWaitForMultipleHandles(0, 100, 2, handles, &index);<br>>>       ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);<br>>>       ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index);<br>>>       success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);<br>>>       ok(success, "PeekMessageA failed, error %u\n", GetLastError());<br>> <br>> <br>> The first, why use the PeekMessage to check if received a WM_DDE_FIRST message?<br>> Is there an real application do like that way?<br><br>Of course there are multiple ways to test for window messages in the message queue, I just picked PeekMessageA because it doesn't require setting up a Wndproc.<br><br>> <br>> <br>> In fact CoWaitForMultipleHandles has a message loop, the WM_DDE_FIRST message has been<br>> dispatched to the window's WNDPROC. So the PeekMessageA certainly failed. <br><br>No, it doesn't. Feel free to run the tests yourself on a Windows machine, I have tested them with the Wine testbot and all tests pass on 2000/XP/Vista/8/2008/... - which means that Windows does not process all WM_DDE_FIRST messages.<br><br>This is also why I am unsure about how to fix it. When changing the behaviour in order to fix one of the tests which fails in Wine (marked with todo_wine), it breaks other tests which were working well before.<br><br>> <br>> <br>> I think the correct test should be this: <br>> 1, Define a custom WNDPROC function named cowait_test_wnd_proc .<br>> 2, Define a global int variable named g_count_of_wm_dde_first.<br>> 3, Set the value of g_count_of_wm_dde_first to zero before call CoWaitForMultipleHandles.<br>> 4, Increase the value of g_count_of_wm_dde_first by one, once received a WM_DDE_FIRST message in cowait_test_wnd_proc.<br>> 5, Check if the value of g_count_of_wm_dde_first is equal to 2 after CoWaitForMultipleHandles returned. <br>> <br><br>This testing method would also be fine, but you would get 1 instead of 2. My patch doesn't show any test failures on Windows, which means that one of the WM_DDE_FIRST messages is still in the queue.<br><br>> <br>> The second  is why use todo_wine ?<br>>         todo_wine<br>>         ok(!success, "PeekMessageA succeeded\n");<br>> why not just write?<br>>         ok(!success, "PeekMessageA succeeded\n"); <br>> <br><br>The Wine coding guideline does not allow to add new test failures, instead all tests which do not pass yet have to be marked with "todo_wine". This makes easily visible which tests need further work just by looking at the source code, moreover it avoids introducing regressions (breaking tests which were working well before). Take a look at some of the other Wine tests, this is not the only place where its used.<br><br>> <br>> <br>> <br>> Thank you.<br><br>Regards,<br>Sebastian<br></div></tincludetail></div><!--<![endif]-->