Commit c5c10198 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

server: Add a request to get the eventfd file descriptor associated with a waitable handle.

parent 790031ac
......@@ -5508,6 +5508,19 @@ struct create_esync_reply
};
struct get_esync_fd_request
{
struct request_header __header;
obj_handle_t handle;
};
struct get_esync_fd_reply
{
struct reply_header __header;
int type;
unsigned int shm_idx;
};
enum request
{
REQ_new_process,
......@@ -5788,6 +5801,7 @@ enum request
REQ_resume_process,
REQ_get_next_thread,
REQ_create_esync,
REQ_get_esync_fd,
REQ_NB_REQUESTS
};
......@@ -6073,6 +6087,7 @@ union generic_request
struct resume_process_request resume_process_request;
struct get_next_thread_request get_next_thread_request;
struct create_esync_request create_esync_request;
struct get_esync_fd_request get_esync_fd_request;
};
union generic_reply
{
......@@ -6356,11 +6371,12 @@ union generic_reply
struct resume_process_reply resume_process_reply;
struct get_next_thread_reply get_next_thread_reply;
struct create_esync_reply create_esync_reply;
struct get_esync_fd_reply get_esync_fd_reply;
};
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 758
#define SERVER_PROTOCOL_VERSION 759
/* ### protocol_version end ### */
......
......@@ -333,3 +333,40 @@ DECL_HANDLER(create_esync)
if (root) release_object( root );
}
/* Retrieve a file descriptor for an esync object which will be signaled by the
* server. The client should only read from (i.e. wait on) this object. */
DECL_HANDLER(get_esync_fd)
{
struct object *obj;
enum esync_type type;
int fd;
if (!(obj = get_handle_obj( current->process, req->handle, SYNCHRONIZE, NULL )))
return;
if (obj->ops->get_esync_fd)
{
fd = obj->ops->get_esync_fd( obj, &type );
reply->type = type;
if (obj->ops == &esync_ops)
{
struct esync *esync = (struct esync *)obj;
reply->shm_idx = esync->shm_idx;
}
else
reply->shm_idx = 0;
send_client_fd( current->process, fd, req->handle );
}
else
{
if (debug_level)
{
fprintf( stderr, "%04x: esync: can't wait on object: ", current->id );
obj->ops->dump( obj, 0 );
}
set_error( STATUS_NOT_IMPLEMENTED );
}
release_object( obj );
}
......@@ -3789,3 +3789,11 @@ enum esync_type
int type; /* actual type (may be different for events) */
unsigned int shm_idx;
@END
/* Retrieve the esync fd for an object. */
@REQ(get_esync_fd)
obj_handle_t handle; /* handle to the object */
@REPLY
int type;
unsigned int shm_idx;
@END
......@@ -397,6 +397,7 @@ DECL_HANDLER(suspend_process);
DECL_HANDLER(resume_process);
DECL_HANDLER(get_next_thread);
DECL_HANDLER(create_esync);
DECL_HANDLER(get_esync_fd);
#ifdef WANT_REQUEST_HANDLERS
......@@ -681,6 +682,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_resume_process,
(req_handler)req_get_next_thread,
(req_handler)req_create_esync,
(req_handler)req_get_esync_fd,
};
C_ASSERT( sizeof(abstime_t) == 8 );
......@@ -2279,6 +2281,11 @@ C_ASSERT( FIELD_OFFSET(struct create_esync_reply, handle) == 8 );
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, type) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, shm_idx) == 16 );
C_ASSERT( sizeof(struct create_esync_reply) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_esync_fd_request, handle) == 12 );
C_ASSERT( sizeof(struct get_esync_fd_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_esync_fd_reply, type) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_esync_fd_reply, shm_idx) == 12 );
C_ASSERT( sizeof(struct get_esync_fd_reply) == 16 );
#endif /* WANT_REQUEST_HANDLERS */
......
......@@ -4516,6 +4516,17 @@ static void dump_create_esync_reply( const struct create_esync_reply *req )
fprintf( stderr, ", shm_idx=%08x", req->shm_idx );
}
static void dump_get_esync_fd_request( const struct get_esync_fd_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
}
static void dump_get_esync_fd_reply( const struct get_esync_fd_reply *req )
{
fprintf( stderr, " type=%d", req->type );
fprintf( stderr, ", shm_idx=%08x", req->shm_idx );
}
static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_new_process_request,
(dump_func)dump_get_new_process_info_request,
......@@ -4795,6 +4806,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_resume_process_request,
(dump_func)dump_get_next_thread_request,
(dump_func)dump_create_esync_request,
(dump_func)dump_get_esync_fd_request,
};
static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
......@@ -5076,6 +5088,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
NULL,
(dump_func)dump_get_next_thread_reply,
(dump_func)dump_create_esync_reply,
(dump_func)dump_get_esync_fd_reply,
};
static const char * const req_names[REQ_NB_REQUESTS] = {
......@@ -5357,6 +5370,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"resume_process",
"get_next_thread",
"create_esync",
"get_esync_fd",
};
static const struct
......
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