From 3764da68deb43bcda87283b58ae1e1287aabc816 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 5 Dec 2005 12:52:05 +0100 Subject: [PATCH] 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 052de1065f..c5de9863ea 100644 --- a/server/directory.c +++ b/server/directory.c @@ -260,11 +260,9 @@ void *create_named_object_dir( struct directory *root, const struct unicode_str } /* 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 directory *root, const struct unicode_str * 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 8443837610..7464e18975 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 cf8736197f..cc81e376d6 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 9e3bdc342e..18c194e0dd 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 d138729679..2beb148f25 100644 --- a/server/object.h +++ b/server/object.h @@ -187,9 +187,8 @@ extern struct object *find_object_dir( struct directory *root, const struct unic 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 e8d9cbbbba..2dd6beb9e7 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 7f28cc802c..cf805a71c2 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 74419e5ad3..436ed7cd3a 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 ); }