Rob Shearman : msi: Rewrite the second loop in ACTION_FinishCustomActions so that it always terminates .

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 5 13:10:23 CST 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Mon Mar  5 12:03:59 2007 +0000

msi: Rewrite the second loop in ACTION_FinishCustomActions so that it always terminates.

Create an array of handles to wait on so that we can wait without
holding a critical section.

---

 dlls/msi/custom.c |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index c6c07cf..fc86691 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -859,6 +859,9 @@ static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
 void ACTION_FinishCustomActions(MSIPACKAGE* package)
 {
     struct list *item;
+    HANDLE *wait_handles;
+    unsigned int handle_count, i;
+    msi_custom_action_info *info, *cursor;
 
     while ((item = list_head( &package->RunningActions )))
     {
@@ -874,27 +877,25 @@ void ACTION_FinishCustomActions(MSIPACKAGE* package)
         msi_free( action );
     }
 
-    while (1)
-    {
-        HANDLE handle;
-        msi_custom_action_info *info;
+    EnterCriticalSection( &msi_custom_action_cs );
 
-        EnterCriticalSection( &msi_custom_action_cs );
-        item = list_head( &msi_pending_custom_actions );
-        info = LIST_ENTRY( item, msi_custom_action_info, entry );
+    handle_count = list_count( &msi_pending_custom_actions );
+    wait_handles = HeapAlloc( GetProcessHeap(), 0, handle_count * sizeof(HANDLE) );
 
-        if (item && info->package == package )
+    handle_count = 0;
+    LIST_FOR_EACH_ENTRY_SAFE( info, cursor, &msi_pending_custom_actions, msi_custom_action_info, entry )
+    {
+        if (info->package == package )
         {
-            handle = info->handle;
+            wait_handles[handle_count++] = info->handle;
             free_custom_action_data( info );
         }
-        else
-            handle = NULL;
-        LeaveCriticalSection( &msi_custom_action_cs );
+    }
 
-        if (!item)
-            break;
+    LeaveCriticalSection( &msi_custom_action_cs );
 
-        msi_dialog_check_messages( handle );
-    }
+    for (i = 0; i < handle_count; i++)
+        msi_dialog_check_messages( wait_handles[i] );
+
+    HeapFree( GetProcessHeap(), 0, wait_handles );
 }




More information about the wine-cvs mailing list