server: Queue an IRP_MJ_CLOSE request on file destruction.

This commit is contained in:
Alexandre Julliard 2015-07-08 18:05:04 +09:00
parent b1fd5955c9
commit 350ee62ab4
4 changed files with 41 additions and 2 deletions

View File

@ -643,6 +643,12 @@ typedef union
client_ptr_t device;
} create;
struct
{
unsigned int major;
int __pad;
client_ptr_t device;
} close;
struct
{
unsigned int major;
unsigned int key;
@ -6089,6 +6095,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
#define SERVER_PROTOCOL_VERSION 478
#define SERVER_PROTOCOL_VERSION 479
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -170,6 +170,7 @@ struct device_file
static void device_file_dump( struct object *obj, int verbose );
static struct fd *device_file_get_fd( struct object *obj );
static int device_file_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
static void device_file_destroy( struct object *obj );
static enum server_fd_type device_file_get_fd_type( struct fd *fd );
static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_data, int blocking,
@ -196,7 +197,7 @@ static const struct object_ops device_file_ops =
default_set_sd, /* set_sd */
no_lookup_name, /* lookup_name */
no_open_file, /* open_file */
no_close_handle, /* close_handle */
device_file_close_handle, /* close_handle */
device_file_destroy /* destroy */
};
@ -409,6 +410,27 @@ static struct fd *device_file_get_fd( struct object *obj )
return (struct fd *)grab_object( file->fd );
}
static int device_file_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{
struct device_file *file = (struct device_file *)obj;
if (file->device->manager && obj->handle_count == 1) /* last handle */
{
struct irp_call *irp;
irp_params_t params;
params.close.major = IRP_MJ_CLOSE;
params.close.device = file->device->user_ptr;
if ((irp = create_irp( file, &params, NULL, 0, 0 )))
{
add_irp_to_queue( file, irp );
release_object( irp );
}
}
return 1;
}
static void device_file_destroy( struct object *obj )
{
struct device_file *file = (struct device_file *)obj;

View File

@ -659,6 +659,12 @@ typedef union
client_ptr_t device; /* opaque ptr for the device */
} create;
struct
{
unsigned int major; /* IRP_MJ_CLOSE */
int __pad;
client_ptr_t device; /* opaque ptr for the device */
} close;
struct
{
unsigned int major; /* IRP_MJ_READ */
unsigned int key; /* driver key */

View File

@ -322,6 +322,11 @@ static void dump_irp_params( const char *prefix, const irp_params_t *data )
dump_uint64( ",device=", &data->create.device );
fputc( '}', stderr );
break;
case IRP_MJ_CLOSE:
fprintf( stderr, "%s{major=CLOSE", prefix );
dump_uint64( ",device=", &data->close.device );
fputc( '}', stderr );
break;
case IRP_MJ_READ:
fprintf( stderr, "%s{major=READ,key=%08x", prefix, data->read.key );
dump_uint64( ",pos=", &data->read.pos );