From 3b3c8619c852513f57ce7388557c8451691fbe00 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 23 Sep 2020 15:34:10 +0200 Subject: [PATCH] server: Keep permanent objects on the standard object list. Signed-off-by: Alexandre Julliard --- server/object.c | 47 ++++++----------------------------------------- server/object.h | 5 +++-- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/server/object.c b/server/object.c index 27c1aa58ad8..77dec733a54 100644 --- a/server/object.c +++ b/server/object.c @@ -52,22 +52,13 @@ struct namespace #ifdef DEBUG_OBJECTS static struct list object_list = LIST_INIT(object_list); -static struct list static_object_list = LIST_INIT(static_object_list); void dump_objects(void) { - struct list *p; + struct object *ptr; - LIST_FOR_EACH( p, &static_object_list ) + LIST_FOR_EACH_ENTRY( ptr, &object_list, struct object, obj_list ) { - struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); - fprintf( stderr, "%p:%d: ", ptr, ptr->refcount ); - dump_object_name( ptr ); - ptr->ops->dump( ptr, 1 ); - } - LIST_FOR_EACH( p, &object_list ) - { - struct object *ptr = LIST_ENTRY( p, struct object, obj_list ); fprintf( stderr, "%p:%d: ", ptr, ptr->refcount ); dump_object_name( ptr ); ptr->ops->dump( ptr, 1 ); @@ -76,17 +67,11 @@ void dump_objects(void) void close_objects(void) { - struct list *ptr; + struct object *obj, *obj2; - /* release the static objects */ - while ((ptr = list_head( &static_object_list ))) - { - struct object *obj = LIST_ENTRY( ptr, struct object, obj_list ); - /* move it back to the standard list before freeing */ - list_remove( &obj->obj_list ); - list_add_head( &object_list, &obj->obj_list ); - release_object( obj ); - } + /* release the permanent objects */ + LIST_FOR_EACH_ENTRY_SAFE( obj, obj2, &object_list, struct object, obj_list ) + if (obj->is_permanent) release_object( obj ); dump_objects(); /* dump any remaining objects */ } @@ -406,26 +391,6 @@ void unlink_named_object( struct object *obj ) free( name_ptr ); } -/* mark an object as being permanent, i.e. only released at shutdown */ -void make_object_permanent( struct object *obj ) -{ - obj->is_permanent = 1; -#ifdef DEBUG_OBJECTS - list_remove( &obj->obj_list ); - list_add_head( &static_object_list, &obj->obj_list ); -#endif -} - -/* mark an object as no longer permanent */ -void make_object_temporary( struct object *obj ) -{ - obj->is_permanent = 0; -#ifdef DEBUG_OBJECTS - list_remove( &obj->obj_list ); - list_add_head( &object_list, &obj->obj_list ); -#endif -} - /* grab an object (i.e. increment its refcount) and return the object */ struct object *grab_object( void *ptr ) { diff --git a/server/object.h b/server/object.h index f8a3a971d6b..394a4aac463 100644 --- a/server/object.h +++ b/server/object.h @@ -145,8 +145,6 @@ extern void *create_named_object( struct object *parent, const struct object_ops extern void *open_named_object( struct object *parent, const struct object_ops *ops, const struct unicode_str *name, unsigned int attributes ); extern void unlink_named_object( struct object *obj ); -extern void make_object_permanent( struct object *obj ); -extern void make_object_temporary( struct object *obj ); extern struct namespace *create_namespace( unsigned int hash_size ); extern void free_kernel_objects( struct object *obj ); /* grab/release_object can take any pointer, but you better make sure */ @@ -180,6 +178,9 @@ extern void dump_objects(void); extern void close_objects(void); #endif +static inline void make_object_permanent( struct object *obj ) { obj->is_permanent = 1; } +static inline void make_object_temporary( struct object *obj ) { obj->is_permanent = 0; } + /* event functions */ struct event;