Chris Robinson : quartz: Use a safe APC to kill the PullPin thread when the PullPin is being released .

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 2 06:22:54 CDT 2007


Module: wine
Branch: master
Commit: b1bfae286f24303e0ca254e92c4859d55dce8b23
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b1bfae286f24303e0ca254e92c4859d55dce8b23

Author: Chris Robinson <chris.kcat at gmail.com>
Date:   Sat Mar 31 20:13:08 2007 -0700

quartz: Use a safe APC to kill the PullPin thread when the PullPin is being released.

---

 dlls/quartz/pin.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index 84a2c30..06313e4 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -1121,6 +1121,15 @@ HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const
     return hr;
 }
 
+static void CALLBACK PullPin_SafeThreadStop(ULONG_PTR handle)
+{
+    HANDLE hThread = (HANDLE)handle;
+
+    if (hThread)
+        CloseHandle(hThread);
+    ExitThread(0);
+}
+
 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
 {
     PullPin *This = (PullPin *)iface;
@@ -1155,7 +1164,14 @@ ULONG WINAPI PullPin_Release(IPin * iface)
     if (!refCount)
     {
         if (This->hThread)
-            PullPin_StopProcessing(This);
+        {
+            HRESULT hr;
+
+            if (!QueueUserAPC(PullPin_SafeThreadStop, This->hThread, (ULONG_PTR)This->hThread))
+                ERR("Cannot stop PullPin thread (GetLastError() = %d)!", GetLastError());
+            if (This->pAlloc && FAILED(hr = IMemAllocator_Decommit(This->pAlloc)))
+                ERR("Allocator decommit failed with error %x. Possible memory leak\n", hr);
+        }
         if(This->pAlloc)
             IMemAllocator_Release(This->pAlloc);
         if(This->pReader)




More information about the wine-cvs mailing list