server: Don't set last error in close_handle(), return the error code instead.

This commit is contained in:
Alexandre Julliard 2009-12-01 13:59:41 +01:00
parent 1a6c472115
commit 60efdd55ea
3 changed files with 11 additions and 29 deletions

View File

@ -347,35 +347,22 @@ struct handle_table *copy_handle_table( struct process *process, struct process
}
/* close a handle and decrement the refcount of the associated object */
/* return 1 if OK, 0 on error */
int close_handle( struct process *process, obj_handle_t handle )
unsigned int close_handle( struct process *process, obj_handle_t handle )
{
struct handle_table *table;
struct handle_entry *entry;
struct object *obj;
if (!(entry = get_handle( process, handle )))
{
set_error( STATUS_INVALID_HANDLE );
return 0;
}
if (entry->access & RESERVED_CLOSE_PROTECT)
{
set_error( STATUS_HANDLE_NOT_CLOSABLE );
return 0;
}
if (!(entry = get_handle( process, handle ))) return STATUS_INVALID_HANDLE;
if (entry->access & RESERVED_CLOSE_PROTECT) return STATUS_HANDLE_NOT_CLOSABLE;
obj = entry->ptr;
if (!obj->ops->close_handle( obj, process, handle ))
{
set_error( STATUS_HANDLE_NOT_CLOSABLE );
return 0;
}
if (!obj->ops->close_handle( obj, process, handle )) return STATUS_HANDLE_NOT_CLOSABLE;
entry->ptr = NULL;
table = handle_is_global(handle) ? global_table : process->handles;
if (entry < table->entries + table->free) table->free = entry - table->entries;
if (entry == table->entries + table->last) shrink_handle_table( table );
release_object( obj );
return 1;
return STATUS_SUCCESS;
}
/* retrieve the object corresponding to one of the magic pseudo-handles */
@ -567,7 +554,8 @@ unsigned int get_handle_table_count( struct process *process )
/* close a handle */
DECL_HANDLER(close_handle)
{
close_handle( current->process, req->handle );
unsigned int err = close_handle( current->process, req->handle );
set_error( err );
}
/* set a handle information */
@ -596,12 +584,7 @@ DECL_HANDLER(dup_handle)
release_object( dst );
}
/* close the handle no matter what happened */
if (req->options & DUP_HANDLE_CLOSE_SOURCE)
{
unsigned int err = get_error(); /* don't overwrite error from the above calls */
reply->closed = close_handle( src, req->src_handle );
set_error( err );
}
if (req->options & DUP_HANDLE_CLOSE_SOURCE) reply->closed = !close_handle( src, req->src_handle );
reply->self = (src == current->process);
release_object( src );
}

View File

@ -38,7 +38,7 @@ extern obj_handle_t alloc_handle( struct process *process, void *obj,
unsigned int access, unsigned int attr );
extern obj_handle_t alloc_handle_no_access_check( struct process *process, void *ptr,
unsigned int access, unsigned int attr );
extern int close_handle( struct process *process, obj_handle_t handle );
extern unsigned int close_handle( struct process *process, obj_handle_t handle );
extern struct object *get_handle_obj( struct process *process, obj_handle_t handle,
unsigned int access, const struct object_ops *ops );
extern unsigned int get_handle_access( struct process *process, obj_handle_t handle );

View File

@ -403,7 +403,6 @@ void close_thread_desktop( struct thread *thread )
thread->desktop = 0;
if (handle) close_handle( thread->process, handle );
clear_error(); /* ignore errors */
}
/* set the reply data from the object name */
@ -458,7 +457,7 @@ DECL_HANDLER(close_winstation)
if ((winstation = (struct winstation *)get_handle_obj( current->process, req->handle,
0, &winstation_ops )))
{
if (!close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
if (close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
release_object( winstation );
}
}
@ -544,7 +543,7 @@ DECL_HANDLER(close_desktop)
if ((desktop = (struct desktop *)get_handle_obj( current->process, req->handle,
0, &desktop_ops )))
{
if (!close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
if (close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
release_object( desktop );
}
}