server: Add handle count and flags to object and add handling of permanent objects [dir_object #5]

Vitaliy Margolen wine-patch at kievinfo.com
Wed Nov 2 13:07:23 CST 2005



Vitaliy Margolen

changelog:
  server
  - Add handle count and flags to object
  - Add handling of permanent objects [dir_object #5]
-------------- next part --------------
diff -up -x '*.o' wine-rtest/server/handle.c wine-dbg/server/handle.c
--- wine-rtest/server/handle.c	2005-11-02 11:31:07.000000000 -0700
+++ wine-dbg/server/handle.c	2005-10-29 09:05:56.000000000 -0600
@@ -216,6 +216,7 @@ static obj_handle_t alloc_entry( struct 
     entry->ptr    = grab_object( obj );
     entry->access = access;
     entry->fd     = -1;
+    ((struct object*)obj)->handlecount++;
     return index_to_handle(i);
 }
 
@@ -350,6 +351,7 @@ int close_handle( struct process *proces
     if (entry < table->entries + table->free) table->free = entry - table->entries;
     if (entry == table->entries + table->last) shrink_handle_table( table );
     release_object( obj );
+    obj->handlecount--;
     return 1;
 }
 
diff -up -x '*.o' wine-rtest/server/object.c wine-dbg/server/object.c
--- wine-rtest/server/object.c	2005-11-02 11:36:59.000000000 -0700
+++ wine-dbg/server/object.c	2005-11-02 11:59:48.000000000 -0700
@@ -139,6 +139,8 @@ void *alloc_object( const struct object_
     {
         obj->type     = OB_TYPE_NONE;
         obj->refcount = 1;
+        obj->handlecount = 0;
+        obj->flags    = 0;
         obj->ops      = ops;
         obj->name     = NULL;
         list_init( &obj->wait_queue );
@@ -156,7 +158,15 @@ void *create_named_object( struct namesp
     struct object *obj;
     struct object_name *name_ptr;
 
-    if (!name || !len) return alloc_object( ops );
+    if (!name || !len)
+    {
+        if((obj = alloc_object( ops )))
+        {
+            obj->flags = attributes & OBJ_VALID_ATTRIBUTES;
+            if ( obj->flags & OBJ_PERMANENT ) grab_object( obj );
+        }
+        return obj;
+    }
 
     if ((obj = find_object( namespace, name, len, attributes )))
     {
@@ -172,6 +182,8 @@ void *create_named_object( struct namesp
     if ((obj = alloc_object( ops )))
     {
         set_object_name( namespace, obj, name_ptr );
+        obj->flags = attributes & OBJ_VALID_ATTRIBUTES;
+        if ( obj->flags & OBJ_PERMANENT ) grab_object( obj );
         clear_error();
     }
     else free( name_ptr );
@@ -263,6 +275,16 @@ struct namespace *create_namespace( unsi
     return namespace;
 }
 
+/* if object is permanent make it temporary */
+void make_temporary_obj( struct object *obj )
+{
+    if (obj && (obj->flags & OBJ_PERMANENT) )
+    {
+        obj->flags &= ~OBJ_PERMANENT;
+        release_object( obj );
+    }
+}
+
 /* functions for unimplemented/default object operations */
 
 int no_add_queue( struct object *obj, struct wait_queue_entry *entry )
diff -up -x '*.o' wine-rtest/server/object.h wine-dbg/server/object.h
--- wine-rtest/server/object.h	2005-11-02 11:36:59.000000000 -0700
+++ wine-dbg/server/object.h	2005-11-02 10:49:17.000000000 -0700
@@ -110,6 +114,8 @@ struct object
 {
     unsigned short            type;        /* object type */
     unsigned int              refcount;    /* reference count */
+    unsigned int              handlecount; /* handle count */
+    unsigned int              flags;       /* object flags */
     const struct object_ops  *ops;
     struct list               wait_queue;
     struct object_name       *name;
@@ -139,6 +145,7 @@ extern struct namespace *create_namespac
 /* that the thing pointed to starts with a struct object... */
 extern struct object *grab_object( void *obj );
 extern void release_object( void *obj );
+extern void make_temporary_obj( struct object *obj );
 extern struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len,
                                    unsigned int attributes );
 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );


More information about the wine-patches mailing list