server: Avoid a crash when trying to wait on a disconnected pipe client.

This commit is contained in:
Alexandre Julliard 2009-06-09 12:11:05 +02:00
parent d88f9e3cd9
commit 7a344c14af
3 changed files with 16 additions and 1 deletions

View File

@ -1710,6 +1710,12 @@ void set_fd_signaled( struct fd *fd, int signaled )
if (signaled) wake_up( fd->user, 0 ); if (signaled) wake_up( fd->user, 0 );
} }
/* set or clear the fd signaled state */
int is_fd_signaled( struct fd *fd )
{
return fd->signaled;
}
/* handler for close_handle that refuses to close fd-associated handles in other processes */ /* handler for close_handle that refuses to close fd-associated handles in other processes */
int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle ) int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{ {

View File

@ -70,6 +70,7 @@ extern void set_fd_events( struct fd *fd, int events );
extern obj_handle_t lock_fd( struct fd *fd, file_pos_t offset, file_pos_t count, int shared, int wait ); extern obj_handle_t lock_fd( struct fd *fd, file_pos_t offset, file_pos_t count, int shared, int wait );
extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count ); extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count );
extern void set_fd_signaled( struct fd *fd, int signaled ); extern void set_fd_signaled( struct fd *fd, int signaled );
extern int is_fd_signaled( struct fd *fd );
extern int default_fd_signaled( struct object *obj, struct thread *thread ); extern int default_fd_signaled( struct object *obj, struct thread *thread );
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access ); extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );

View File

@ -176,6 +176,7 @@ static const struct fd_ops pipe_server_fd_ops =
/* client end functions */ /* client end functions */
static void pipe_client_dump( struct object *obj, int verbose ); static void pipe_client_dump( struct object *obj, int verbose );
static int pipe_client_signaled( struct object *obj, struct thread *thread );
static struct fd *pipe_client_get_fd( struct object *obj ); static struct fd *pipe_client_get_fd( struct object *obj );
static void pipe_client_destroy( struct object *obj ); static void pipe_client_destroy( struct object *obj );
static void pipe_client_flush( struct fd *fd, struct event **event ); static void pipe_client_flush( struct fd *fd, struct event **event );
@ -188,7 +189,7 @@ static const struct object_ops pipe_client_ops =
no_get_type, /* get_type */ no_get_type, /* get_type */
add_queue, /* add_queue */ add_queue, /* add_queue */
remove_queue, /* remove_queue */ remove_queue, /* remove_queue */
default_fd_signaled, /* signaled */ pipe_client_signaled, /* signaled */
no_satisfied, /* satisfied */ no_satisfied, /* satisfied */
no_signal, /* signal */ no_signal, /* signal */
pipe_client_get_fd, /* get_fd */ pipe_client_get_fd, /* get_fd */
@ -289,6 +290,13 @@ static void pipe_client_dump( struct object *obj, int verbose )
fprintf( stderr, "Named pipe client server=%p\n", client->server ); fprintf( stderr, "Named pipe client server=%p\n", client->server );
} }
static int pipe_client_signaled( struct object *obj, struct thread *thread )
{
struct pipe_client *client = (struct pipe_client *) obj;
return client->fd && is_fd_signaled(client->fd);
}
static void named_pipe_destroy( struct object *obj) static void named_pipe_destroy( struct object *obj)
{ {
struct named_pipe *pipe = (struct named_pipe *) obj; struct named_pipe *pipe = (struct named_pipe *) obj;