Huw Davies : winhttp: Don't wait for the task thread to exit.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 21 13:08:52 CDT 2015


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Jul 21 15:57:13 2015 +0100

winhttp: Don't wait for the task thread to exit.

Instead, have the task thread call the destructor before it exits.
Previously, if the task thread held the final reference, it would call
request_destroy which would then wait for itself to finish.

---

 dlls/winhttp/request.c |  5 +++++
 dlls/winhttp/session.c | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index aa8a6f9..9a79754 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -217,6 +217,11 @@ static DWORD CALLBACK task_proc( LPVOID param )
         }
         case WAIT_OBJECT_0 + 1:
             TRACE("exiting\n");
+            CloseHandle( request->task_cancel );
+            CloseHandle( request->task_wait );
+            request->task_cs.DebugInfo->Spare[0] = 0;
+            DeleteCriticalSection( &request->task_cs );
+            request->hdr.vtbl->destroy( &request->hdr );
             return 0;
 
         default:
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 109ca3a..2fae530 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -561,13 +561,13 @@ static void request_destroy( object_header_t *hdr )
 
     if (request->task_thread)
     {
+        /* Signal to the task proc to quit.  It will call
+           this again when it does. */
+        HANDLE thread = request->task_thread;
+        request->task_thread = 0;
         SetEvent( request->task_cancel );
-        WaitForSingleObject( request->task_thread, INFINITE );
-        CloseHandle( request->task_thread );
-        CloseHandle( request->task_cancel );
-        CloseHandle( request->task_wait );
-        request->task_cs.DebugInfo->Spare[0] = 0;
-        DeleteCriticalSection( &request->task_cs );
+        CloseHandle( thread );
+        return;
     }
     release_object( &request->connect->hdr );
 




More information about the wine-cvs mailing list