Commit 1561a8a2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

server: Create eventfd file descriptors for process objects.

parent c5c10198
......@@ -295,6 +295,24 @@ struct esync *create_esync( struct object *root, const struct unicode_str *name,
#endif
}
/* Create a file descriptor for an existing handle.
* Caller must close the handle when it's done; it's not linked to an esync
* server object in any way. */
int esync_create_fd( int initval, int flags )
{
#ifdef HAVE_SYS_EVENTFD_H
int fd;
fd = eventfd( initval, flags | EFD_CLOEXEC | EFD_NONBLOCK );
if (fd == -1)
perror( "eventfd" );
return fd;
#else
return -1;
#endif
}
DECL_HANDLER(create_esync)
{
struct esync *esync;
......
......@@ -22,3 +22,4 @@
extern int do_esync(void);
void esync_init(void);
int esync_create_fd( int initval, int flags );
......@@ -63,6 +63,7 @@
#include "request.h"
#include "user.h"
#include "security.h"
#include "esync.h"
/* process object */
......@@ -95,6 +96,7 @@ static struct security_descriptor *process_get_sd( struct object *obj );
static void process_poll_event( struct fd *fd, int event );
static struct list *process_get_kernel_obj_list( struct object *obj );
static void process_destroy( struct object *obj );
static int process_get_esync_fd( struct object *obj, enum esync_type *type );
static void terminate_process( struct process *process, struct thread *skip, int exit_code );
static const struct object_ops process_ops =
......@@ -105,7 +107,7 @@ static const struct object_ops process_ops =
add_queue, /* add_queue */
remove_queue, /* remove_queue */
process_signaled, /* signaled */
NULL, /* get_esync_fd */
process_get_esync_fd, /* get_esync_fd */
no_satisfied, /* satisfied */
no_signal, /* signal */
no_get_fd, /* get_fd */
......@@ -686,6 +688,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla
process->rawinput_mouse = NULL;
process->rawinput_kbd = NULL;
memset( &process->image_info, 0, sizeof(process->image_info) );
process->esync_fd = -1;
list_init( &process->kernel_object );
list_init( &process->thread_list );
list_init( &process->locks );
......@@ -742,6 +745,9 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla
if (!token_assign_label( process->token, &high_label_sid ))
goto error;
if (do_esync())
process->esync_fd = esync_create_fd( 0, 0 );
set_fd_events( process->msg_fd, POLLIN ); /* start listening to events */
return process;
......@@ -789,6 +795,7 @@ static void process_destroy( struct object *obj )
free( process->rawinput_devices );
free( process->dir_cache );
free( process->image );
if (do_esync()) close( process->esync_fd );
}
/* dump a process on stdout for debugging purposes */
......@@ -806,6 +813,13 @@ static int process_signaled( struct object *obj, struct wait_queue_entry *entry
return !process->running_threads;
}
static int process_get_esync_fd( struct object *obj, enum esync_type *type )
{
struct process *process = (struct process *)obj;
*type = ESYNC_MANUAL_SERVER;
return process->esync_fd;
}
static unsigned int process_map_access( struct object *obj, unsigned int access )
{
access = default_map_access( obj, access );
......
......@@ -85,6 +85,7 @@ struct process
const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */
struct list kernel_object; /* list of kernel object pointers */
pe_image_info_t image_info; /* main exe image info */
int esync_fd; /* esync file descriptor (signaled on exit) */
};
/* process functions */
......
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