[ros-diffs] [fireball] 42717: - Get wine/class.c back to using Wine-styled linked list functions/macros for consistency: either all user server code uses NT linked lists or Wine linked lists. This fixes a problem with window's classes list consistency. - Add Win32 process cleanup on its termination: delete the handles table and delete all classes. This fixes a problem of never terminating process, and occasionally fixes "New hardware found" wizard. Leaks--;

fireball at svn.reactos.org fireball at svn.reactos.org
Sat Aug 15 23:53:24 CEST 2009


Author: fireball
Date: Sat Aug 15 23:53:24 2009
New Revision: 42717

URL: http://svn.reactos.org/svn/reactos?rev=42717&view=rev
Log:
- Get wine/class.c back to using Wine-styled linked list functions/macros for consistency: either all user server code uses NT linked lists or Wine linked lists. This fixes a problem with window's classes list consistency.
- Add Win32 process cleanup on its termination: delete the handles table and delete all classes. This fixes a problem of never terminating process, and occasionally fixes "New hardware found" wizard. Leaks--;

Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h
    branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h
    branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/class.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/main.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/region.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/stubs.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/user.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -16,7 +16,7 @@
 {
   PEPROCESS            peProcess;
   W32HEAP_USER_MAPPING HeapMappings;
-  LIST_ENTRY           Classes;         /* window classes owned by the process */
+  struct list          Classes;         /* window classes owned by the process */
   struct handle_table *handles;         /* handle entries */
   struct event        *idle_event;      /* event for input idle */
   struct msg_queue    *queue;           /* main message queue */

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -19,6 +19,9 @@
 
 /* Wine protocol */
 #include <wine/server_protocol.h>
+
+/* Wine list implementation */
+#include <wine/list.h>
 
 /* RosGdi syscalls */
 #include <ntrosgdi.h>

Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/main/init.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -40,6 +40,7 @@
                      BOOLEAN Create)
 {
     PPROCESSINFO Win32Process;
+    struct handle_table *handles;
 
     DPRINT("Enter Win32kProcessCallback\n");
 
@@ -91,13 +92,25 @@
         Win32Process->HeapMappings.UserMapping = UserBase;
         Win32Process->HeapMappings.Count = 1;
 
-        InitializeListHead(&Win32Process->Classes);
+        list_init(&Win32Process->Classes);
         Win32Process->handles = alloc_handle_table(Win32Process, 0);
         connect_process_winstation(Win32Process);
     }
     else
     {
         DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
+
+        UserEnterExclusive();
+
+        /* Delete its handles table */
+        handles = Win32Process->handles;
+        Win32Process->handles = NULL;
+        if (handles) release_object(handles);
+
+        /* Destroy its classes */
+        destroy_process_classes(Win32Process);
+
+        UserLeave();
     }
 
     DPRINT("Leave Win32kProcessCallback\n");

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/atom.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -23,8 +23,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/class.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/class.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/class.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/class.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -23,8 +23,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "user.h"
@@ -32,18 +30,9 @@
 #define NDEBUG
 #include <debug.h>
 
-#undef LIST_FOR_EACH
-/* iterate through the list using a list entry.
- * elem is set to NULL if the list is run thru without breaking out or if list is empty.
- */
-#define LIST_FOR_EACH(elem, list, type, field) \
-    for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \
-         &(elem)->field != (list) || (elem == NULL); \
-         (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field))
-
 struct window_class
 {
-    LIST_ENTRY      entry;           /* entry in process list */
+    struct list     entry;           /* entry in process list */
     PPROCESSINFO    process;         /* process owning the class */
     int             count;           /* reference count */
     int             local;           /* local class? */
@@ -70,36 +59,36 @@
     /* other fields are initialized by caller */
 
     /* local classes have priority so we put them first in the list */
-    if (local) InsertHeadList( &process->Classes, &class->entry );
-    else InsertTailList( &process->Classes, &class->entry );
+    if (local) list_add_head( &process->Classes, &class->entry );
+    else list_add_tail( &process->Classes, &class->entry );
     return class;
 }
 
 static void destroy_class( struct window_class *class )
 {
-    RemoveEntryList( &class->entry );
+    list_remove( &class->entry );
     ObDereferenceObject( class->process->peProcess );
     ExFreePool( class );
 }
 
 void destroy_process_classes( PPROCESSINFO process )
 {
-    PLIST_ENTRY ptr;
-
-    while (( ptr = process->Classes.Flink ))
-    {
-        struct window_class *class = CONTAINING_RECORD( ptr, struct window_class, entry );
+    struct list *ptr;
+
+    while (( ptr = list_head(&process->Classes) ))
+    {
+        struct window_class *class = LIST_ENTRY( ptr, struct window_class, entry );
         destroy_class( class );
     }
 }
 
 static struct window_class *find_class( PPROCESSINFO process, atom_t atom, mod_handle_t instance )
 {
-    struct window_class *class;
-
-    LIST_FOR_EACH( class, &process->Classes, struct window_class, entry)
-    {
-        //struct window_class *class = CONTAINING_RECORD( ptr, struct window_class, entry );
+    struct list *ptr;
+
+    LIST_FOR_EACH( ptr, &process->Classes )
+    {
+        struct window_class *class = LIST_ENTRY( ptr, struct window_class, entry );
         if (class->atom != atom) continue;
         if (!instance || !class->local || class->instance == instance) return class;
     }

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/directory.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -23,8 +23,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -22,8 +22,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -21,8 +21,6 @@
 
 #include <win32k.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "user.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/main.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/main.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/main.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/main.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -10,8 +10,6 @@
 
 #include <win32k.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 
 #define WANT_REQUEST_HANDLERS

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/object.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -21,9 +21,6 @@
 #include <win32k.h>
 
 #include <limits.h>
-
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 
 #define NDEBUG

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -21,9 +21,6 @@
 #include <win32k.h>
 
 #include <limits.h>
-
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/region.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/region.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/region.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/region.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -76,8 +76,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/stubs.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/stubs.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/stubs.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/stubs.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -10,8 +10,6 @@
 
 #include <win32k.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/user.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/user.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/user.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/user.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -22,8 +22,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -22,8 +22,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -10,8 +10,6 @@
 
 #include <win32k.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 
 #define NDEBUG

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c?rev=42717&r1=42716&r2=42717&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] Sat Aug 15 23:53:24 2009
@@ -22,8 +22,6 @@
 
 #include <limits.h>
 
-#undef LIST_FOR_EACH
-#undef LIST_FOR_EACH_SAFE
 #include "object.h"
 #include "request.h"
 #include "handle.h"




More information about the Ros-diffs mailing list