Hans Leidekker : winhttp: Don't close child handles on release.

Alexandre Julliard julliard at winehq.org
Tue Jun 23 15:52:51 CDT 2020


Module: wine
Branch: master
Commit: 933665147704ab07e702bf4366f1a9a8aa6a62d7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=933665147704ab07e702bf4366f1a9a8aa6a62d7

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Jun 22 21:39:20 2020 +0200

winhttp: Don't close child handles on release.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winhttp/handle.c          | 14 ++------------
 dlls/winhttp/request.c         |  2 --
 dlls/winhttp/session.c         |  5 -----
 dlls/winhttp/tests/winhttp.c   | 27 +++++++++++++++++++++++----
 dlls/winhttp/winhttp_private.h |  1 -
 5 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/dlls/winhttp/handle.c b/dlls/winhttp/handle.c
index 9c77d5166a..08052b91ee 100644
--- a/dlls/winhttp/handle.c
+++ b/dlls/winhttp/handle.c
@@ -79,7 +79,6 @@ void release_object( struct object_header *hdr )
         send_callback( hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, &hdr->handle, sizeof(HINTERNET) );
 
         TRACE("destroying object %p\n", hdr);
-        if (hdr->type != WINHTTP_HANDLE_TYPE_SESSION) list_remove( &hdr->entry );
         hdr->vtbl->destroy( hdr );
     }
 }
@@ -89,7 +88,6 @@ HINTERNET alloc_handle( struct object_header *hdr )
     struct object_header **p;
     ULONG_PTR handle, num;
 
-    list_init( &hdr->children );
     hdr->handle = NULL;
 
     EnterCriticalSection( &handle_cs );
@@ -123,7 +121,7 @@ BOOL free_handle( HINTERNET hinternet )
 {
     BOOL ret = FALSE;
     ULONG_PTR handle = (ULONG_PTR)hinternet;
-    struct object_header *hdr = NULL, *child, *next;
+    struct object_header *hdr = NULL;
 
     EnterCriticalSection( &handle_cs );
 
@@ -141,15 +139,7 @@ BOOL free_handle( HINTERNET hinternet )
 
     LeaveCriticalSection( &handle_cs );
 
-    if (hdr)
-    {
-        LIST_FOR_EACH_ENTRY_SAFE( child, next, &hdr->children, struct object_header, entry )
-        {
-            TRACE("freeing child handle %p for parent handle 0x%lx\n", child->handle, handle + 1);
-            free_handle( child->handle );
-        }
-        release_object( hdr );
-    }
+    if (hdr) release_object( hdr );
 
     EnterCriticalSection( &handle_cs );
     if (next_handle > handle && !handles[handle]) next_handle = handle;
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 0511dd44ee..08e9d7584e 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3102,11 +3102,9 @@ HINTERNET WINAPI WinHttpWebSocketCompleteUpgrade( HINTERNET hrequest, DWORD_PTR
     socket->hdr.vtbl = &socket_vtbl;
     socket->hdr.refs = 1;
     socket->hdr.context = context;
-    list_init( &socket->hdr.children );
 
     addref_object( &request->hdr );
     socket->request = request;
-    list_add_head( &request->hdr.children, &socket->hdr.entry );
 
     if ((hsocket = alloc_handle( &socket->hdr ))) socket->hdr.handle = hsocket;
 
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 87974ffbd8..13d228d851 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -246,7 +246,6 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
     session->hdr.flags = flags;
     session->hdr.refs = 1;
     session->hdr.redirect_policy = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
-    list_init( &session->hdr.children );
     session->resolve_timeout = DEFAULT_RESOLVE_TIMEOUT;
     session->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
     session->send_timeout = DEFAULT_SEND_TIMEOUT;
@@ -552,11 +551,9 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, LPCWSTR server, INTERNET_PO
     connect->hdr.notify_mask = session->hdr.notify_mask;
     connect->hdr.context = session->hdr.context;
     connect->hdr.redirect_policy = session->hdr.redirect_policy;
-    list_init( &connect->hdr.children );
 
     addref_object( &session->hdr );
     connect->session = session;
-    list_add_head( &session->hdr.children, &connect->hdr.entry );
 
     if (!(connect->hostname = strdupW( server ))) goto end;
     connect->hostport = port;
@@ -1121,12 +1118,10 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
     request->hdr.notify_mask = connect->hdr.notify_mask;
     request->hdr.context = connect->hdr.context;
     request->hdr.redirect_policy = connect->hdr.redirect_policy;
-    list_init( &request->hdr.children );
     list_init( &request->task_queue );
 
     addref_object( &connect->hdr );
     request->connect = connect;
-    list_add_head( &connect->hdr.children, &request->hdr.entry );
 
     request->resolve_timeout = connect->session->resolve_timeout;
     request->connect_timeout = connect->session->connect_timeout;
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 8083c4825b..be02bbe250 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -3099,6 +3099,7 @@ static void test_websocket(int port)
 {
     HINTERNET session, connection, request, socket;
     DWORD size, len, count, status, index, error;
+    DWORD_PTR ctx;
     WCHAR header[32];
     char buf[128];
     BOOL ret;
@@ -3244,10 +3245,28 @@ static void test_websocket(int port)
 
     /* Send/Receive on websock */
 
-    WinHttpCloseHandle(request);
-    WinHttpCloseHandle(socket);
-    WinHttpCloseHandle(connection);
-    WinHttpCloseHandle(session);
+    ret = WinHttpCloseHandle(connection);
+    ok(ret, "got %u\n", GetLastError());
+
+    /* request handle is still valid */
+    size = sizeof(ctx);
+    ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
+    ok(ret, "got %u\n", GetLastError());
+
+    ret = WinHttpCloseHandle(socket);
+    ok(ret, "got %u\n", GetLastError());
+
+    ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
+    ok(ret, "got %u\n", GetLastError());
+
+    ret = WinHttpCloseHandle(session);
+    ok(ret, "got %u\n", GetLastError());
+
+    ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
+    ok(ret, "got %u\n", GetLastError());
+
+    ret = WinHttpCloseHandle(request);
+    ok(ret, "got %u\n", GetLastError());
 }
 
 static void test_not_modified(int port)
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index af695f86c3..9b07b64b09 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -51,7 +51,6 @@ struct object_header
     WINHTTP_STATUS_CALLBACK callback;
     DWORD notify_mask;
     struct list entry;
-    struct list children;
 };
 
 struct hostdata




More information about the wine-cvs mailing list