Commit 8700c434 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Get rid of the server-side file descriptor cache management.

parent 28418cc9
......@@ -551,7 +551,6 @@ struct close_handle_request
struct close_handle_reply
{
struct reply_header __header;
int fd;
};
......@@ -856,20 +855,6 @@ struct get_handle_fd_reply
#define FD_FLAG_REMOVABLE 0x20
struct set_handle_fd_request
{
struct request_header __header;
obj_handle_t handle;
int fd;
};
struct set_handle_fd_reply
{
struct reply_header __header;
int cur_fd;
};
struct flush_file_request
{
struct request_header __header;
......@@ -2533,7 +2518,6 @@ struct disconnect_named_pipe_request
struct disconnect_named_pipe_reply
{
struct reply_header __header;
int fd;
};
......@@ -3807,7 +3791,6 @@ enum request
REQ_open_file_object,
REQ_alloc_file_handle,
REQ_get_handle_fd,
REQ_set_handle_fd,
REQ_flush_file,
REQ_lock_file,
REQ_unlock_file,
......@@ -4028,7 +4011,6 @@ union generic_request
struct open_file_object_request open_file_object_request;
struct alloc_file_handle_request alloc_file_handle_request;
struct get_handle_fd_request get_handle_fd_request;
struct set_handle_fd_request set_handle_fd_request;
struct flush_file_request flush_file_request;
struct lock_file_request lock_file_request;
struct unlock_file_request unlock_file_request;
......@@ -4247,7 +4229,6 @@ union generic_reply
struct open_file_object_reply open_file_object_reply;
struct alloc_file_handle_reply alloc_file_handle_reply;
struct get_handle_fd_reply get_handle_fd_reply;
struct set_handle_fd_reply set_handle_fd_reply;
struct flush_file_reply flush_file_reply;
struct lock_file_reply lock_file_reply;
struct unlock_file_reply unlock_file_reply;
......@@ -4425,6 +4406,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply;
};
#define SERVER_PROTOCOL_VERSION 257
#define SERVER_PROTOCOL_VERSION 258
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -1279,7 +1279,7 @@ DECL_HANDLER(alloc_console)
release_object( console );
goto the_end;
}
close_handle( renderer, in, NULL );
close_handle( renderer, in );
}
free_console( process );
}
......
......@@ -140,7 +140,7 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
/* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 )))
{
close_handle( debugger, event->data.info.create_process.process, NULL );
close_handle( debugger, event->data.info.create_process.process );
return 0;
}
event->data.info.create_process.thread = handle;
......@@ -150,8 +150,8 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
/* the doc says write access too, but this doesn't seem a good idea */
!(handle = alloc_handle( debugger, exe_module->file, GENERIC_READ, 0 )))
{
close_handle( debugger, event->data.info.create_process.process, NULL );
close_handle( debugger, event->data.info.create_process.thread, NULL );
close_handle( debugger, event->data.info.create_process.process );
close_handle( debugger, event->data.info.create_process.thread );
return 0;
}
event->data.info.create_process.file = handle;
......@@ -287,17 +287,17 @@ static void debug_event_destroy( struct object *obj )
switch(event->data.code)
{
case CREATE_THREAD_DEBUG_EVENT:
close_handle( debugger, event->data.info.create_thread.handle, NULL );
close_handle( debugger, event->data.info.create_thread.handle );
break;
case CREATE_PROCESS_DEBUG_EVENT:
if (event->data.info.create_process.file)
close_handle( debugger, event->data.info.create_process.file, NULL );
close_handle( debugger, event->data.info.create_process.thread, NULL );
close_handle( debugger, event->data.info.create_process.process, NULL );
close_handle( debugger, event->data.info.create_process.file );
close_handle( debugger, event->data.info.create_process.thread );
close_handle( debugger, event->data.info.create_process.process );
break;
case LOAD_DLL_DEBUG_EVENT:
if (event->data.info.load_dll.handle)
close_handle( debugger, event->data.info.load_dll.handle, NULL );
close_handle( debugger, event->data.info.load_dll.handle );
break;
}
}
......@@ -661,7 +661,7 @@ DECL_HANDLER(get_exception_status)
if ((event = (struct debug_event *)get_handle_obj( current->process, req->handle,
0, &debug_event_ops )))
{
close_handle( current->process, req->handle, NULL );
close_handle( current->process, req->handle );
if (event->state == EVENT_CONTINUED)
{
if (current->context == &event->context)
......
......@@ -1957,23 +1957,6 @@ DECL_HANDLER(get_handle_fd)
}
}
/* set the cached file descriptor of a handle */
DECL_HANDLER(set_handle_fd)
{
struct fd *fd;
reply->cur_fd = -1;
if ((fd = get_handle_fd_obj( current->process, req->handle, 0 )))
{
struct device *device = fd->inode ? fd->inode->device : NULL;
/* only cache the fd on non-removable devices */
if (!device || !device->removable)
reply->cur_fd = set_handle_unix_fd( current->process, req->handle, req->fd );
release_object( fd );
}
}
/* get ready to unmount a Unix device */
DECL_HANDLER(unmount_device)
{
......
......@@ -42,7 +42,6 @@ struct handle_entry
{
struct object *ptr; /* object */
unsigned int access; /* access rights */
int fd; /* file descriptor (in client process) */
};
struct handle_table
......@@ -218,7 +217,6 @@ static obj_handle_t alloc_entry( struct handle_table *table, void *obj, unsigned
table->free = i + 1;
entry->ptr = grab_object( obj );
entry->access = access;
entry->fd = -1;
return index_to_handle(i);
}
......@@ -319,7 +317,6 @@ struct handle_table *copy_handle_table( struct process *process, struct process
for (i = 0; i <= table->last; i++, ptr++)
{
if (!ptr->ptr) continue;
ptr->fd = -1;
if (ptr->access & RESERVED_INHERIT) grab_object( ptr->ptr );
else ptr->ptr = NULL; /* don't inherit this entry */
}
......@@ -331,7 +328,7 @@ 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, int *fd )
int close_handle( struct process *process, obj_handle_t handle )
{
struct handle_table *table;
struct handle_entry *entry;
......@@ -350,9 +347,6 @@ int close_handle( struct process *process, obj_handle_t handle, int *fd )
return 0;
}
entry->ptr = NULL;
if (fd) *fd = entry->fd;
else if (entry->fd != -1) return 1; /* silently ignore close attempt if we cannot close the fd */
entry->fd = -1;
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 );
......@@ -410,46 +404,6 @@ unsigned int get_handle_access( struct process *process, obj_handle_t handle )
return entry->access;
}
/* retrieve the cached fd for a given handle */
int get_handle_unix_fd( struct process *process, obj_handle_t handle, unsigned int access )
{
struct handle_entry *entry;
if (!(entry = get_handle( process, handle ))) return -1;
if ((entry->access & access) != access)
{
set_error( STATUS_ACCESS_DENIED );
return -1;
}
return entry->fd;
}
/* set the cached fd for a handle if not set already, and return the current value */
int set_handle_unix_fd( struct process *process, obj_handle_t handle, int fd )
{
struct handle_entry *entry;
if (handle_is_global( handle )) return -1; /* no fd cache for global handles */
if (!(entry = get_handle( process, handle ))) return -1;
/* if no current fd set it, otherwise return current fd */
if (entry->fd == -1) entry->fd = fd;
return entry->fd;
}
/* remove the cached fd and return it */
int flush_cached_fd( struct process *process, obj_handle_t handle )
{
struct handle_entry *entry = get_handle( process, handle );
int fd = -1;
if (entry)
{
fd = entry->fd;
entry->fd = -1;
}
return fd;
}
/* find the first inherited handle of the given type */
/* this is needed for window stations and desktops (don't ask...) */
obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops )
......@@ -547,7 +501,7 @@ unsigned int get_handle_table_count( struct process *process )
/* close a handle */
DECL_HANDLER(close_handle)
{
close_handle( current->process, req->handle, &reply->fd );
close_handle( current->process, req->handle );
}
/* set a handle information */
......@@ -579,7 +533,7 @@ DECL_HANDLER(dup_handle)
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, NULL );
reply->closed = close_handle( src, req->src_handle );
set_error( err );
}
release_object( src );
......
......@@ -36,12 +36,10 @@ struct unicode_str;
/* that the thing pointed to starts with a struct object... */
extern obj_handle_t alloc_handle( struct process *process, void *obj,
unsigned int access, unsigned int attr );
extern int close_handle( struct process *process, obj_handle_t handle, int *fd );
extern 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 );
extern int get_handle_unix_fd( struct process *process, obj_handle_t handle, unsigned int access );
extern int set_handle_unix_fd( struct process *process, obj_handle_t handle, int fd );
extern obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, struct process *dst,
unsigned int access, unsigned int attr, unsigned int options );
extern obj_handle_t open_object( const struct namespace *namespace, const struct unicode_str *name,
......@@ -50,6 +48,5 @@ extern obj_handle_t find_inherited_handle( struct process *process, const struct
extern struct handle_table *alloc_handle_table( struct process *process, int count );
extern struct handle_table *copy_handle_table( struct process *process, struct process *parent );
extern unsigned int get_handle_table_count( struct process *process);
extern int flush_cached_fd( struct process *process, obj_handle_t handle );
#endif /* __WINE_SERVER_HANDLE_H */
......@@ -884,7 +884,6 @@ DECL_HANDLER(disconnect_named_pipe)
{
struct pipe_server *server;
reply->fd = -1;
server = get_pipe_server_obj( current->process, req->handle, 0 );
if (!server)
return;
......@@ -901,7 +900,6 @@ DECL_HANDLER(disconnect_named_pipe)
around - client loses all waiting data */
server->state = ps_disconnected_server;
do_disconnect( server );
reply->fd = flush_cached_fd( current->process, req->handle );
break;
case ps_wait_disconnect:
......@@ -909,7 +907,6 @@ DECL_HANDLER(disconnect_named_pipe)
assert( server->fd );
do_disconnect( server );
server->state = ps_wait_connect;
reply->fd = flush_cached_fd( current->process, req->handle );
break;
case ps_idle_server:
......
......@@ -460,8 +460,6 @@ enum apc_type { APC_NONE, APC_USER, APC_TIMER, APC_ASYNC_IO };
/* Close a handle for the current process */
@REQ(close_handle)
obj_handle_t handle; /* handle to close */
@REPLY
int fd; /* associated fd to close */
@END
......@@ -673,15 +671,6 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
* only handle available data (don't wait) */
#define FD_FLAG_REMOVABLE 0x20 /* is it on a removable device? */
/* Set the cached file descriptor of a handle */
@REQ(set_handle_fd)
obj_handle_t handle; /* handle we are interested in */
int fd; /* file descriptor */
@REPLY
int cur_fd; /* current file descriptor */
@END
/* Flush a file buffers */
@REQ(flush_file)
obj_handle_t handle; /* handle to the file */
......@@ -1805,8 +1794,6 @@ enum message_type
/* Disconnect a named pipe */
@REQ(disconnect_named_pipe)
obj_handle_t handle;
@REPLY
int fd; /* associated fd to close */
@END
......
......@@ -148,7 +148,6 @@ DECL_HANDLER(create_file);
DECL_HANDLER(open_file_object);
DECL_HANDLER(alloc_file_handle);
DECL_HANDLER(get_handle_fd);
DECL_HANDLER(set_handle_fd);
DECL_HANDLER(flush_file);
DECL_HANDLER(lock_file);
DECL_HANDLER(unlock_file);
......@@ -368,7 +367,6 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_open_file_object,
(req_handler)req_alloc_file_handle,
(req_handler)req_get_handle_fd,
(req_handler)req_set_handle_fd,
(req_handler)req_flush_file,
(req_handler)req_lock_file,
(req_handler)req_unlock_file,
......
......@@ -871,11 +871,6 @@ static void dump_close_handle_request( const struct close_handle_request *req )
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_close_handle_reply( const struct close_handle_reply *req )
{
fprintf( stderr, " fd=%d", req->fd );
}
static void dump_set_handle_info_request( const struct set_handle_info_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
......@@ -1112,17 +1107,6 @@ static void dump_get_handle_fd_reply( const struct get_handle_fd_reply *req )
fprintf( stderr, " flags=%d", req->flags );
}
static void dump_set_handle_fd_request( const struct set_handle_fd_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " fd=%d", req->fd );
}
static void dump_set_handle_fd_reply( const struct set_handle_fd_reply *req )
{
fprintf( stderr, " cur_fd=%d", req->cur_fd );
}
static void dump_flush_file_request( const struct flush_file_request *req )
{
fprintf( stderr, " handle=%p", req->handle );
......@@ -2293,11 +2277,6 @@ static void dump_disconnect_named_pipe_request( const struct disconnect_named_pi
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_disconnect_named_pipe_reply( const struct disconnect_named_pipe_reply *req )
{
fprintf( stderr, " fd=%d", req->fd );
}
static void dump_get_named_pipe_info_request( const struct get_named_pipe_info_request *req )
{
fprintf( stderr, " handle=%p", req->handle );
......@@ -3322,7 +3301,6 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_open_file_object_request,
(dump_func)dump_alloc_file_handle_request,
(dump_func)dump_get_handle_fd_request,
(dump_func)dump_set_handle_fd_request,
(dump_func)dump_flush_file_request,
(dump_func)dump_lock_file_request,
(dump_func)dump_unlock_file_request,
......@@ -3520,7 +3498,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)0,
(dump_func)0,
(dump_func)dump_get_apc_reply,
(dump_func)dump_close_handle_reply,
(dump_func)0,
(dump_func)dump_set_handle_info_reply,
(dump_func)dump_dup_handle_reply,
(dump_func)dump_open_process_reply,
......@@ -3539,7 +3517,6 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_open_file_object_reply,
(dump_func)dump_alloc_file_handle_reply,
(dump_func)dump_get_handle_fd_reply,
(dump_func)dump_set_handle_fd_reply,
(dump_func)dump_flush_file_reply,
(dump_func)dump_lock_file_reply,
(dump_func)0,
......@@ -3639,7 +3616,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_open_named_pipe_reply,
(dump_func)0,
(dump_func)0,
(dump_func)dump_disconnect_named_pipe_reply,
(dump_func)0,
(dump_func)dump_get_named_pipe_info_reply,
(dump_func)dump_create_window_reply,
(dump_func)0,
......@@ -3756,7 +3733,6 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"open_file_object",
"alloc_file_handle",
"get_handle_fd",
"set_handle_fd",
"flush_file",
"lock_file",
"unlock_file",
......
......@@ -353,7 +353,7 @@ void close_thread_desktop( struct thread *thread )
obj_handle_t handle = thread->desktop;
thread->desktop = 0;
if (handle) close_handle( thread->process, handle, NULL );
if (handle) close_handle( thread->process, handle );
clear_error(); /* ignore errors */
}
......@@ -395,7 +395,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, NULL )) set_error( STATUS_ACCESS_DENIED );
if (!close_handle( current->process, req->handle )) set_error( STATUS_ACCESS_DENIED );
release_object( winstation );
}
}
......@@ -474,7 +474,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, NULL )) set_error( STATUS_DEVICE_BUSY );
if (!close_handle( current->process, req->handle )) set_error( STATUS_DEVICE_BUSY );
release_object( desktop );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment