Commit 4c57f1bd authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

server: Create eventfd descriptors for timers.

parent 6c0379f0
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "file.h" #include "file.h"
#include "handle.h" #include "handle.h"
#include "request.h" #include "request.h"
#include "esync.h"
static const WCHAR timer_name[] = {'T','i','m','e','r'}; static const WCHAR timer_name[] = {'T','i','m','e','r'};
...@@ -61,10 +62,12 @@ struct timer ...@@ -61,10 +62,12 @@ struct timer
struct thread *thread; /* thread that set the APC function */ struct thread *thread; /* thread that set the APC function */
client_ptr_t callback; /* callback APC function */ client_ptr_t callback; /* callback APC function */
client_ptr_t arg; /* callback argument */ client_ptr_t arg; /* callback argument */
int esync_fd; /* esync file descriptor */
}; };
static void timer_dump( struct object *obj, int verbose ); static void timer_dump( struct object *obj, int verbose );
static int timer_signaled( struct object *obj, struct wait_queue_entry *entry ); static int timer_signaled( struct object *obj, struct wait_queue_entry *entry );
static int timer_get_esync_fd( struct object *obj, enum esync_type *type );
static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry ); static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry );
static void timer_destroy( struct object *obj ); static void timer_destroy( struct object *obj );
...@@ -76,7 +79,7 @@ static const struct object_ops timer_ops = ...@@ -76,7 +79,7 @@ static const struct object_ops timer_ops =
add_queue, /* add_queue */ add_queue, /* add_queue */
remove_queue, /* remove_queue */ remove_queue, /* remove_queue */
timer_signaled, /* signaled */ timer_signaled, /* signaled */
NULL, /* get_esync_fd */ timer_get_esync_fd, /* get_esync_fd */
timer_satisfied, /* satisfied */ timer_satisfied, /* satisfied */
no_signal, /* signal */ no_signal, /* signal */
no_get_fd, /* get_fd */ no_get_fd, /* get_fd */
...@@ -111,6 +114,10 @@ static struct timer *create_timer( struct object *root, const struct unicode_str ...@@ -111,6 +114,10 @@ static struct timer *create_timer( struct object *root, const struct unicode_str
timer->period = 0; timer->period = 0;
timer->timeout = NULL; timer->timeout = NULL;
timer->thread = NULL; timer->thread = NULL;
timer->esync_fd = -1;
if (do_esync())
timer->esync_fd = esync_create_fd( 0, 0 );
} }
} }
return timer; return timer;
...@@ -182,6 +189,9 @@ static int set_timer( struct timer *timer, timeout_t expire, unsigned int period ...@@ -182,6 +189,9 @@ static int set_timer( struct timer *timer, timeout_t expire, unsigned int period
{ {
period = 0; /* period doesn't make any sense for a manual timer */ period = 0; /* period doesn't make any sense for a manual timer */
timer->signaled = 0; timer->signaled = 0;
if (do_esync())
esync_clear( timer->esync_fd );
} }
timer->when = (expire <= 0) ? expire - monotonic_time : max( expire, current_time ); timer->when = (expire <= 0) ? expire - monotonic_time : max( expire, current_time );
timer->period = period; timer->period = period;
...@@ -209,6 +219,13 @@ static int timer_signaled( struct object *obj, struct wait_queue_entry *entry ) ...@@ -209,6 +219,13 @@ static int timer_signaled( struct object *obj, struct wait_queue_entry *entry )
return timer->signaled; return timer->signaled;
} }
static int timer_get_esync_fd( struct object *obj, enum esync_type *type )
{
struct timer *timer = (struct timer *)obj;
*type = timer->manual ? ESYNC_MANUAL_SERVER : ESYNC_AUTO_SERVER;
return timer->esync_fd;
}
static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry ) static void timer_satisfied( struct object *obj, struct wait_queue_entry *entry )
{ {
struct timer *timer = (struct timer *)obj; struct timer *timer = (struct timer *)obj;
...@@ -223,6 +240,7 @@ static void timer_destroy( struct object *obj ) ...@@ -223,6 +240,7 @@ static void timer_destroy( struct object *obj )
if (timer->timeout) remove_timeout_user( timer->timeout ); if (timer->timeout) remove_timeout_user( timer->timeout );
if (timer->thread) release_object( timer->thread ); if (timer->thread) release_object( timer->thread );
if (do_esync()) close( timer->esync_fd );
} }
/* create a timer */ /* create a timer */
......
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