Alexandre Julliard : server: Move handle allocation out of open_object_dir.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 5 08:54:18 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 3764da68deb43bcda87283b58ae1e1287aabc816
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=3764da68deb43bcda87283b58ae1e1287aabc816

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Dec  5 12:52:05 2005 +0100

server: Move handle allocation out of open_object_dir.

---

 server/directory.c |   19 +++++++++++--------
 server/event.c     |    8 +++++++-
 server/mapping.c   |    8 +++++++-
 server/mutex.c     |    8 +++++++-
 server/object.h    |    5 ++---
 server/semaphore.c |    8 +++++++-
 server/symlink.c   |    9 +++++++--
 server/timer.c     |    8 +++++++-
 8 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/server/directory.c b/server/directory.c
index 052de10..c5de986 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -260,11 +260,9 @@ void *create_named_object_dir( struct di
 }
 
 /* open a new handle to an existing object */
-obj_handle_t open_object_dir( struct directory *root, const struct unicode_str *name,
-                              unsigned int attr, const struct object_ops *ops,
-                              unsigned int access )
+void *open_object_dir( struct directory *root, const struct unicode_str *name,
+                       unsigned int attr, const struct object_ops *ops )
 {
-    obj_handle_t handle = 0;
     struct unicode_str name_left;
     struct object *obj;
 
@@ -275,11 +273,11 @@ obj_handle_t open_object_dir( struct dir
         else if (ops && obj->ops != ops)
             set_error( STATUS_OBJECT_TYPE_MISMATCH );
         else
-            handle = alloc_handle( current->process, obj, access, attr & OBJ_INHERIT );
+            return obj;
 
         release_object( obj );
     }
-    return handle;
+    return NULL;
 }
 
 
@@ -367,13 +365,18 @@ DECL_HANDLER(create_directory)
 DECL_HANDLER(open_directory)
 {
     struct unicode_str name;
-    struct directory *root = NULL;
+    struct directory *dir, *root = NULL;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &directory_ops, req->access );
+    if ((dir = open_object_dir( root, &name, req->attributes, &directory_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &dir->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( dir );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/event.c b/server/event.c
index 8443837..7464e18 100644
--- a/server/event.c
+++ b/server/event.c
@@ -172,12 +172,18 @@ DECL_HANDLER(open_event)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct event *event;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &event_ops, req->access );
+    if ((event = open_object_dir( root, &name, req->attributes, &event_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &event->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( event );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/mapping.c b/server/mapping.c
index cf87361..cc81e37 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -402,12 +402,18 @@ DECL_HANDLER(open_mapping)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct mapping *mapping;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &mapping_ops, req->access );
+    if ((mapping = open_object_dir( root, &name, req->attributes, &mapping_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &mapping->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( mapping );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/mutex.c b/server/mutex.c
index 9e3bdc3..18c194e 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -198,12 +198,18 @@ DECL_HANDLER(open_mutex)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct mutex *mutex;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &mutex_ops, req->access );
+    if ((mutex = open_object_dir( root, &name, req->attributes, &mutex_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &mutex->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( mutex );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/object.h b/server/object.h
index d138729..2beb148 100644
--- a/server/object.h
+++ b/server/object.h
@@ -187,9 +187,8 @@ extern struct object *find_object_dir( s
                                        unsigned int attr, struct unicode_str *name_left );
 extern void *create_named_object_dir( struct directory *root, const struct unicode_str *name,
                                       unsigned int attr, const struct object_ops *ops );
-extern obj_handle_t open_object_dir( struct directory *root, const struct unicode_str *name,
-                                     unsigned int attr, const struct object_ops *ops,
-                                     unsigned int access );
+extern void *open_object_dir( struct directory *root, const struct unicode_str *name,
+                              unsigned int attr, const struct object_ops *ops );
 extern void init_directories(void);
 extern void close_directories(void);
 
diff --git a/server/semaphore.c b/server/semaphore.c
index e8d9cbb..2dd6beb 100644
--- a/server/semaphore.c
+++ b/server/semaphore.c
@@ -172,12 +172,18 @@ DECL_HANDLER(open_semaphore)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct semaphore *sem;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &semaphore_ops, req->access );
+    if ((sem = open_object_dir( root, &name, req->attributes, &semaphore_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &sem->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( sem );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/symlink.c b/server/symlink.c
index 7f28cc8..cf805a7 100644
--- a/server/symlink.c
+++ b/server/symlink.c
@@ -168,13 +168,18 @@ DECL_HANDLER(open_symlink)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct symlink *symlink;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes | OBJ_OPENLINK,
-                                     &symlink_ops, req->access );
+    if ((symlink = open_object_dir( root, &name, req->attributes | OBJ_OPENLINK, &symlink_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &symlink->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( symlink );
+    }
 
     if (root) release_object( root );
 }
diff --git a/server/timer.c b/server/timer.c
index 74419e5..436ed7c 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -231,12 +231,18 @@ DECL_HANDLER(open_timer)
 {
     struct unicode_str name;
     struct directory *root = NULL;
+    struct timer *timer;
 
     get_req_unicode_str( &name );
     if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
         return;
 
-    reply->handle = open_object_dir( root, &name, req->attributes, &timer_ops, req->access );
+    if ((timer = open_object_dir( root, &name, req->attributes, &timer_ops )))
+    {
+        reply->handle = alloc_handle( current->process, &timer->obj, req->access,
+                                      req->attributes & OBJ_INHERIT );
+        release_object( timer );
+    }
 
     if (root) release_object( root );
 }




More information about the wine-cvs mailing list